我正在尝试调用一个类似于以下内容的 Solidity 函数:
function fillOrder(
Order memory order,
uint256 takerAssetFillAmount,
bytes memory signature
)
使用 web3j 我会创建类似于下面的函数,但是我不太确定如何表示在 Solidity 中表示为结构的顺序。
List<Type> inputParams = Arrays.asList(???, new
Uint256(takerAssetFillAmount), new Bytes32(signture));
new Function("fillOrder", inputParams, Collections.emptyList());
关于如何表示结构的任何指示?
谢谢。
最佳答案
您可以用方括号将参数括起来。
例如,假设我有一份契约(Contract):
contract Test {
struct Foo {
uint a;
string b;
address c;
}
function bar (Foo memory foo) public {
c = foo.c;
}
}
我可以使用 web3.js
调用 bar
函数,如下所示:
contract.methods.foo([123, "123", "0xABC...."]).send({ from: '0x...' })
关于ethereum - 如何使用 web3j 将元组编码为函数的输入参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52620848/