Error while generating smart contracts which returns array of struct in Web3j v3.3.1

0 votes
pragma solidity ^0.4.21;

pragma experimental ABIEncoderV2;

function getPurchaseOrderForVendor(string vendorNameInput) constant returns (PurchaseOrderStruct[])

I am returning an array of struct from solidity function as given above. It is compiled to abi and bin files. The issue is with creating wrapper files for the contract using web3j(v3.3.1). I'm 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)
Jul 26, 2018 in Blockchain by sabby
• 4,050 points
162 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Solidity does not support returning structs in external calls. It is only allowed in internal function calls. You need to decompose the struct and return the elements via a tuple.

You need to either return strings as bytes32, or (my preferred approach) you use one function to return the size of the array you want and have your retrieval function take in an index parameter and return one decomposed struct element at a time.

answered Jul 26, 2018 by Perry
• 16,450 points

Related Questions In Blockchain

0 votes
1 answer
+1 vote
1 answer
+1 vote
1 answer

How is it possible to achieve privacy and confidentiality in smart contracts??

Any contract code written on the blockchain ...READ MORE

answered Apr 18, 2018 in Blockchain by Shashank
• 10,330 points

edited Aug 7, 2018 by Omkar 59 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
63 views
+1 vote
1 answer
0 votes
1 answer

How to set web3 solidity variable value?

The setLog transaction has not yet been mined by ...READ MORE

answered Jul 6, 2018 in Blockchain by Christine
• 15,790 points
76 views
0 votes
1 answer
0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 16,450 points
176 views
0 votes
1 answer

Error while running make command using Fabric 1.0.6

It's a known issue in go 1.9.4: https://github.com/golang/go/issues/23739 While ...READ MORE

answered Jun 26, 2018 in Blockchain by Perry
• 16,450 points
77 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.