Skip to main content
Reverting state can be helpful when testing contracts and protocols and you want to discard all state changes up to the snapshot position.
Instead of reverting state, consider forking an existing Virtual Environment instead, and do your testing on a disposable working copy.

Reverting to a snapshot

1
Create snapshot
2
Use evm_snapshot to create a snapshot on the current block. The method returns the snapshot ID you can use to revert.
3
TENDERLY_VIRTUAL_TESTNET_RPC= #...

SNAPSHOT_ID=$(curl $TENDERLY_VIRTUAL_TESTNET_RPC \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{
      "jsonrpc": "2.0",
      "method": "evm_snapshot",
      "id": "1234"
    }' \
    | jq -r  '.result')
4
Revert
5
Use evm_revert to back revert to previously created snapshot (SNAPSHOT_ID). From this point onwards, all prior changes up to the snapshot will be discarded.
6
read -r -d '' REVERT_REQUEST <<EOF
{
  "jsonrpc": "2.0",
  "method": "evm_revert",
  "params": ["$SNAPSHOT_ID"],
  "id": "1234"
}
EOF

curl $TENDERLY_VIRTUAL_TESTNET_RPC \
    -H "Content-Type: application/json" \
    -d $REVERT_REQUEST