The debug_traceBlock method is part of the Ethereum JSON RPC Core API, designed for advanced debugging.
Returns full trace of all invoked opcodes of all transactions includedin the block.
The debug_traceBlock method is part of the Ethereum JSON RPC Core API and is designed for advanced debugging purposes. This method provides a full trace of all invoked opcodes of all transactions included in the specified block. It is particularly useful for developers analyzing the low-level execution of Ethereum transactions within a block.
Supported Networks
The debug_traceBlock RPC Ethereum method supports all Ethereum network types, including:
Mainnet
Testnets: Sepolia, Holesky
Parameters
The debug_traceBlock method accepts the following parameters:
Block: (data) The RLP-encoded representation of the block to be traced.
Object: (None) Request options. These are optional and default to false.
wscat -c wss://eth.getblock.io/YOUR-API-KEY/ # wait for connection and send the request body {"jsonrpc":"2.0","method":"debug_traceBlock","params": ["0xf90213a01e77d8f1267348b516ebc4f4da1e2aa59f85f0cbd853949500ffac8bfc38ba14a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942a65aca4d5fc5b5c859090a6c34d164135398226a00b5e4386680f43c224c5c037efc0b645c8e1c3f6b30da0eec07272b4e6f8cd89a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086057a418a7c3e83061a80832fefd880845622efdc96d583010202844765746885676f312e35856c696e7578a03fbea7af642a4e20cd93a945a1f5e23bd72fc5261153e09102cf718980aeff38886af23caae95692ef", null],
"id":"getblock.io"}
Response Example
The server responds with a JSON object. Below is an example response for the debug_traceBlock method:
{"result":"null","id":"getblock.io","status_code":405,"message":"Method not allowed"}
Response Description
result: null if the method is not allowed or unavailable.
status_code: The HTTP status code for the request.
message: A descriptive message explaining the response, e.g., "Method not allowed."
Returns
If successful, the method provides a detailed trace of all transactions in the block, including the following information:
block: The block details, including its hash and transactions.
transaction: A detailed trace of each transaction in the block.
parameters: Opcode-level execution details and associated data.
value: The values used or modified during the transaction execution.
Use Case
The debug_traceBlock method is valuable for developers who need to debug Ethereum transactions at the opcode level. This includes analyzing gas consumption, investigating failed transactions, and diagnosing issues in smart contract execution. If a debug_traceBlock error occurs, ensure the provided Block data is correct and that your node supports this method. The provided debug_traceBlock example demonstrates how to construct a proper request.
Example Code
Here is an example of how to call the debug_traceBlock method programmatically using Python:
import requestsimport json# Define the API URL and access tokenurl ='https://go.getblock.io/<ACCESS-TOKEN>/'headers ={'Content-Type':'application/json'}# Prepare the request datadata ={"jsonrpc":"2.0","method":"debug_traceBlock","params": [ "0xf90213a01e77d8f1267348b516ebc4f4da1e2aa59f85f0cbd853949500ffac8bfc38ba14a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347942a65aca4d5fc5b5c859090a6c34d164135398226a00b5e4386680f43c224c5c037efc0b645c8e1c3f6b30da0eec07272b4e6f8cd89a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086057a418a7c3e83061a80832fefd880845622efdc96d583010202844765746885676f312e35856c696e7578a03fbea7af642a4e20cd93a945a1f5e23bd72fc5261153e09102cf718980aeff38886af23caae95692ef",
null ],"id":"getblock.io"}# Send the POST requestresponse = requests.post(url, headers=headers, data=json.dumps(data))# Parse the JSON responseresponse_data = response.json()# Print the resultprint(json.dumps(response_data, indent=4))
This Python script demonstrates how to interact with the debug_traceBlock method programmatically. Replace <ACCESS-TOKEN> with your actual API key. The Web3 debug_traceBlock method can also be used through Web3 libraries for Ethereum.