17

What purpose does the "calldata" serve in this parameter _owners? Is it a new keyword?

  function setup(address[] calldata _owners, uint256 _threshold, address to, bytes calldata data)

Taken from Gnosis Safe Contract - GnosisSafe.sol

1

2 Answers 2

28

As per the Solidity version 0.5.0 breaking changes here :

Explicit data location for all variables of struct, array or mapping types is now mandatory. This is also applied to function parameters and return variables.

So currently, reference types comprise structs, arrays and mappings. If you use a reference type, you always have to explicitly provide the data area where the type is stored:

  • memory (whose lifetime is limited to a function call)

  • storage (the location where the state variables are stored)

  • calldata (special data location that contains the function arguments, only available for external function call parameters).

So here in the shared contract, data location has been mentioned which is calldata. Hope it helps.

0

calldata is immutable and temporary data location. if you are not going to modify the function argument use calldata to save gas. otherwise use memory keyword.

Your Answer

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

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