I don't understand how ABI encoding with tuples work:

f(uint8[], uint) with arguments [3], 4 accordingly https://abi.hashex.org produces:


  1. In arguments the value 3 goes before 4, but in the encoded 4 is before 3. In some reason, the value 3 is at the very end despite it is in the first element. Why?!

  2. First go all the heads, then all the tails, right? Each head is a 32 bytes offset to the corresponding tail from the beginning of the tuple, right?

1 Answer 1


Strictly speaking, there are no tuples in your example. Type uint8[] is a dynamic array type, not a tuple. Here is the encoding decomposed:

47958782                                                         // Function selector (4 bytes)
0000000000000000000000000000000000000000000000000000000000000040 // Offset of the first argument (32 bytes)
0000000000000000000000000000000000000000000000000000000000000004 // Value of the second argument (32 bytes)
0000000000000000000000000000000000000000000000000000000000000001 // Length of the array (offset points here, 32 bytes)
0000000000000000000000000000000000000000000000000000000000000003 // First element of the array (32 bytes)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.