DEBUG Methods

The DEBUG API methods allow you to inspect and debug the network. The DEBUG API is a more verbose alternative to the TRACE API, and its main purpose is compatibility with tools such as Remix. Where these APIs overlap, we recommend using the TRACE API for production use over the DEBUG API. Specifically, we recommend trace_block over debug_traceBlock, and trace_transaction over debug_traceTransaction.

The DEBUG API methods are not enabled by default for JSON-RPC. To enable the DEBUG API methods, use the --rpc-http-api or --rpc-ws-api options.

debug_accountAt

This example uses an externally owned account address for the address parameter.

  • code: data - code for the account. Displays 0x0 if the address is an externally owned account.

  • nonce: quantity - number of transactions made by the account before this one

  • balance: quantity - balance of the account in wei

  • codehash: data - code hash for the account

result: object - account details object with the following fields:

Returns

  • blockHashOrNumber: string - block hash or number at which to retrieve account information

  • txIndex: number - transaction index at which to retrieve account information

  • address: string - contract or account address for which to retrieve information

Parameters

Returns account information at the specified index of the specified block.

curl -X POST --data '{"jsonrpc":"2.0","method":"debug_accountAt","params":["0xc8df1f061abb4d0c107b2b1a794ade8780b3120e681f723fe55a7be586d95ba6", 0, "0xbcde5374fce5edbc8e2a8697c15331677e6ebf0b"],"id":1}' http://127.0.0.1:8545

This example uses a contract address for the address parameter.

curl -X POST --data '{"jsonrpc":"2.0","method":"debug_accountAt","params":["0x2b76b3a2fc44c0e21ea183d06c846353279a7acf12abcc6fb9d5e8fb14ae2f8c", 0, "0x0e0d2c8f7794e82164f11798276a188147fbd415"],"id":1}' http://127.0.0.1:8545

debug_accountRange

Retesteth uses debug_accountRange to implement debugging.

Returns the accounts for a specified block.

Parameters

  • blockHashOrNumber: string - block hash or number at which to retrieve account information

  • txIndex: number - transaction index at which to retrieve account information

  • address: string - address hash from which to start

  • limit: integer - maximum number of account entries to return

Returns

result: object - account details object with the following fields:

  • addressMap: map of strings to strings - map of address hashes and account addresses

  • nextKey: string - hash of the next address if any addresses remain in the state, otherwise zero

curl -X POST --data '{"jsonrpc":"2.0","method":"debug_accountRange","params":["12345", 0, "0", 5],"id":1}' http://127.0.0.1:8545

debug_batchSendRawTransaction

Sends a list of signed transactions. This is used to quickly load a network with a lot of transactions. This does the same thing as calling eth_sendRawTransaction multiple times.

Parameters

data: string - signed transaction data array

Returns

result: array of objects - object returned for each transaction, with the following fields:

  • index: string - index of the transaction in the request parameters array

  • success: boolean - indicates whether or not the transaction has been added to the transaction pool

  • errorMessage: string - (optional) error message

  • curl HTTP

  • wscat WS

  • JSON result

curl -X POST --data '{"jsonrpc":"2.0","method":"debug_batchSendRawTransaction","params":["0xf868808203e882520894627306090abab3a6e1400e9345bc60c78a8bef57872386f26fc10000801ba0ac74ecfa0e9b85785f042c143ead4780931234cc9a032fce99fab1f45e0d90faa02fd17e8eb433d4ca47727653232045d4f81322619c0852d3fe8ddcfcedb66a43","0x416","0xf868018203e882520894627306090abab3a6e1400e9345bc60c78a8bef57872386f26fc10000801ca0b24ea1bee8fe36984c36acbf80979a4509f23fc17141851e08d505c0df158aa0a00472a05903d4cd7a811bd4d5c59cc105d93f5943f3393f253e92e65fc36e7ce0","0xf868808203e882520894627306090abab3a6e1400e9345bc60c78a8bef5787470de4df820000801ca0f7936b4de04792e3c65095cfbfd1399d231368f5f05f877588c0c8509f6c98c9a01834004dead527c8da1396eede42e1c60e41f38a77c2fd13a6e495479c729b99"],"id":1}' http://127.0.0.1:8545

debug_getBadBlocks

Returns a list of invalid blocks. This is used to detect and analyze consensus flaws.

Parameters

None

Returns

result: array of objects - list of block objects

curl -X POST --data '{"jsonrpc":"2.0","method":"debug_getBadBlocks","params":[],"id":1}' http://127.0.0.1:8545

debug_getRawBlock

Returns the RLP encoding of the specified block.

Parameters

blockNumber: string - hexadecimal or decimal integer representing a block number, or one of the string tags latest, earliest, pending, finalized, or safe, as described in block parameter

NOTE

pending returns the same value as latest.

Returns

result: object - RLP-encoded block object

curl -X POST --data '{"jsonrpc":"2.0","method":"debug_getRawBlock","params":["0x32026E"],"id":1}' http://127.0.0.1:8545

debug_getRawHeader

Parameters

blockNumber: string - hexadecimal or decimal integer representing a block number, or one of the string tags latest, earliest, pending, finalized, or safe, as described in block parameter

NOTE:

pending returns the same value as latest.

Returns

result: object - array of RLP-encoded transaction receipts

curl -X POST --data '{"jsonrpc":"2.0","method":"debug_getRawReceipts","params":["0x32026E"],"id":1}' http://127.0.0.1:8545

Last updated