简体   繁体   English

Web3j v3.3.1:生成返回结构数组的已编译固体智能合约时出错

[英]Web3j v3.3.1 : Error while generating compiled solidity smart contracts which returns array of struct

I am returning an array of struct from solidity function as below. 我从如下的solidity函数返回一个结构数组。

pragma solidity ^0.4.21; 语用强度^ 0.4.21;

pragma experimental ABIEncoderV2; 实用实验性ABIEncoderV2;

function getPurchaseOrderForVendor(string vendorNameInput) constant returns (PurchaseOrderStruct[]) 函数getPurchaseOrderForVendor(string vendorNameInput)常量返回(PurchaseOrderStruct [])

It is compiled to abi and bin files. 它被编译为abi和bin文件。 The issue is with creating wrapper files for the contract using web3j(v3.3.1). 问题在于使用web3j(v3.3.1)为合同创建包装文件。 Im getting the below errors. 我收到以下错误。

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 does not support returning structs in external calls. 实体不支持在外部调用中返回结构。 It is only allowed in internal function calls. 仅在internal函数调用中允许。 You need to decompose the struct and return the elements via a tuple. 您需要分解结构并通过元组返回元素。

Source: Solidity documentation 资料来源: Solidity文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM