-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return array of structs now support? #2948
Comments
Try |
The remix IDE says below:
Version:
|
oh I'm sorry - it's |
When execute the return array function it says below
function
|
@EasonWang01 this seems to be a limitation in the decoding library you are using (possibly web3.js). |
Was using Remix IDE,is it possible to decode it? |
Not in Remix currently. |
Do you know how to decode it if not using Remix? |
@EasonWang01 that will need to be written up. I'm not sure if any of the ABIs support it just yet. |
@EasonWang01 Has the problem been solved |
Still cant return array of struct? |
Any help is appreciated! |
Returning structs in general seems to work only for automatic public accessors and fail otherwise.
In remix IDE the failure is "Failed to decode output: Error: Unsupported or invalid type: tuple". I get a similar error in web3.js. |
The difference in the ABI between the cases that decode and the cases that don't is the output type.
Why is there indirection about "components"? The array of dictionaries was already sufficient to describe a struct type, and was already implemented by several decoders. |
@wjmelements web3.js is still lacking an implementation for structs. ethers.js should already be fully compliant. The components-indirection was needed, because the |
Is there any progress yet, in either Remix or Web3.js? I can't see the current workaround. |
@ThomasMW they renamed the repo, which killed that link. Here is the new link: https://github.com/ethereum/remix-ide/issues/920#issuecomment-348069589 |
according to the answer in the url https://github.com/ethereum/remix-ide/issues/920#issuecomment-348069589 which is function all(uint pos) public constant returns(uint id, uint value, uint time){
DonateInfo storage di = list[pos];
return (di.id, di.value, di.time)
} But it is not returning the whole list of array tho, it is taking in an uint and output a specific struct, similar to array[unit]? |
Yup, is it not possible to get all |
Breaking down the struct into an array will not work either without converting strings to bytes and back, it's quite the messy workaround as well imo. Using 0.4.22 and experimental ABIEncoderV2 still getting the error. It would be really cool if this could receive some priority, I imagine many devs would like to see this feature. Not trying to be pushy here 😄 . Wouldn't having a struct as a real object be an "easy" solution? Not that I have any clue what I'm talking about here. Another workaround is constructing your array on the client side with .map() (from an array of integers) I guess... |
"error": "Failed to decode output: Error: Unsupported or invalid type: tuple" |
Why is this closed ? |
Because it has been supported since 0.4.17 by the compiler. |
is it?. Using nightly builds or experimental encoders doesn't really qualifiy as supported imo. |
I agree that this should be re-opened. Trying to return an array of structs is still an active issue in the community. |
You have to activate an experimental feature: #2948 (comment) Having this issue open does not speed up the completion of the experimental feature. |
how do i return a mapping or a array from a solidity function |
You cannot return a mapping. |
@ANUDAVIS Could you please share an example? Without any code, it's hard to reason about your issue. In general, this should work:
|
This is a good pattern to follow. |
Is it support now for solidity?
Thanks for reply.
The text was updated successfully, but these errors were encountered: