-
Notifications
You must be signed in to change notification settings - Fork 0
Support returning structs from functions #33
Comments
Is there an ETA for this , next protocol release / Solidity 0.5.0? |
EncoderV2 is in 0.4.0 already, you can specify to use it with the following code
Although I didn't have a chance to test it well in read world yet, requires some beta Solidity compiler voodoo. So far it's backward compatible with V1 anyway |
I've tried it with the 0.4.22 compiler. |
Hello @kyriediculous I've made the following contract
So far the latest version from develop branch branch successfully works with "testSingle" method. Sincerely, Alex |
Full support should be in master now |
Full encoding support is also in master now |
It's likely that this is compatible with web3 1.0.0 right now but not with anything else; Not with remix or web3 implementations that are compatible with Metamask (since they are web3 1.0.0 incompatible) as of writing. Of course this isn't at your end. Remix:
|
Yes, as far as I know remix and web3 are based on ethereumjs-abi JavaScript package and do not support decoding yet (etherjs does support V2 encoding). Nevertheless you can follow an ABI spec from solidity documents directly and implement it. I’ve published this contract and was calling a function as a part of the test, Ethereum network itself works with contracts with experimental ABI, and 0.4.22 looks quite stable with it (they had to implement usage of “returndatasize” assembler instructions to make it possible to return a structure, that was merged as a part of 0.4.22), so I expect ABIv2 to become stable and non-experimental somewhere in 0.4.23 or 0.5 that should come quite soon.
You can look at the tests for web3swift and find a full ABI and contract address on Rinkeby. Any pull requests to add more exhaustive tests and edge cases are welcome.
Sincerely, Alex
…________________________________
From: kyriediculous <[email protected]>
Sent: Sunday, April 8, 2018 9:08:45 PM
To: BANKEX/web3swift
Cc: Alexander; State change
Subject: Re: [BANKEX/web3swift] Support returning structs from functions (#33)
It's likely that this is compatible with web3 1.0.0 right now but not with anything else; Not with remix or web3 implementations that are compatible with Metamask (since they are web3 1.0.0 incompatible) as of writing.
Of course this isn't at your end.
Remix:
[call] from:0xca35b7d915458ef540ade6068dfe2f44e8fa733c, to:Tester.testSingle(), data:f376e...6e013, return:
{
"error": "Failed to decode output: Error: Unsupported or invalid type: tuple"
}
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub<#33 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AGKv92JmPNUkhlMPo4VtU73ehMoNl3dHks5tmlItgaJpZM4TFEyN>.
|
If I deploy a contract using the ABI experimental function(s) described here for returning a struct from a Soldity function, will it work with Web3.js on Rinkeby and the main net? I'm getting this error during a compile in Remix: browser/video-dummy-data.sol:2:1: Warning: Experimental features are turned on. Do not use experimental features on live deployments. |
Hello @roschler First of all, ABIv2 encoder/decoder in web3swift is backward compatible with a normal one. It will understand all current encoding types, but will also decode experimental features, such as returning structs. You can already use these features if you want by putting this #pragma is your code, and it will be included in 0.5 version of solidity. Interestingly, solidity docs describing ABI encoding imply features of ABIv2, looks like those features just were not implemented yet in main solidity branch. So, if you do not need this features - just remove a pragma and everything will work. If you do need them, you will have to supply a pragma and use V2 decoder from web3swift. Sincerely, Alex |
Thanks Alex! |
Version 0.4.22 still gets issues with that;
ethereum/solidity#40
FYI:
https://ethereum.stackexchange.com/questions/7317/how-can-i-return-struct-when-function-is-called
ethereum/solidity#1601
ethereum/solidity#2948
ethereum/solidity#2863
Depends on #32
The text was updated successfully, but these errors were encountered: