web3j-cli icon indicating copy to clipboard operation
web3j-cli copied to clipboard

Can't generate java wrapper class of a smartcontract having struct array. Error: part 'struct MLevel' is keyword

Open ShoaibKakal opened this issue 3 years ago • 0 comments

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

ShoaibKakal avatar Aug 25 '22 20:08 ShoaibKakal