When I execute this:

bytes8 h = 0x000008dfe2f440000733c;

the calldata is :

0: 0x3370204e000000000000000000000000000000000000000008dfe2f440000733c00000008dfe2f440000733c000000000000000000000000000000000000000000000000

I split it by 32bytes:


Why is this?

  • 3
    The function selector is always 4 bytes, so that's in its own "slot" Sep 20 '18 at 10:33
  • This question demonstrates the padding in calldata, as @Mikhail answers. The actual call doesn't make usual sense because enter is a function that only has one parameter, so naively h typically won't be used.
    – eth
    Nov 14 '19 at 8:48
  • How to find out the maximum size of the calldata? Mar 16 '21 at 10:05
3370204e // bytes4(keccak256("enter(bytes8)"))
000000000000000000000000000000000000000008dfe2f440000733c0000000 // 0x8dfe2f440000733c0000000 uint96 padded to 32 bytes
8dfe2f440000733c000000000000000000000000000000000000000000000000 // 0x000008dfe2f440000733c bytes8 padded to 32 bytes

From documentation:

Furthermore, to interface with contracts that do not adhere to the ABI, the function call is provided which takes an arbitrary number of arguments of any type. These arguments are padded to 32 bytes and concatenated. One exception is the case where the first argument is encoded to exactly four bytes. In this case, it is not padded to allow the use of function signatures here.

Note that uintN is left padded and bytesN is right padded. From documentation:

uint<M>: enc(X) is the big-endian encoding of X, padded on the higher-order (left) side with zero-bytes such that the length is 32 bytes.

bytes<M>: enc(X) is the sequence of bytes in X padded with trailing zero-bytes to a length of 32 bytes.


Like @libertylocked said in their comment, the function selector is 4 bytes, so you have to remove those 4 bytes before splitting by 32 bytes to get the individual words.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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