gpt4 book ai didi

java - Web3j v3.3.1 : Error while generating compiled solidity smart contracts which returns array of struct

转载 作者:行者123 更新时间:2023-12-02 11:28:48 26 4
gpt4 key购买 nike

我从 Solidity 函数返回一个结构数组,如下所示。

编译指示可靠性^0.4.21;

编译指示实验 ABIEncoderV2;

函数 getPurchaseOrderForVendor(stringvendorNameInput) 常量返回 (PurchaseOrderStruct[])

编译为abi和bin文件。问题在于使用 web3j(v3.3.1) 为合约创建包装文件。我收到以下错误。

Generating com.contract.InvoiceSettlement_sol_InvoiceSettlement ... 
Exception in thread "main" java.lang.UnsupportedOperationException:
Unsupported type
encountered: tuple
at org.web3j.abi.datatypes.generated.AbiTypes.getType(AbiTypes.java:221)

at org.web3j.codegen.SolidityFunctionWrapper.buildTypeName(SolidityFunct
ionWrapper.java:851)
at org.web3j.codegen.SolidityFunctionWrapper.buildTypeNames(SolidityFunc
tionWrapper.java:508)
at org.web3j.codegen.SolidityFunctionWrapper.buildFunction(SolidityFunct
ionWrapper.java:523)
at org.web3j.codegen.SolidityFunctionWrapper.buildFunctionDefinitions(So
lidityFunctionWrapper.java:216)
at org.web3j.codegen.SolidityFunctionWrapper.generateJavaFiles(SolidityF
unctionWrapper.java:112)
at org.web3j.codegen.SolidityFunctionWrapper.generateJavaFiles(SolidityF
unctionWrapper.java:94)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.generate(SolidityF
unctionWrapperGenerator.java:123)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.main(SolidityFunct
ionWrapperGenerator.java:87)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.run(SolidityFuncti
onWrapperGenerator.java:48)
at org.web3j.console.Runner.main(Runner.java:38)

最佳答案

Solidity 不支持在外部调用中返回结构。仅允许在内部函数调用中使用。您需要分解结构并通过元组返回元素。

来源:Solidity documentation

关于java - Web3j v3.3.1 : Error while generating compiled solidity smart contracts which returns array of struct,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49428518/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com