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,370 points
1,988 views

1 answer to this question.

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
• 17,100 points

Related Questions In Blockchain

0 votes
1 answer

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

Solidity does not support returning structs in ...READ MORE

answered Jun 19, 2018 in Blockchain by aryya
• 7,460 points
1,673 views
+1 vote
2 answers

Challenge while setting up Hyperledger Fabric 1.0 in Ubuntu 16.04

The rocksdb error you're seeing wouldn't be ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,610 points

edited Jun 8, 2020 by Sirajul 1,156 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
1,927 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
2,126 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,455 views
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
• 17,100 points
3,607 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 27, 2018 in Blockchain by Perry
• 17,100 points
1,067 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP