Skip to content

(Ethers v6) Parsing partial calldata given a FunctionFragment #4380

Answered by ricmoo
shazow asked this question in Q&A
Discussion options

You must be logged in to vote

In general the ABI format is not streamable, you can certainly build something to incrementally decode non-dynamic components, like uint and bool; the easiest thing to do would be to repeatedly call something like AbiCoder.decode(inputs.slice(0, i), data) inside a try..catch inside a for loop (sorry, not a computer, so it’s hard to type, let me know if you want that expanded into proper code).

But any dynamic components (including the length of that component) are in the encoded data after 32 bytes times the number of parameter, so their values aren’t present at all if you only have the beginning. Each entry that is a dynamic type is a pointer to the location after all the data/pointers.

S…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@shazow
Comment options

Answer selected by shazow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants