18

solidity中的struct结构体问题

 2 years ago
source link: https://learnblockchain.cn/question/3106
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

solidity中的struct结构体问题 | 登链社区 | 技术问答

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK