Debug JSON-RPC API
Methods useful for debugging purposes with ZKsync Era.
debug_traceBlockByHash
Traces all calls made from a specific block by its L2 hash.
Parameters
- DATA, 32 bytes - hash defining the L2 block.
- TracerConfig - Optional configuration for tracing. Refer to the TraceConfig documentation for more details.
Returns
Array of objects, each representing a traced call made from the specified block.
Example Request
curl --request POST \
--url https://mainnet.era.zksync.io/ \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 1,
"method": "debug_traceBlockByHash",
"params": ["0x4bd0bd4547d8f8a4fc86a024e54558e156c1acf43d82e24733c6dac2fe5c5fc7"]
}'
Example Response
{
"jsonrpc": "2.0",
"result": [
{
"type": "Call",
"from": "0x0000000000000000000000000000000000000000",
"to": "0x0000000000000000000000000000000000008001",
"gas": "0x18be25",
"gasUsed": "0x7603b",
"value": "0xa1e94fc0fe6043",
"output": "0x",
"input": "0x",
"error": null,
"revertReason": null,
"calls": [...]
},
...
]
}
debug_traceBlockByNumber
Traces all calls made from a specific block by its L2 block number.
Parameters
- QUANTITY, 8 bytes | TAG - The number of the block to trace. This can be a hex-encoded number or one of the strings "earliest", "latest", or "pending".
- TracerConfig - Optional configuration for tracing. Refer to the TraceConfig documentation for more details.
Returns
Array of objects, each representing a traced call made from the specified block.
Example Request
curl --request POST \
--url https://mainnet.era.zksync.io/ \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 1,
"method": "debug_traceBlockByNumber",
"params": ["0x24b258"]
}'
Example Response
{
"jsonrpc": "2.0",
"result": [
{
"result": {
"type": "Call",
"from": "0x0000000000000000000000000000000000000000",
"to": "0x0000000000000000000000000000000000008001",
"gas": "0x18be25",
"gasUsed": "0x7603b",
"value": "0xa1e94fc0fe6043",
"output": "0x",
"input": "0x",
"error": null,
"revertReason": null,
"calls": [...]
},
...
]
}
debug_traceCall
Traces a call made at a specific block, by block number or hash.
Parameters
- CallRequest - The call request to trace, containing fields like
from
,to
,data
, and optionallygas
,gasPrice
, andvalue
. - DATA, 32 bytes | QUANTITY, 8 bytes - Optional. The block identifier, which can be a block number as a hex-encoded number or a block hash. If not specified, the latest block is used.
- TracerConfig - Optional. Configuration options for the trace. For more details, refer to the TraceConfig documentation.
Returns
Array of objects, each representing a traced call made from the specified block.
Example Request
curl --request POST \
--url https://mainnet.era.zksync.io/ \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 1,
"method": "debug_traceCall",
"params": [
{
"from": "0x1111111111111111111111111111111111111111",
"to": "0x2222222222222222222222222222222222222222",
"data": "0xffffffff"
},
"0x24b258"
]
}'
Example Response
{
"jsonrpc": "2.0",
"result": {
"type": "Call",
"from": "0x0000000000000000000000000000000000000000",
"to": "0x0000000000000000000000000000000000008001",
"gas": "0x0",
"gasUsed": "0x6b4b",
"value": "0x0",
"output": "0x",
"input": "0xffffffff",
"error": null,
"revertReason": null,
"calls": []
},
"id": 1
}
debug_traceTransaction
Uses the EVM's callTracer
to return a debug trace of a specific transaction given by its transaction hash.
Parameters
- DATA, 32 bytes - The 32-byte hash of the transaction to trace.
- TracerConfig - Optional. Configuration options for the trace. For more details, refer to the TraceConfig documentation.
Returns
Array of objects, each representing a traced call made from the specified block.
Example Request
curl --request POST \
--url https://mainnet.era.zksync.io/ \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 1,
"method": "debug_traceTransaction",
"params": ["0x4b228f90e796de5a18227072745b0f28e0c4a4661a339f70d3bdde591d3b7f3a"]
}'
Example Response
{
"jsonrpc": "2.0",
"result": [
{
"type": "Call",
"from": "0x0000000000000000000000000000000000000000",
"to": "0x0000000000000000000000000000000000008001",
"gas": "0x154800",
"gasUsed": "0xc2419",
"value": "0x0",
"output": "0x",
"input": "0x095ea7b30000000000000000000000002da10a1e27bf85cedd8ffb1abbe97e53391c0295ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"error": null,
"revertReason": null,
"calls": [...]
},
...
]
}