web3.php
web3.php copied to clipboard
Not compatible with ABIEncoderV2 when receiving struct
Just to let you know you have a problem with ABIEncoderV2 if you are trying to call a function that returns a struct.
Call to a member function staticPartLength() on integer
@AdamMiltonBarker hi, im getting this error too, how do you fix it?
Hello. Any news on this ?
I'm getting the same issue. Is there any update?
I'm getting the same error. Is there a fix for this issue?
The error is on this line:/Contracts/Ethabi.php:226
any updates on this?
So here, I've been looking through the code, trying to figure out how to fix this with a real case. This will require the addition of a new type tuple[]. This is obviously not supported at the moment.
This will break when you have an array of structs being returned. Let's say you have a GameItem[] as the return type. This will break because of two reasons. The first reason is that the tuple[] type doesn't exist. The second reason is that the tuple[] has a different output structure as the other types. There is a 'components' portion, per tuple that contains a set of elements (uint, int, ect...).
Hello, trying to fix that as well, but I'm a little lost in what we need to change in the code to support the decoding for this tuple[] solidity type. Is this something complex to implement in the current library architecture or a good first issue as mentioned by the tag affected to this issue ;-)
I didn't find yet any solution/other lib in PHP to handle smartcontract which return array of structs (tuple[])
@sc0Vu Hi, what's your plan about supporting ABIEncoderV2 tuple[] type ?
Hello,
is there any update on this?
If anyone still encounters, the solution I found was: take the txData returned by the call itself, strip leading 0x, split at each 64 chars (32 bytes) and based on the struct of the function, decode each param by it's own type.
struct structure in my case: { uint256 uint256 address }
so I splitted the string at each 64 chars, so I receive a total of 11 items, first item is 0x20, it means 32 bytes, the second item is the length of structs, in my case: 3 so I take the next 3 batches of each 3 items and decode following: uint256 decode for split[2] uint256 decode for split[3] address decode for split[4] and so on till split[10]
Hope it helps someone, been wrapping my head for few hours
If anyone still encounters, the solution I found was: take the txData returned by the call itself, strip leading 0x, split at each 64 chars (32 bytes) and based on the struct of the function, decode each param by it's own type.
struct structure in my case: { uint256 uint256 address }
so I splitted the string at each 64 chars, so I receive a total of 11 items, first item is 0x20, it means 32 bytes, the second item is the length of structs, in my case: 3 so I take the next 3 batches of each 3 items and decode following: uint256 decode for split[2] uint256 decode for split[3] address decode for split[4] and so on till split[10]
Hope it helps someone, been wrapping my head for few hours
That's basically parsing the ABI code manually ;)
I've been waiting for this too for some months already... I'm starting a custom library now on top of some libraries from web3p & kornrunner.
Hey, created new pull based on Abaowu pull with minimal code... any chances to include it? https://github.com/web3p/web3.php/pull/299
If anyone wants to test: https://github.com/slawomir-pryczek/web3.php
It would be nice if this feature could be somehow prioritized, as it is also mentioned in #265.
If that's not the case, it should be clearly communicated that the library will not be maintained anymore. In that case, the community could potentially focus on alternatives (e.g. @drlecks's simple-web3-php)
Hey, just FYI, new ABI format is more complex than that so even using these patches (mine or Abaowu) won't make it fully AbiV2 compatible. And looking at abi encoder/decoder code probably it'll need rewrite...
Hey guys any update on Tuple issue? Help needed :)