Skip to content

Simulation

The sim module lets you test scripts on a forked chain without spending gas or affecting real state.

load sim
sim:fork (
# Everything inside runs on a simulated fork
sim:set-balance @me 100e18
exec @token(DAI) "transfer(address,uint256)" 0x4F2083f5fBede34C2714aFfb3105539775f7FE64 @token.amount(DAI 50)
)

EVMcrispr supports multiple simulation backends:

Backend Flag Notes
EthereumJS (default) Runs in-browser, no external node needed
Anvil --using anvil Fastest, needs anvil running locally
Hardhat --using hardhat Needs Hardhat node running locally
Tenderly --using tenderly Cloud-based, needs --auth-token
load sim
# Use Anvil
sim:fork --using anvil (
sim:set-balance @me 100e18
)
# Use Tenderly
sim:fork --using tenderly --auth-token "your-token" (
sim:set-balance @me 100e18
)
load sim
sim:fork --block-number 18000000 (
print @get(@token(DAI) "totalSupply()(uint256)")
)

Use --from to simulate as a specific address:

load sim
# A well-stocked account whose balance we borrow for the simulation
set $whale 0x40ec5B33f54e0E8A33A975908C5BA1c14e5BbbDf
sim:fork --from $whale (
exec @token(DAI) "transfer(address,uint256)" @me @token.amount(DAI 1000)
)
load sim
sim:fork (
sim:set-balance @me 100e18
sim:set-balance 0x4F2083f5fBede34C2714aFfb3105539775f7FE64 50e18
)
load sim
sim:fork (
sim:set-code 0x44fA8E6f47987339850636F88629646662444217 0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe
)
load sim
sim:fork (
sim:set-storage-at 0x44fA8E6f47987339850636F88629646662444217 0x00 0x01
)

Use expect to verify conditions during simulation:

load sim
sim:fork (
sim:set-balance @me 100e18
# Assert balance was set
sim:expect @bool(@get(@token(DAI) "balanceOf(address)(uint256)" @me) >= 0)
# Assert equality
set $a 42
sim:expect @bool($a == 42)
# Assert inequality
sim:expect @bool(1 != 2)
)

If an assertion fails, the script halts with an error.

Use the standard wait command to move forward in time (useful for timelocks, vesting, etc.). Inside a fork the wait is instant — the chain’s clock is warped instead of sleeping:

load sim
sim:fork (
# Advance 1 day (86400 seconds)
wait 86400
)
load aragonos
load sim
sim:fork (
aragonos:connect my-dao.aragonid.eth (
# Test a governance action
grant @me @app(voting) CREATE_VOTES_ROLE
install $agent agent:new-app
)
)