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 Data when decoding #245

Open
honkler opened this issue Sep 21, 2021 · 2 comments
Open

Invalid Data when decoding #245

honkler opened this issue Sep 21, 2021 · 2 comments

Comments

@honkler
Copy link

honkler commented Sep 21, 2021

I'm trying to decode UniswapRouter functions. Decoding the method

swapExactTokensForETH(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline)

returns

./ethabi decode params -t '(uint256,uint256,address[],address,uint256)' 0000000000000000000000000000000000000000000000b0edf30260784f1a08000000000000000000000000000000000000000000000000264439d42c24ad2600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000ca274cc0405bd4317adc3cd5975265be503f1ee50000000000000000000000000000000000000000000000000000017c04528c94000000000000000000000000000000000000000000000000000000000000000200000000000000000000000001c2086facfd7aa38f69a6bd8c91bef3bb5adfca000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7 Error: Invalid data

while the same works fine using web3.js:

3263773007792569260552,2757392455294037286,[0x01C2086faCFD7aA38f69A6Bd8C91BEF3BB5adFCa,0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7],0xCA274cc0405Bd4317Adc3Cd5975265be503f1ee5,1632160091284

Other functions in the same ABI like addLiquidity return correct data. I tried leaving the mehod id in, but it makes no difference. Sorry for bad formatting.

@YNX940214
Copy link

just use https://crates.io/crates/ethereum_abi , much better

@kamikazebr
Copy link

kamikazebr commented Jun 24, 2022

@honkler
you need run it without tuple and individual

ethabi decode params -t 'uint256' -t 'uint256' -t 'address[]' -t 'address' -t 'uint256' 0000000000000000000000000000000000000000000000b0edf30260784f1a08000000000000000000000000000000000000000000000000264439d42c24ad2600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000ca274cc0405bd4317adc3cd5975265be503f1ee50000000000000000000000000000000000000000000000000000017c04528c94000000000000000000000000000000000000000000000000000000000000000200000000000000000000000001c2086facfd7aa38f69a6bd8c91bef3bb5adfca000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7

result

uint256 b0edf30260784f1a08
uint256 264439d42c24ad26
address[] [01c2086facfd7aa38f69a6bd8c91bef3bb5adfca,b31f66aa3c1e785363f0875a1b74e27b85fd66c7]
address ca274cc0405bd4317adc3cd5975265be503f1ee5
uint256 17c04528c94

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