Forks will be deprecated on March 31, 2025. Please migrate to Tenderly Virtual TestNets or contact our support for assistance with automatic migration.
Forks
How to Impersonate any Address as a Simulation Sender

How to Impersonate any Address as a Simulation Sender

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.

In some scenarios, you may want to simulate transaction execution as if it was sent from an arbitrary address. When a transaction is simulated via API, Tenderly doesn’t deal with signatures, so you can set any from value. You can even simulate sending transactions from another contract.

To achieve this, just send a transaction with any from address:

example.tsx
...
dotenv.config();
const { TENDERLY_ACCOUNT_SLUG, TENDERLY_PROJECT_SLUG, TENDERLY_ACCESS_KEY } = process.env;
 
const SIMULATE_API = `https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/simulate`
 
const DAI_ADDRESS = "0x6b175474e89094c44da98b954eedeac495271d0f";
 
// tx data obtained using other means
const TX_DATA = await contract.populateTransaction[funcName](...args);
 
const transaction = {
    network_id: '1',
    from: "0x0000000000000000000000000000000000000000",
    input: TX_DATA,
    to: DAI_ADDRESS,
    block_number: null,
    // tenderly specific
    save: true
}
 
const opts = {
    headers: {
        'X-Access-Key': TENDERLY_ACCESS_KEY || "",
    }
}
const resp = await axios.post(SIMULATE_API, transaction, opts);
console.log(resp.data);