Performing Multicall
Overview
Starknet Foundry sncast supports executing multiple deployments or calls with the sncast multicall run command.
📝 Note
sncast multicall runexecutes only one transaction containing all the prepared calls. Which means the fee is paid once.
You need to provide a path to a .toml file with declarations of desired operations that you want to execute.
You can also compose such config .toml file with the sncast multicall new command.
For a detailed CLI description, see the multicall command reference.
Example
multicall run Example
Example file:
[[call]]
call_type = "deploy"
class_hash = "0x076e94149fc55e7ad9c5fe3b9af570970ae2cf51205f8452f39753e9497fe849"
inputs = []
id = "map_contract"
unique = false
[[call]]
call_type = "invoke"
contract_address = "map_contract"
function = "put"
inputs = ["0x123", 234] # Numbers can be used directly without quotes
After running sncast multicall run --path file.toml, a declared contract will be first deployed, and then its function put will be invoked.
📝 Note The example above demonstrates the use of the
idproperty in a deploy call, which is then referenced as thecontract addressin an invoke call. Additionally, theidcan be referenced in the inputs of deploy and invoke calls 🔥
💡 Info Inputs can be either strings (like
"0x123") or numbers (like234).
📝 Note For numbers larger than 2^63 - 1 (that can't fit into
i64), use string format (e.g.,"9223372036854775808") due to TOML parser limitations.
$ sncast multicall run --path multicall_example.toml
Output:
Success: Multicall completed
Transaction Hash: 0x[..]
To see invocation details, visit:
transaction: https://sepolia.starkscan.co/tx/[..]
💡 Info Max fee will be automatically computed if
--max-fee <MAX_FEE>is not passed.
multicall new Example
You can also generate multicall template with multicall new command, specifying output path.
$ sncast multicall new ./template.toml
Output:
Success: Multicall template created successfully
Path: ./template.toml
Content: [[call]]
call_type = "deploy"
class_hash = ""
inputs = []
id = ""
unique = false
[[call]]
call_type = "invoke"
contract_address = ""
function = ""
inputs = []
⚠️ Warning Trying to pass any existing file as an output for
multicall newwill result in error, as the command doesn't overwrite by default.
multicall new With overwrite Argument
If there is a file with the same name as provided, it can be overwritten.
$ sncast multicall new ./template.toml --overwrite
Output:
Success: Multicall template created successfully
Path: ./template.toml
Content: [[call]]
call_type = "deploy"
class_hash = ""
inputs = []
id = ""
unique = false
[[call]]
call_type = "invoke"
contract_address = ""
function = ""
inputs = []