For AI agents: an LLM-friendly Markdown version of every page is available by appending .md to its URL or by sending an Accept: text/markdown request header. The full documentation index is at https://www.ankr.com/docs/llms.txt
Skip to main content

Ethereum — History, eth, Trace and debug (2/3)

API reference for Ethereum. All methods ->

Part 2 of 3: 1 · 2 · 3

eth_getLogs

Returns an array of all logs matching a given filter object.

Parameters


  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    1. object: the filter options:

      • fromBlock (string; quantity|tag; optional; default: "latest"): either the block number or one of the following block tags:

        • latest: for the last mined block.
        • earliest: for the lowest numbered block available on the client.
        • pending: for not yet mined transactions.
      • toBlock (string; quantity|tag; optional; default: "latest"): either the block number or one of the following block tags:

        • latest: for the last mined block.
        • earliest: for the lowest numbered block available on the client.
        • pending: for not yet mined transactions.
      • address (array of strings; data, 20 bytes; optional): a contract address or a list of addresses from which logs should originate.

      • topics (array of strings; data; optional): an array of 32 bytes data topics. Topics are order-dependent. Each topic can also be an array of data with "or" options.

      • blockhash (string; data, 32 bytes; optional; future): with the addition of EIP-234, blockHash will be a new filter option which restricts the logs returned to the single block with the 32-byte hash blockHash. Using blockHash is equivalent to fromBlock = toBlock = the block number with hash blockHash. If blockHash is present in the filter criteria, then neither fromBlock nor toBlock are allowed.

Returns


  • removed (string; tag): true when the log was removed, due to a chain reorganization; false if it's a valid log.
  • logIndex (string; quantity): the log index position in the block; null when it's a pending log.
  • transactionIndex (string; quantity): the transactions index position log was created from; null when it's a pending log.
  • transactionHash (string; data, 32 bytes): a hash of the transactions this log was created from; null when it's a pending log.
  • blockHash (string; data, 32 bytes): a hash of the block containing the log; null when it's pending; null when it's a pending log.
  • blockNumber (string; quantity): the number of the block containing the log; null when it's pending; null when it's a pending log.
  • address (string; data, 20 bytes): an address from which this log originated.
  • data (string; data): contains one or more 32 bytes non-indexed arguments of the log.
  • topics (array of strings; data): an array of 0 to 4 32 bytes data of indexed log arguments. (In solidity: The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)

Request example

curl -X POST https://rpc.ankr.com/eth/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{"address": "0xdAC17F958D2ee523a2206206994597C13D831ec7"}],
"id": 1
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000009acbb72cf67103a30333a32cd203459c6a9c3311",
"0x000000000000000000000000994871e1103c5da4be270365fa62771ea4525520"
],
"data": "0x000000000000000000000000000000000000000000000000000000001ec39aa0",
"blockNumber": "0xf6289d",
"transactionHash": "0xc7ed73c9b219d4243872e5993ad2950c8ea87d15af28562d33b0c05d46a90cee",
"transactionIndex": "0x1e",
"blockHash": "0x1e12377f0357320c0e5cfcadc2dfbc9c75fc339be668e118c34e4333f835ef31",
"logIndex": "0x13",
"removed": false
},
{
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000005879975799597392c031f10b6eff282cb7974ac8",
"0x0000000000000000000000006d52ab66340f3f78d0c1007bec484268876b5948"
],
"data": "0x0000000000000000000000000000000000000000000000000000000000000000",
"blockNumber": "0xf6289d",
"transactionHash": "0x0118499f7be4c3510bd60fe3a3aee5f5f316743b6cc13a8cb0528d784f962aec",
"transactionIndex": "0x20",
"blockHash": "0x1e12377f0357320c0e5cfcadc2dfbc9c75fc339be668e118c34e4333f835ef31",
"logIndex": "0x14",
"removed": false
}
]
}

trace_filter

Retrieve traces that match filter criteria.

Parameters


  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • fromBlock (string, optional): the starting block number, given as a hexadecimal string. Example: "0x1" for the first block.
    • toBlock (string, optional): the ending block number, given as a hexadecimal string. Example: "latest" for the most recent block.
    • fromAddress (array of strings, optional): an array of addresses that initiated the transactions. Example: ["0xAddress1", "0xAddress2"].
    • toAddress (array of strings, optional): an array of addresses that received the transactions. Example: ["0xAddress1", "0xAddress2"].
    • after (integer, optional): the offset for pagination. Example: 0.
    • count (integer, optional): the number of results to return. Example: 100.
    • topics (array of arrays of strings, optional): an array of log topics to filter by. Each inner array represents a set of possible values for that topic. Example: [["0xTopic1", "0xTopic2"], ["0xTopic3"]].

Returns


  • action (object)

    • For call:
      • callType (string): the type of call (e.g., "call", "delegatecall", "staticcall").
      • from (string): the address that initiated the call.
      • to (string): the address that was called.
      • gas (string): the amount of gas provided for the call.
      • input (string): the input data for the call.
      • value (string): the amount of Wei sent with the call.
    • For create:
      • from (string): the address that created the contract.
      • gas (string): the amount of gas provided for the creation.
      • init (string): the initialization code for the contract.
      • value (string): the amount of Wei sent with the creation.
    • For reward:
      • author (string): the address that received the reward.
      • value (string): the amount of Wei rewarded.
      • rewardType (string): the type of reward (e.g., "block", "uncle").
    • For suicide:
      • address (string): the address of the contract that self-destructed.
      • refundAddress (string): the address that received the remaining balance.
      • balance (string): the remaining balance of the contract.
  • blockHash (string): the hash of the block containing the transaction.

  • blockNumber (string): The number of the block containing the transaction.

  • result (object)

    • For call:
      • gasUsed (string): The amount of gas used by the call.
      • output (string): The output data from the call.
    • For create:
      • address (string): The address of the created contract.
      • code (string): The runtime code of the created contract.
      • gasUsed (string): The amount of gas used by the creation.
    • For reward: No additional fields.
    • For suicide: No additional fields.
  • subtraces (integer): The number of subtraces (nested traces) generated by this trace.

  • traceAddress (array of integers): The address within the trace hierarchy.

  • transactionHash (string): The hash of the transaction containing the trace.

  • transactionPosition (integer): The index position of the transaction within the block.

  • type (string): The type of trace (e.g., "call", "create", "reward", "suicide").

Request example

curl -X POST https://rpc.ankr.com/eth/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "trace_filter",
"params": [{
"fromBlock": "0x3ff718",
"toBlock": "0x3ff720",
"fromAddress": ["0x1234567890abcdef1234567890abcdef12345678"],
"toAddress": ["0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"],
"topics": [["0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"]]
}],
"id": 1
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": []
}

trace_transaction

Retrieves the traces created during the execution of a given transaction.

Parameters


  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • transactionHash (string; required): the hash of the transaction for which you want to retrieve the traces.

Returns


  • action (object)

    • For call:
      • callType (string): the type of call (e.g., "call", "delegatecall", "staticcall").
      • from (string): the address that initiated the call.
      • to (string): the address that was called.
      • gas (string): the amount of gas provided for the call.
      • input (string): the input data for the call.
      • value (string): the amount of Wei sent with the call.
    • For create:
      • from (string): the address that created the contract.
      • gas (string): the amount of gas provided for the creation.
      • init (string): the initialization code for the contract.
      • value (string): the amount of Wei sent with the creation.
    • For reward:
      • author (string): the address that received the reward.
      • value (string): the amount of Wei rewarded.
      • rewardType (string): the type of reward (e.g., "block", "uncle").
    • For suicide:
      • address (string): the address of the contract that self-destructed.
      • refundAddress (string): the address that received the remaining balance.
      • balance (string): the remaining balance of the contract.
  • blockHash (string): the hash of the block containing the transaction.

  • blockNumber (string): The number of the block containing the transaction.

  • result (object)

    • For call:
      • gasUsed (string): The amount of gas used by the call.
      • output (string): The output data from the call.
    • For create:
      • address (string): The address of the created contract.
      • code (string): The runtime code of the created contract.
      • gasUsed (string): The amount of gas used by the creation.
    • For reward: No additional fields.
    • For suicide: No additional fields.
  • subtraces (integer): The number of subtraces (nested traces) generated by this trace.

  • traceAddress (array of integers): The address within the trace hierarchy.

  • transactionHash (string): The hash of the transaction containing the trace.

  • transactionPosition (integer): The index position of the transaction within the block.

  • type (string): The type of trace (e.g., "call", "create", "reward", "suicide").

Request example

curl -X POST https://rpc.ankr.com/eth/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "trace_transaction",
"params": ["0x58ddccddbc8d1deddf91e43e6623cdc2e1186f067dc687bb3928076a02bad39e"],
"id": 1
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"action": {
"callType": "call",
"from": "0x339d413ccefd986b1b3647a9cfa9cbbe70a30749",
"gas": "0x38025",
"input": "0x3161b7f60000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a50000000000000000000000000000000000000000000123a8d6d9f1c9e741075000000000000000000000000000000000000000000000000000000000017d78400000000000000000000000000000000000000000000000000000000000000010",
"value": "0x0",
"to": "0x2d61dcdd36f10b22176e0433b86f74567d529aaa"
},
"result": {
"gasUsed": "0x38025",
"output": "0x"
},
"subtraces": 1,
"traceAddress": [],
"type": "call",
"blockHash": "0xb20d0897ac3567d603afb646238b66e455bf28d234ce96cdbbe86ddc8d27c9e9",
"blockNumber": 344366750,
"transactionHash": "0x58ddccddbc8d1deddf91e43e6623cdc2e1186f067dc687bb3928076a02bad39e",
"transactionPosition": 0
}
]
}

trace_replayTransaction

Replays a transaction and returns the traces produced by its execution along with the state changes.

Parameters


  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • transactionHash (string): the hash of the transaction to be replayed.
    • traceTypes (array of strings): the types of traces to be included in the response. Possible value: trace.

Returns

The method returns an object that can include the following fields:

  • trace (array): an array of trace objects, similar to those returned by trace_transaction and trace_filter:

    • action (object)

      • For call:
        • callType (string): the type of call (e.g., "call", "delegatecall", "staticcall").
        • from (string): the address that initiated the call.
        • to (string): the address that was called.
        • gas (string): the amount of gas provided for the call.
        • input (string): the input data for the call.
        • value (string): the amount of Wei sent with the call.
      • For create:
        • from (string): the address that created the contract.
        • gas (string): the amount of gas provided for the creation.
        • init (string): the initialization code for the contract.
        • value (string): the amount of Wei sent with the creation.
      • For reward:
        • author (string): the address that received the reward.
        • value (string): the amount of Wei rewarded.
        • rewardType (string): the type of reward (e.g., "block", "uncle").
      • For suicide:
        • address (string): the address of the contract that self-destructed.
        • refundAddress (string): the address that received the remaining balance.
        • balance (string): the remaining balance of the contract.
    • blockHash (string): the hash of the block containing the transaction.

    • blockNumber (string): The number of the block containing the transaction.

    • result (object)

      • For call:
        • gasUsed (string): The amount of gas used by the call.
        • output (string): The output data from the call.
      • For create:
        • address (string): The address of the created contract.
        • code (string): The runtime code of the created contract.
        • gasUsed (string): The amount of gas used by the creation.
      • For reward: No additional fields.
      • For suicide: No additional fields.
    • subtraces (integer): The number of subtraces (nested traces) generated by this trace.

    • traceAddress (array of integers): The address within the trace hierarchy.

    • transactionHash (string): The hash of the transaction containing the trace.

    • transactionPosition (integer): The index position of the transaction within the block.

    • type (string): The type of trace (e.g., "call", "create", "reward", "suicide").

Request example

curl -X POST https://rpc.ankr.com/eth/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "trace_replayTransaction",
"params": ["0x58ddccddbc8d1deddf91e43e6623cdc2e1186f067dc687bb3928076a02bad39e", ["trace"]],
"id": 1
}'

Response example

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"output": "0x",
"stateDiff": null,
"trace": [
{
"action": {
"callType": "call",
"from": "0x339d413ccefd986b1b3647a9cfa9cbbe70a30749",
"gas": "0x38025",
"input": "0x3161b7f60000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a50000000000000000000000000000000000000000000123a8d6d9f1c9e741075000000000000000000000000000000000000000000000000000000000017d78400000000000000000000000000000000000000000000000000000000000000010",
"value": "0x0",
"to": "0x2d61dcdd36f10b22176e0433b86f74567d529aaa"
},
"result": {
"gasUsed": "0x38025",
"output": "0x"
},
"subtraces": 1,
"traceAddress": [],
"type": "call"
}
],
"vmTrace": null
}
}

trace_replayBlockTransactions

Replays all the transactions in a given block and returns the traces produced by their execution along with the state changes.

Parameters


  • id (integer; required): a request ID (example: 1).

  • jsonrpc (string; required): a JSON RPC spec used (example: 2.0).

  • method (string; required): a method used for the request.

  • params (array; required):

    • blockHash (string): the hash of the block whose transactions you want to replay.
    • traceTypes (array of strings): the types of traces to be included in the response. Possible value: trace.

Returns

The method returns an object that can include the following fields:

  • trace (array): an array of trace objects, similar to those returned by trace_transaction and trace_filter:

    • action (object)

      • For call:
        • callType (string): the type of call (e.g., "call", "delegatecall", "staticcall").
        • from (string): the address that initiated the call.
        • to (string): the address that was called.
        • gas (string): the amount of gas provided for the call.
        • input (string): the input data for the call.
        • value (string): the amount of Wei sent with the call.
      • For create:
        • from (string): the address that created the contract.
        • gas (string): the amount of gas provided for the creation.
        • init (string): the initialization code for the contract.
        • value (string): the amount of Wei sent with the creation.
      • For reward:
        • author (string): the address that received the reward.
        • value (string): the amount of Wei rewarded.
        • rewardType (string): the type of reward (e.g., "block", "uncle").
      • For suicide:
        • address (string): the address of the contract that self-destructed.
        • refundAddress (string): the address that received the remaining balance.
        • balance (string): the remaining balance of the contract.
    • blockHash (string): the hash of the block containing the transaction.

    • blockNumber (string): The number of the block containing the transaction.

    • result (object)

      • For call:
        • gasUsed (string): The amount of gas used by the call.
        • output (string): The output data from the call.
      • For create:
        • address (string): The address of the created contract.
        • code (string): The runtime code of the created contract.
        • gasUsed (string): The amount of gas used by the creation.
      • For reward: No additional fields.
      • For suicide: No additional fields.
    • subtraces (integer): The number of subtraces (nested traces) generated by this trace.

    • traceAddress (array of integers): The address within the trace hierarchy.

    • transactionHash (string): The hash of the transaction containing the trace.

    • transactionPosition (integer): The index position of the transaction within the block.

    • type (string): The type of trace (e.g., "call", "create", "reward", "suicide").

Request example

curl -X POST https://rpc.ankr.com/eth/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "trace_replayBlockTransactions",
"params": ["0x58ddccddbc8d1deddf91e43e6623cdc2e1186f067dc687bb3928076a02bad39e", ["trace"]],
"id": 1
}'