8000 Can't generate java wrapper class of a smartcontract having struct array. Error: part 'struct MLevel' is keyword · Issue #91 · LFDT-web3j/web3j-cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Can't generate java wrapper class of a smartcontract having struct array. Error: part 'struct MLevel' is keyword #91
Open
@ShoaibKakal

Description

@ShoaibKakal

I've a smartcontract in which I've a function getLevels() that returns an array of struct type MLevel, defined at the beginning of smartcontract.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

struct MLevel{
    address id;
    string levelPrize;
    uint levelNo;
    uint levelCriteria;
}

contract Test{

  MLevel[] public mlevels;

    function addLevel(uint _levelCriteria, string memory _levelPrize)public payable{
        MLevel memory level;
        level.id = msg.sender;
        level.levelCriteria = _levelCriteria;
        level.levelPrize = _levelPrize;
        mlevels.push(level);
    }

    function getLevels() public view returns(MLevel [] memory){
        return mlevels;
    }

}

The above smartcontract works absolutely fine in Remix ide. But when I try to create its java wrapper class using web3j, wrapper class does not generate and web3j ends with a weird error part 'struct MLevel' is keyword as shown below in the image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0