Cheatcodes Reference
-
mock_call- mocks a number of contract calls to an entry point -
start_mock_call- mocks contract call to an entry point -
stop_mock_call- cancels themock_call/start_mock_callfor an entry point -
get_class_hash- retrieves a class hash of a contract -
replace_bytecode- replace the class hash of a contract -
l1_handler- executes a#[l1_handler]function to mock a message arriving from Ethereum -
spy_events- createsEventSpyinstance which spies on events emitted by contracts -
spy_messages_to_l1- createsL1MessageSpyinstance which spies on messages to L1 sent by contracts -
store- stores values in targeted contact's storage -
load- loads values directly from targeted contact's storage -
set_balance- sets new balance of ERC20 token for target contract -
CheatSpan- enum for specifying the number of target calls for a cheat -
Token- enum for specifying ERC20 token for a cheat -
interact_with_state- allows interacting with a contract's state in tests
Execution Info
Caller Address
cheat_caller_address- changes the caller address for contracts, for a number of callsstart_cheat_caller_address_global- changes the caller address for all contractsstart_cheat_caller_address- changes the caller address for contractsstop_cheat_caller_address- cancels thecheat_caller_address/start_cheat_caller_addressfor contractsstop_cheat_caller_address_global- cancels thestart_cheat_caller_address_global
Block Info
Block Number
cheat_block_number- changes the block number for contracts, for a number of callsstart_cheat_block_number_global- changes the block number for all contractsstart_cheat_block_number- changes the block number for contractsstop_cheat_block_number- cancels thecheat_block_number/start_cheat_block_numberfor contractsstop_cheat_block_number_global- cancels thestart_cheat_block_number_global
Block Timestamp
cheat_block_timestamp- changes the block timestamp for contracts, for a number of callsstart_cheat_block_timestamp_global- changes the block timestamp for all contractsstart_cheat_block_timestamp- changes the block timestamp for contractsstop_cheat_block_timestamp- cancels thecheat_block_timestamp/start_cheat_block_timestampfor contractsstop_cheat_block_timestamp_global- cancels thestart_cheat_block_timestamp_global
Sequencer Address
cheat_sequencer_address- changes the sequencer address for contracts, for a number of callsstart_cheat_sequencer_address_global- changes the sequencer address for all contractsstart_cheat_sequencer_address- changes the sequencer address for contractsstop_cheat_sequencer_address- cancels thecheat_sequencer_address/start_cheat_sequencer_addressfor contractsstop_cheat_sequencer_address_global- cancels thestart_cheat_sequencer_address_global
Transaction Info
Transaction Version
cheat_transaction_version- changes the transaction version for contracts, for a number of callsstart_cheat_transaction_version_global- changes the transaction version for all contractsstart_cheat_transaction_version- changes the transaction version for contractsstop_cheat_transaction_version- cancels thecheat_transaction_version/start_cheat_transaction_versionfor contractsstop_cheat_transaction_version_global- cancels thestart_cheat_transaction_version_global
Transaction Max Fee
cheat_max_fee- changes the transaction max fee for contracts, for a number of callsstart_cheat_max_fee_global- changes the transaction max fee for all contractsstart_cheat_max_fee- changes the transaction max fee for contractsstop_cheat_max_fee- cancels thecheat_max_fee/start_cheat_max_feefor contractsstop_cheat_max_fee_global- cancels thestart_cheat_max_fee_global
Transaction Signature
cheat_signature- changes the transaction signature for contracts, for a number of callsstart_cheat_signature_global- changes the transaction signature for all contractsstart_cheat_signature- changes the transaction signature for contractsstop_cheat_signature- cancels thecheat_signature/start_cheat_signaturefor contractsstop_cheat_signature_global- cancels thestart_cheat_signature_global
Transaction Hash
cheat_transaction_hash- changes the transaction hash for contracts, for a number of callsstart_cheat_transaction_hash_global- changes the transaction hash for all contractsstart_cheat_transaction_hash- changes the transaction hash for contractsstop_cheat_transaction_hash- cancels thecheat_transaction_hash/start_cheat_transaction_hashfor contractsstop_cheat_transaction_hash_global- cancels thestart_cheat_transaction_hash_global
Transaction Chain ID
cheat_chain_id- changes the transaction chain_id for contracts, for a number of callsstart_cheat_chain_id_global- changes the transaction chain_id for all contractsstart_cheat_chain_id- changes the transaction chain_id for contractsstop_cheat_chain_id- cancels thecheat_chain_id/start_cheat_chain_idfor contractsstop_cheat_chain_id_global- cancels thestart_cheat_chain_id_global
Transaction Nonce
cheat_nonce- changes the transaction nonce for contracts, for a number of callsstart_cheat_nonce_global- changes the transaction nonce for all contractsstart_cheat_nonce- changes the transaction nonce for contractsstop_cheat_nonce- cancels thecheat_nonce/start_cheat_noncefor contractsstop_cheat_nonce_global- cancels thestart_cheat_nonce_global
Transaction Resource Bounds
cheat_resource_bounds- changes the transaction resource bounds for contracts, for a number of callsstart_cheat_resource_bounds_global- changes the transaction resource bounds for all contractsstart_cheat_resource_bounds- changes the transaction resource bounds for contractsstop_cheat_resource_bounds- cancels thecheat_resource_bounds/start_cheat_resource_boundsfor contractsstop_cheat_resource_bounds_global- cancels thestart_cheat_resource_bounds_global
Transaction Tip
cheat_tip- changes the transaction tip for contracts, for a number of callsstart_cheat_tip_global- changes the transaction tip for all contractsstart_cheat_tip- changes the transaction tip for contractsstop_cheat_tip- cancels thecheat_tip/start_cheat_tipfor contractsstop_cheat_tip_global- cancels thestart_cheat_tip_global
Transaction Paymaster Data
cheat_paymaster_data- changes the transaction paymaster data for contracts, for a number of callsstart_cheat_paymaster_data_global- changes the transaction paymaster data for all contractsstart_cheat_paymaster_data- changes the transaction paymaster data for contractsstop_cheat_paymaster_data- cancels thecheat_paymaster_data/start_cheat_paymaster_datafor contractsstop_cheat_paymaster_data_global- cancels thestart_cheat_paymaster_data_global
Transaction Nonce Data Availability Mode
cheat_nonce_data_availability_mode- changes the transaction nonce data availability mode for contracts, for a number of callsstart_cheat_nonce_data_availability_mode_global- changes the transaction nonce data availability mode for all contractsstart_cheat_nonce_data_availability_mode- changes the transaction nonce data availability mode for contractsstop_cheat_nonce_data_availability_mode- cancels thecheat_nonce_data_availability_mode/start_cheat_nonce_data_availability_modefor contractsstop_cheat_nonce_data_availability_mode_global- cancels thestart_cheat_nonce_data_availability_mode_global
Transaction Fee Data Availability Mode
cheat_fee_data_availability_mode- changes the transaction fee data availability mode for contracts, for a number of callsstart_cheat_fee_data_availability_mode_global- changes the transaction fee data availability mode for all contractsstart_cheat_fee_data_availability_mode- changes the transaction fee data availability mode for contractsstop_cheat_fee_data_availability_mode- cancels thecheat_fee_data_availability_mode/start_cheat_fee_data_availability_modefor contractsstop_cheat_fee_data_availability_mode_global- cancels thestart_cheat_fee_data_availability_mode_global
Transaction Account Deployment
cheat_account_deployment_data- changes the transaction account deployment data for contracts, for a number of callsstart_cheat_account_deployment_data_global- changes the transaction account deployment data for all contractsstart_cheat_account_deployment_data- changes the transaction account deployment data for contractsstop_cheat_account_deployment_data- cancels thecheat_account_deployment_data/start_cheat_account_deployment_datafor contractsstop_cheat_account_deployment_data_global- cancels thestart_cheat_account_deployment_data_global
Account Contract Address
cheat_account_contract_address- changes the address of an account which the transaction originates from, for the given target and spanstart_cheat_account_contract_address_global- changes the address of an account which the transaction originates from, for all targetsstart_cheat_account_contract_address- changes the address of an account which the transaction originates from, for the given targetstop_cheat_account_contract_address- cancels thecheat_account_deployment_data/start_cheat_account_deployment_datafor the given targetstop_cheat_account_contract_address_global- cancels thestart_cheat_account_contract_address_global
âšī¸ Info To use cheatcodes you need to add
snforge_stdpackage as a development dependency in yourScarb.tomlusing the appropriate version.[dev-dependencies] snforge_std = "0.51.2"