Debug JSON-RPC API

Methods useful for debugging purposes with ZKsync Chains.

debug_getRawTransaction

Returns the raw, RLP-encoded data of a single transaction, given its transaction hash.

Parameters

  1. DATA, 32 bytes - The 32-byte hash of the transaction to trace.
  2. TracerConfig - Optional. Configuration options for the trace. For more details, refer to the TraceConfig documentation.

Returns

  1. DATA - Full serialized transaction exactly as it was submitted to the network. The format matches Ethereum’s standard raw transaction encoding.

Example Request

curl --request POST \
  --url https://mainnet.era.zksync.io/ \
  --header 'Content-Type: application/json' \
  --data '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "debug_getRawTransaction",
      "params": ["0x4bd0bd4547d8f8a4fc86a024e54558e156c1acf43d82e24733c6dac2fe5c5fc7"]
    }'

Example Response

{
  "jsonrpc": "2.0",
  "result": ["0xf8678084342770c182520894658bdf435d810c91414ec09147daa6db624063798203e880820a95a0af5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60a0201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b]
}

debug_getRawTransactions

Returns a list of raw, RLP-encoded transactions for a specific block.

Parameters

  1. 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".
  2. TracerConfig - Optional configuration for tracing. Refer to the TraceConfig documentation for more details.

Returns

  1. DATA - Array of full serialized transaction exactly as it was submitted to the network. The format matches Ethereum’s standard raw transaction encoding.

Example Request

curl --request POST \
  --url https://mainnet.era.zksync.io/ \
  --header 'Content-Type: application/json' \
  --data '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "debug_getRawTransactions",
      "params": ["0x1d1551e"]
    }'

Example Response

{
  "jsonrpc": "2.0",
  "result": [
  "0xf8678084342770c182520894658bdf435d810c91414ec09147daa6db624063798203e880820a95a0af5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60a0201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b",
  "0xf86b0185030d40f680825208943535353535353535353535353535353535353535880de0b6b3a76400008025a071c349c30c1b8ed17c2c6b85b2b2a5fd888de0b7c3c6d678e912fcd894bc0e4ca07d893d0cc7899ac76549e18006e2beef6ccbc6d10a6c4a9173aa9cbbf137d61d",
  "0xf86c028477359400825208949876543210abcdef1234567890abcdef123456789088015f90c9b3af00008026a0a392e91d9a0b21fd1582d96b11aa80cf9874d2e41798e169f7cf13c5152a8f75a037ee9f64f73e617011e44f61f601b6ed553b68d80c10b5a1d1e24879a2c6db5b"
  ]
}

debug_traceBlockByHash

Traces all calls made from a specific block by its L2 hash.

Parameters

  1. DATA, 32 bytes - hash defining the L2 block.
  2. 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.

Trace Object

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

  1. 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".
  2. 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.

Trace Object

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

  1. CallRequest - The call request to trace, containing fields like from, to, data, and optionally gas, gasPrice, and value.
  2. 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.
  3. 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.

Trace Object

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

  1. DATA, 32 bytes - The 32-byte hash of the transaction to trace.
  2. 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.

Trace Object

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": [...]
    },
    ...
  ]
}

Made with ❤️ by the ZKsync Community