Cheatcodes Reference

  • CheatTarget - enum for selecting contracts to target with cheatcodes
  • CheatSpan - enum for specifying the number of target calls for a cheat
  • prank - changes the caller address for contracts, for a number of calls
  • start_prank - changes the caller address for contracts
  • stop_prank - cancels the prank / start_prank for contracts
  • roll - changes the block number for contracts, for a number of calls
  • start_roll - changes the block number for contracts
  • stop_roll - cancels the roll / start_roll for contracts
  • warp - changes the block timestamp for contracts, for a number of calls
  • start_warp - changes the block timestamp for contracts
  • stop_warp - cancels the warp / start_warp for contracts
  • elect - changes the sequencer address for contracts, for a number of calls
  • start_elect - changes the sequencer address for contracts
  • stop_elect - cancels the elect / start_elect for contracts
  • spoof - changes the transaction context for contracts, for a number of calls
  • start_spoof - changes the transaction context for contracts
  • stop_spoof - cancels the spoof / start_spoof for contracts
  • 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 the mock_call / start_mock_call for an entry point
  • get_class_hash - retrieves a class hash of a contract
  • replace_bytecode - replace the class hash of a contract
  • l1_handler_execute - executes a #[l1_handler] function to mock a message arriving from Ethereum
  • spy_events - creates EventSpy instance which spies on events emitted by contracts
  • store - stores values in targeted contact's storage
  • load - loads values directly from targeted contact's storage

ℹ️ Info To use cheatcodes you need to add snforge_std package as a development dependency in your Scarb.toml using appropriate release tag.

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.12.0" }