Link (create function): https://github.com/balancer-labs/balancer-v2-monorepo/blob/master/pkg/pool-weighted/contracts/WeightedPoolFactory.sol
string memory name,
string memory symbol,
IERC20 memory tokens,
uint256 memory normalizedWeights,
IRateProvider memory rateProviders,
) external returns (address)
function create(string calldata name,
string calldata symbol,
IERC20 calldata tokens,
uint256 calldata normalizedWeights,
IRateProvider calldata rateProviders,
address owner) external returns (address);
Just wanted to double check since I've never had to write an interface equivalent for a complicated function.
As far as I can see, you've replicated the function declaration, and then replaced every occurrence of
The reason for that is unclear to me, because '
calldata' has no "special meaning" related to interfaces.
calldata keyword is used for indicating that the pointed input data is read-only (cannot be modified inside the function), which allows for some minor gas optimization.
calldata input argument can be passed to a function either from another function which has received it as
calldata, or from the offchain.
In other words, you cannot create a
calldata object inside a contract function.
You can read the basic facts about interfaces here (see TLDR below).
You can interact with other contracts by declaring an
- It cannot have any functions implemented
- It can inherit from other interfaces
- All declared functions must be external
- It cannot declare a constructor
- It cannot declare state variables
As you can see, nothing specifically related to '
Other than gas optimization, receiving an input as
calldata allows you to apply "fancy tricks" on it, such as array slicing, which you cannot apply on
Can we discuss in detail about the smart contract?
Your answers are always correct.
What do you want to discuss?
Do you have ongoing project?
You can find my TG address via developer wanted post.
Please contact me via TG