exec
Call a contract function, encoding the arguments from its signature.
Supports runtime fields inside smart blocks. Use explicit @helper! expressions or captured outputs; other fields are evaluated at build time.
Syntax
Section titled “Syntax”exec <contractAddress> <signature> [...params]Arguments
Section titled “Arguments”| Name | Type | Evaluation | Description |
|---|---|---|---|
contractAddress | address | Runtime in smart blocks | Target contract address |
signature | write-abi | Build time | Function signature (e.g. "transfer(address,uint256)") |
[...params] | any | Runtime in smart blocks | Arguments matching the signature types |
Options
Section titled “Options”| Name | Type | Evaluation | Description |
|---|---|---|---|
--value | number | Runtime in smart blocks | ETH to send with the call (in wei) |
--from | address | Build time | Sender address (requires simulation or connected wallet) |
--gas | number | Build time | Gas limit |
--max-fee-per-gas | number | Build time | Max fee per gas (EIP-1559) |
--max-priority-fee-per-gas | number | Build time | Max priority fee per gas (EIP-1559) |
--nonce | number | Build time | Transaction nonce override |
Examples
Section titled “Examples”# Approve a tokenexec @token(DAI) "approve(address,uint256)" 0x64c007ba4ab6184753dc1e8e7263e8d06831c5f6 1200e18
# Send ETH with the callexec 0xe91d153e0b41518a2ce8dd3d7944fa863463a97d "deposit()" --value 1e18
# Specify senderexec @token(DAI) "approve(address,uint256)" 0x64c007ba4ab6184753dc1e8e7263e8d06831c5f6 1200e18 --from 0x44fA8E6f47987339850636F88629646662444217
# Capture events from the transactionload simset $wxdai 0xe91d153e0b41518a2ce8dd3d7944fa863463a97dsim:fork --using anvil ( sim:set-balance @me 1e18 exec $wxdai "deposit()" --value 0.001e18 -> Deposit(address indexed, uint) [_ $amount] exec $wxdai "withdraw(uint)" $amount)
# Complex parameter typesexec 0xd0e81E3EE863318D0121501ff48C6C3e3Fd6cbc7 "addBatches(bytes32[],bytes)" [0x02732126661d25c59fd1cc2308ac883b422597fc3103f285f382c95d51cbe667] @bytes(QmTik4Zd7T5ALWv5tdMG8m2cLiHmqtTor5QmnCSGLUjLU2)Revert Captures
Section titled “Revert Captures”Revert captures (-!> / -?!>) catch transaction reverts and decode the error data into variables. Three forms are available after the error name: nothing (assertion only), destructure ([...]), or a boolean variable ($var). A failure raised before the transaction is sent — an argument that will not encode, a read that reverts in an inline call — is a refusal of the line and is caught with -/> / -?/> instead; a revert capture lets it through untouched.
set $c 0x44fA8E6f47987339850636F88629646662444217
# Assert a specific error without capturing dataexec $c "deny()" -!> Unauthorized()
# Destructure error arguments into variablesexec $c "withdraw(uint256)" 200 -!> InsufficientBalance(uint256,uint256) [$balance $required]
# Catch a require/revert reasonexec $c "transfer(address,uint256)" @me 100e18 -!> Error(string) [$reason]
# Boolean variable: $e is "true" if the error matchedexec $c "deny()" -!> Unauthorized() $e
# Generic catch-all (no error name)exec $c "doSomething()" -!> [$reason]exec $c "doSomething()" -!> $e
# Optional: skip silently if tx succeedsexec $c "maybeRevert()" -?!> Error(string) [$reason]exec $c "maybeRevert()" -?!> Unauthorized() $e # $e = "false" if tx succeeds or wrong error-!>expects the transaction to revert; throws if it succeeds-?!>captures the error if the tx reverts; silently continues if it succeeds- With a boolean variable (
$e),-?!>sets$e = "false"on success or mismatched error;-!>always sets$e = "true"(throws otherwise) - Supported error types: custom named errors from the target's ABI,
Error(string)(require/revert),Panic(uint256)(assert), and empty reverts - Use
-/>/-?/>for a failure raised before the send; see Captures
- The signature follows Solidity syntax:
"functionName(type1,type2)" - Parameters are automatically ABI-encoded based on the signature
- Use
--valueto send ETH with the call - Use
--fromto impersonate a sender (requires simulation mode) - Event captures (
->) execute the transaction immediately and store decoded log values in variables - Revert captures (
-!>/-?!>) catch and decode transaction reverts; refusal captures (-/>/-?/>) catch a failure raised before the send