Performing Multicall
Overview
Starknet Foundry sncast
supports executing multiple deployments or calls with the sncast multicall run
command.
📝 Note
sncast multicall run
executes 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
id
property in a deploy call, which is then referenced as thecontract address
in an invoke call. Additionally, theid
can 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:
command: multicall
transaction_hash: [..]
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:
command: multicall new
content: [[call]]
call_type = "deploy"
class_hash = ""
inputs = []
id = ""
unique = false
[[call]]
call_type = "invoke"
contract_address = ""
function = ""
inputs = []
path: ./template.toml
⚠️ Warning Trying to pass any existing file as an output for
multicall new
will 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:
command: multicall new
content: [[call]]
call_type = "deploy"
class_hash = ""
inputs = []
id = ""
unique = false
[[call]]
call_type = "invoke"
contract_address = ""
function = ""
inputs = []
path: ./template.toml