Skip to content
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

Invalid encoding of dynamic types #17

Open
pgebal opened this issue Jun 21, 2018 · 2 comments
Open

Invalid encoding of dynamic types #17

pgebal opened this issue Jun 21, 2018 · 2 comments

Comments

@pgebal
Copy link

pgebal commented Jun 21, 2018

Hi,
thanks for exthereum/abi. When using it I've noticed that calls to functions with arguments of dynamic types are not properly encoded.

ABI.encode("foo(bytes)", [<<1>>]) |> Base.encode16(case: :lower)
outputs
"30c8d1da00000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000"
The correct output is:
"30c8d1da000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000"
The missing part is:
0000000000000000000000000000000000000000000000000000000000000020
which is a head part of encoded bytes and should be put right behind encoded function signature.
https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#use-of-dynamic-types

@hswick
Copy link

hswick commented Jun 21, 2018

You may want to check this out #13

@ayrat555
Copy link
Member

A couple of months ago I re-wrote encoder and decoder of abi n https://github.com/poanetwork/ex_abi . it should be fixed there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants