How to Specify/Change Network chain_id
Forks will be deprecated on March 31, 2025.
Please migrate to Tenderly Virtual TestNets or contact our support for assistance with automatic migration.
New projects on Tenderly should use Virtual TestNets.
New projects on Tenderly should use Virtual 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);