10 Java Web3j Function 构造 struct array 入参

_20220509020458.png

我的智能合约方法如图所示,我想要用 Java 的 web3j 调用这个方法,我尝试多种办法去构造 Function 对象,总是报错。以下是我的代码:

List<Uint8> inputParameters = new ArrayList<>();
        inputParameters.add(new Uint8(9));
        inputParameters.add(new Uint8(8));
        inputParameters.add(new Uint8(4));

        Function function = new Function(
                "test1",
                Arrays.asList(new DynamicArray(StaticStruct.class, inputParameters)),
                Collections.<TypeReference<?>>emptyList()
        );

大佬们,这个入参我该如何构造啊,试了好多都是报错,不好使啊,小弟先行谢过了。

请先 登录 后评论

最佳答案 2022-05-09 11:18

应该用staticstruct 去装abc new DynamicArray(StaticStruct.class,List.of(new StaticStruct(a,bc)))

请先 登录 后评论

其它 2 个回答

tengdw
请先 登录 后评论
tengdw
请先 登录 后评论