trace_replayBlockTransactionsvmTrace - Optimism

trace_replayBlockTransactionsvmTrace. replays all transactions in a specified block and returns detailed trace information

trace_replayBlockTransactions#vmTrace - optimism [Value: 300CU]
Replays all transactions in a specified block and provides detailed trace information for each transaction, includes an in-depth trace of the virtual machine's state throughout the execution of each transaction, capturing every opcode executed and the resulting state changes
Use cases

Use cases

  • Analyze EVM execution for a block of transactions
  • Debug contract interactions within an entire block
  • Inspect gas usage and execution paths in block
Constraints

Constraints

  • High computational resources for detailed VM tracing
  • Requires access to a fully synchronized node
  • Large response size for blocks with many transactions
Get started
Unlock Access to 50+ chains
Boost your app's speed and reliability with dRPC - get your access API key

Language

Request
Examples
curl https://optimism.drpc.org \
-X POST \
-H "Content-Type: application/json" \
-d '{"method":"trace_replayBlockTransactions","params":["0x2ed119",["trace"]],"id":1,"jsonrpc":"2.0"}'

Copy
Response
200
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "output": "0x",
      "stateDiff": null,
      "trace": [
        {
          "action": {
            "callType": "call",
            "from": "0x5cb2045c43d14a5f5e5f1ea60c5b02e0a93032cf",
            "gas": "0x76c0",
            "input": "0x",
            "to": "0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e",
            "value": "0x186a0"
          },
          "blockHash": "0x5bad55fbd7e0f20eac95f45f55f997216de10aaf176314c236b0c3c93c5d1f17",
          "blockNumber": 1234567,
          "result": {
            "gasUsed": "0x5208",
            "output": "0x"
          },
          "subtraces": 0,
          "traceAddress": [],
          "transactionHash": "0x02d4a872e096445e80d05276ee756cefef7f3b376bcec14246469c0cd97dad8f",
          "transactionPosition": 0,
          "type": "call"
        }
        // Additional trace objects can be included here
      ],
      "vmTrace": {
        "code": "0x...",
        "ops": [
          {
            "cost": 3,
            "ex": {
              "mem": null,
              "push": ["0x60"],
              "store": null,
              "used": 3
            },
            "pc": 0,
            "sub": null
          }
        ]
      }
    }
  ]
}
Copy

Request params

idinteger
jsonrpcstring
methodstring
Parametersarray
array
toBlockstring
The block number or block hash to search up to
  • latest [default] - the blockchain's most recent block
  • safe - a block validated by the beacon chain
  • finalized - a block confirmed by over two-thirds of validators
  • earliest - the first or genesis block
  • pending - transactions broadcasted but not yet included in a block
traceTypestring
vmTrace
vmTracestring
To get a full trace of the virtual machine's state during the execution of the given of given transaction, including for any subcalls.

Response

200
An array of trace objects for each transaction, including vmTrace data that details the virtual machine's state during the transaction execution

Response params

object
idinteger
jsonrpcstring
resultobject
object
actionobject
Contains details about the trace action.
object
callTypestring
The type of call.
fromstring
The sender's address.
tostring
The receiver's address.
valuestring
The value transferred in wei.
gasstring
The gas provided for the call.
inputstring
The data sent with the call.
blockHashstring
The hash of the block where the trace occurred.
blockNumberstring
The number of the block where the trace occurred.
resultstring
object
gasUsedstring
Gas used by the trace.
outputstring
Call output.
subtracesinteger
Number of subtraces created by this trace..
traceAddressarray_of_strings
Position of this trace in the call stack.
transactionHashstring
Hash of the transaction containing this trace.
transactionPositionstring
Transaction's position in the block.
typestring
The type of trace.
vmTracestring
The virtual machine trace.
object
codestring
The EVM code executed.
opsarray
An array of operation objects representing the steps executed by the EVM.
object
costnumber
The gas cost of the operation.
exobject
object
memobject
The memory state.
pusharray
The items pushed onto the stack.
storeobject
The storage state.
usednumber
The gas used up to this point.
pcnumber
The program counter.
subobject
Sub-trace if the operation calls another contract.