Skip to Content

Mainnet Follow

You can keep selected state on your Stagenet synced to the live chain it replays.

Normally, state modified on your Stagenet is preserved: once a transaction changes an account, balance, contract, or storage slot, that state stops syncing from the replayed chain.

Followed state is different. If you follow an account, token balance, or storage slot, it continues reading from the live chain even after Stagenet transactions touch it. Any writes made to followed state during a Stagenet transaction are used for that transaction, then discarded when the block ends.

When to follow mainnet state

For your own contracts and wallets, persistence is what you want — deployments, funding, and test transactions should stick.

For third-party market state, persistence causes drift:

  • A swap through a Uniswap pool changes the pool price on your Stagenet. On the live chain, arbitrage moves the pool back in line; on your Stagenet it stays moved.
  • Aggregators and pricing APIs quote against live chain state while your Stagenet executes against modified pool state. If the gap grows, swaps that work on the live chain start reverting on your Stagenet.

Following removes this drift:

  • Modified state — preserved on the Stagenet
  • Followed state — kept synced to the live chain

How following works

At the start of each block, the first read of followed state returns the live value from the replayed chain — any previously modified Stagenet value is ignored.

Writes still behave normally inside the block: if a transaction writes to followed state, later reads in the same transaction and block see that value. At the end of the block, those writes are discarded instead of persisted.

Think of it per block: inside a block, a followed slot behaves like normal chain state. Between blocks, it snaps back to its mainnet value.

How to follow mainnet state

Use the CLI:

# Follow an account: every slot, account field, and code contract.dev follow 0xc9034c3E7F58003E6ae0C8438e7c8f4598d5ACAA # Follow an account's ERC20 balance contract.dev follow 0xToken --balance-of 0xHolder # Follow specific slots (decimal slot numbers or 32-byte keys) contract.dev follow 0xMyContract --slots 0,1,4 # Stop following (mirrors the follow flags) contract.dev unfollow 0xc9034c3E7F58003E6ae0C8438e7c8f4598d5ACAA

Follow whole accounts only for contracts holding pure market state (pools, settlement contracts, oracles). For shared contracts like tokens — where storage holds other users’ balances too — follow specific state with --balance-of or --slots.

Last updated on