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

Calling function that requires bytes argument fails #139

Open
cjimison opened this issue Aug 11, 2022 · 0 comments
Open

Calling function that requires bytes argument fails #139

cjimison opened this issue Aug 11, 2022 · 0 comments

Comments

@cjimison
Copy link

cjimison commented Aug 11, 2022

I have been running into a case where if I use ExW3 with a solidity smart contract that needs a bytes function argument it will fail. I think this might be related to how the encoding works within ExW3, however when I bypass ExW3 and use ABI directly it works:

ABI.encode("setTest(bytes)", [encoded_data])

From what I can tell, there seems to be an extra 64 bytes of data being included in the ExW3 version that I am not sure where it is coming from.

Example:

# Fails when submitted as part of the transaction

# the variable `abi` was parsed from the contract abi file using ExW3
ExW3.Abi.encode_method_call(abi, "setTest", [<<1,2,3,4>>])
"0af724830000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000040102030400000000000000000000000000000000000000000000000000000000"

# Works when submitted as part of the transaction

ABI.encode("setTest(bytes)", [<<1,2,3,4>>]) |> Base.encode16(case: :lower)
"0af72483000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000040102030400000000000000000000000000000000000000000000000000000000"

Looking at the output it seems to be include a second "0x2" block of 64 bytes so I think something is getting wrapped twice.

@cjimison cjimison changed the title Calling function that takes requires bytes fails Calling function that requires bytes argument fails Aug 11, 2022
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

1 participant