Analysing On-chain Scenarios
Scenarios let you create an isolated environment forked from a live blockchain. You can execute transactions, track on-chain data, and inspect how that data changes over the course of the transaction sequence in analytics dashboards.
This is useful for in-depth analysis of on-chain activity. For example:
-
Analyse smart contract exploits
Reproduce an exploit in an isolated environment and track how balances, prices, or protocol state change at each step. -
Test complex DeFi interactions
Run multi-step flows like swaps, deposits, borrows, and liquidations against realistic chain state, then observe how key values evolve. -
Debug multi-transaction behaviour
Inspect how contract state, balances, and function outputs change over a sequence of transactions, not just a single call.
How scenarios work
Scenario analysis follows a simple workflow:
- Fork a chain into an isolated environment
- Populate the scenario by sending transactions to its RPC
- Add tracked data you want to record during the scenario, such as balances or function return values
- Rerun the scenario to replay the transaction sequence
- Analyse how tracked values changed during the sequence
1. Create a scenario
First, create a scenario on the scenarios page, accessible via the sidebar. Every scenario starts by forking a live chain at a block number of your choice.
Each scenario fork has its own RPC endpoint. Think of it like Foundry’s Anvil or Hardhat’s local network, with built in analytics and replayability.
2. Set up scenario transactions
To define your scenario’s transaction flow, send transactions to its RPC URL, for example from a Hardhat or Foundry script.
This makes it easy to build a repeatable transaction sequence involving the contracts and wallets you care about. You can then start tracking their data and replay the full flow later with a single click.
3. Add tracked data
Tracked data is the core of scenario analysis. It lets you observe how key values change as your scenario transactions execute.
You can track:
- native token balances
- ERC-20 balances
- return values of
vieworpurefunctions
4. Rerun the scenario
Rerunning lets you record your newly added tracked data across the full transaction sequence.
When you click Rerun:
- the chain state is reset to the original fork snapshot
- the recorded transaction sequence is replayed from the beginning
- tracked items are recorded again as each step executes
5. Analyse the results
You can view how each tracked value changes during the scenario using graphs in the scenario’s Analysis view. You can also inspect the impact of individual transactions, including token transfers, call traces, and state diffs.
Typical workflow
For example, if you were analysing an attack on a WETH vault, you would:
- fork the chain containing the vault
- run a script that performs the attack
- start tracking the vault’s WETH balance and the attacker’s WETH balance
- rerun the scenario to record the tracked data
- analyse how those values change across the transaction sequence