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
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityWhat 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
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.
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.