-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
How to decode tx data #423
Comments
The first 4 bytes of the data is the function sighash (in this case, ethers.utils.defaultAbiCoder.decode(
[ 'bytes', 'string' ],
hexDataSlice(tx.data, 4)
) If you do not know at all what the function was, you can probably make an educated guess by looking at the data; once you've looked at enough call data and know the ABI coding scheme inside and out, you can often guess what the types are, but it takes some time and would be hard to write generic code to attempt this. You would also not be able to figure out the method call name, since it is hashed, unless you made a large rainbow table, and even then you would likely miss many. So, short answer is that if you do not know what the method is, it is very difficult to figure it out. |
Perfect! As a matter of form the totally correct code (based on
|
Awesome! Thanks! :) |
@ricmoo Just a follow up on this, it seems as though MethodID is 10 characters, not 4? |
Method id is 4 bytes (characters can be a confusing term). Each byte is 2 hex characters along with 0x prefix. So in |
After your explanations in #422 I have also managed to decode the data of a transaction that was created by a contract function call by:
Is there also the possibility to decode it with
ethers.utils.defaultAbiCoder.decode
?This
does not work.
And an additional question: If I do not know with which function a transaction has been created, How do I parse/decode it at all?
Thanks for your help in advance!
The text was updated successfully, but these errors were encountered: