solidity中的struct结构体问题

环境:

java8, web3j:5.0.0

问题:

请教各位大佬

1:web3j如何解析solidity中的struct结构体数组? 2:web3j的4.5.5版本命令行工具无法生成带struct结构体的java包装类


solidity代码:

struct Nft {
uint256 a;
uint256 b;
}

java代码:

public static class NFT extends DynamicStruct {
public BigInteger a;
public BigInteger b;
public NFT(BigInteger a, BigInteger b) {
    super(
            new org.web3j.abi.datatypes.generated.Uint256(a),
            new org.web3j.abi.datatypes.generated.Uint256(b));
    this.a = a;
    this.b = b;
}

public NFT(Uint256 a, Uint256 b) {
    super(a, b);
    this.a = b.getValue();
}
}

封装:

Function function = new Function(methodName, inputParameters, Arrays.asList(
new TypeReference<StaticArray1<NFT>>() {
}
));

issues: https://github.com/web3j/web3j/issues/1422

请先 登录 后评论

2 个回答

Tiny熊
  擅长:智能合约,以太坊
请先 登录 后评论
zwm
请先 登录 后评论
  • 2 关注
  • 0 收藏,2753 浏览
  • bubble21 提出于 2022-02-18 14:19