🤔 Got questions? Schedule an office hours session.
Forks
How to Specify/Change Network chain_id

How to Specify/Change Network chain_id

Migrate to Virtual TestNets

Virtual TestNets are publicly available!
For new projects, we recommend starting with TestNets.
For automatic migration of Forks to TestNets, .

We generally use chain_id as part of transaction signing. In most cases, it’s the same as the originating network. But what if you’d like to change it?

For instance, you can change the network ID to prevent a Fork environment from producing a signature valid on the actual network, stopping a transaction from replaying an attack:

example.tsx
...
 
const { TENDERLY_ACCOUNT_SLUG, TENDERLY_PROJECT_SLUG, TENDERLY_ACCESS_KEY } = process.env;
const TENDERLY_FORK_API = `https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/fork`
 
const body = {
  "network_id": "1", // network you wish to fork
  "block_number": 14386016,
  "chain_config": {
    "chain_id": 3 // chain_id used in the forked environment
  }
}
 
const resp = await axios.post(TENDERLY_FORK_API, body, opts);