Links

Simulate JSON RPC

Custom JSON RPC method available in Tenderly Web3 Gateway.
The custom RPC methods appear in the tenderly_ namespace.

tenderly_simulateTransaction

Simulates transaction as it would execute on the given block.
PARAMS
  1. 1.
    Transaction Transaction OBJECT
    • from (optional) STRING: hex encoded address
    • to STRING: hex encoded address
    • gas (optional) NUMBER
    • maxFeePerGas (optional) NUMBER max fee: The maximum total fee per gas the sender is willing to pay (includes the network / base fee and miner / priority fee) in wei
    • maxPriorityFeePerGas (optional) NUMBER max priority fee: Maximum fee per gas the sender is willing to pay to miners in wei
    • gasPrice (optional) NUMBER: The gas price willing to be paid by the sender in wei
    • value (optional) NUMBER
    • data (optional) STRING: hex encoded bytes
    • accessList (optional) ARRAY of Access list entry OBJECT
      • address STRING hex encoded address
      • storageKeys ARRAY of STRING representation of 32 byte hex encoded storage key
  2. 2.
    Simulation Block Number (optional) The block number against which transaction should be simulated. Either:
    • STRING Block number
    • ENUM of Block tag earliest|finalized|safe|latest|pending
  3. 3.
    Overrides (optional) MAP: mapping from an account (address) to override specification
    • key STRING: the account this override applies to
    • value OBJECT: the override specification
      • nonce (optional) STRING: hex encoded 8 byte nonce override for the account
      • code (optional) STRING: data of the code override for the account
      • balance (optional) STRING: hex encoded 32 byte balance override for the account in wei
      • stateDiff (optional) MAP: mapping of storage key to storage value override
        • key STRING: the storage key
        • value STRING: the value override for the given storage key
Raw
cURL
ethers
Response
{
"id": 0,
"jsonrpc": "2.0",
"method": "tenderly_simulateTransaction",
"params": [
{
"from": "0xDC6bDc37B2714eE601734cf55A05625C9e512461",
"to": "0xff39a3e734fe363e631441f6d24c7539240c2628",
"value": "0x0",
"data": "0x2e7700f0"
},
"0xF4D880",
null
]
}
curl https://mainnet.gateway.tenderly.co/$TENDERLY_WEB3_GATEWAY_KEY \
-X POST \
-H "Content-Type: application/json" \
-d \
'{
"id": 0,
"jsonrpc": "2.0",
"method": "tenderly_simulateTransaction",
"params": [
{
"from": "0xDC6bDc37B2714eE601734cf55A05625C9e512461",
"to": "0xff39a3e734fe363e631441f6d24c7539240c2628",
"value": "0x0",
"data": "0x2e7700f0"
},
"0xF4D880",
null
]
}'
// Installation Instructions: https://docs.ethers.io/v5/getting-started/#installing
const { ethers } = require("ethers");
async function runSimulateTransaction() {
// Initialize an ethers instance
const provider = new ethers.providers.JsonRpcProvider(
"https://goerli.gateway.tenderly.co/$TENDERLY_WEB3_GATEWAY_KEY"
);
// Execute method
const result = await provider.send("tenderly_simulateTransaction", [
{
from: "0xDC6bDc37B2714eE601734cf55A05625C9e512461",
to: "0xff39a3e734fe363e631441f6d24c7539240c2628",
value: "0x0",
data: "0x2e7700f0",
},
"0xF4D880",
]);
// Print the output to console
console.log(result);
}
(async () => {
runSimulateTransaction();
})();
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"status": true,
"gasUsed": "0x523c",
"cumulativeGasUsed": "0x0",
"blockNumber": "0xf4d881",
"type": "0x0",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"logs": null,
"trace": [
{
"type": "CALL",
"from": "0xdc6bdc37b2714ee601734cf55a05625c9e512461",
"to": "0xff39a3e734fe363e631441f6d24c7539240c2628",
"gas": "0x5f58ec4",
"gasUsed": "0x0",
"value": "0x0",
"input": "0x2e7700f0",
"decodedInput": null,
"method": null,
"output": "0x",
"decodedOutput": null,
"subtraces": 0,
"traceAddress": [0]
}
]
}
}
RESULT: Simulation result OBJECT
  • status NUMBER: either 1 (success) or 0 (failure)
  • gasUsed NUMBER: The amount of gas used by this specific transaction alone
  • cumulativeGasUsed NUMBER: the total amount of gas used when this transaction was executed in the block
  • blockNumber NUMBER: the block number in which this transaction was simulated
  • type NUMBER: transaction type, 0x00 for legacy transactions, 0x01 for access list types, 0x02 for dynamic fees
  • logsBloom STRING: bloom filter for light clients to quickly retrieve related logs
  • logs: an array of emitted events ARRAY of OBJECT
    • name STRING: event name
    • anonymous BOOLEAN: indicates if event is anonymous
    • inputs: array of decoded log arguments ARRAY of decoded logs OBJECT
      • name STRING: event argument name
      • type STRING: event argument type from Solidity type system
      • value (optional) STRING string representation value of the argument; interpret according to the type field
    • raw OBJECT: raw logs
      • address STRING hex encoded address: address of the contract emitting the log
      • topics ARRAY of STRING 32 hex encoded bytes
      • data STRING hex encoded string representing event data
  • trace: Trace ARRAY of OBJECT
    • type STRING type: trace item type - either CALL| CALLCODE| STATICCALL| DELEGATECALL| CREATE| CREATE2| SELFDESTRUCT
    • from STRING: hex encoded address
    • to STRING: hex encoded address
    • gas STRING: hex encoded unsigned 64 byte integer representing event gas
    • gasUsed STRING: hex encoded unsigned 64 byte integer representing event gasUsed
    • value STRING: hex encoded unsigned 64 byte integer representing event value in wei
    • error STRING: low-level error from virtual machine
    • errorReason STRING: extracted error reason in case of revert
    • input STRING: hex encoded string representation of raw input bytes for the trace point
    • method STRING: invoked contract method
    • decodedInput : decoded input for the invoked method - ARRAY of decoded in argument OBJECT
      • value STRING: string representation value of the argument; interpret according to the type field.
      • type STRING: the Solidity type of this argument
      • name STRING: the name of this argument
    • output STRING: raw trace output
    • decodedOutput : decoded output of the invoked method - ARRAY of decoded out argument OBJECT
      • value STRING: string representation value of the argument; interpret according to the type field.
      • type STRING: the Solidity type of this argument
      • name STRING: the name of this argument
    • subtraces NUMBER: number of child traces
    • traceAddress : trace position ARRAY of NUMBER