What is calldata? I learned that there are three types of memories:

  1. Storage
  2. Memory
  3. Stack

In the Ethereum docs, it says that the function parameters are of type memory by default.

However, I've also read an article which said that function arguments are stored in calldata.

Now, I don't know what calldata is, can somebody please help me?


  • in simpler term calldata is the data provided within the call made to the smart contract. as @eth have explained it's the function's signature and the parameters provided. – Badr Bellaj Dec 17 '19 at 21:44

Here is an example from What is an ABI and why is it needed to interact with contracts?

contract Foo {
  function baz(uint32 x, bool y) returns (bool r) { r = x > 32 || y; }

If we wanted to call baz with the parameters 69 and true, we would pass 68 bytes in total, which can be broken down into:

0xcdcd77c0: the Method ID. This is derived as the first 4 bytes of the Keccak-256 hash of the ASCII form of the signature baz(uint32,bool). 0x0000000000000000000000000000000000000000000000000000000000000045: the first parameter, a uint32 value 69 padded to 32 bytes. (69 is hex 0x45.) 0x0000000000000000000000000000000000000000000000000000000000000001: the second parameter - boolean true, padded to 32 bytes

The 68 bytes is the calldata: 0xcdcd77c000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001.

| improve this answer | |

calldata is where data from external calls to functions is stored.

Functions can be called internally, e.g. from within the contract, or externally. When a function's visibility is external, only external contracts can call that function.

When such an external call happens, the data of that call is stored in calldata.

Read also here: `external` vs `public` best practices

| improve this answer | |
  • External calls of functions! I nust know we can call a function but this terminology I dont det this – Sheikh Jul 9 '18 at 14:38
  • Can you please explain a little bit – Sheikh Jul 9 '18 at 14:38
  • I edited the response to include more info – schemar Jul 9 '18 at 14:53

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.