Skip to main content
Version: Next

eth_getLogs

Returns all logs that match the given filter. `fromBlock` and `toBlock` bound an inclusive block range; block tags resolve against the current head block. If either bound resolves to a block number greater than the current head block, or if `fromBlock` resolves to a block number greater than `toBlock`, clients MUST return the `-32602: Invalid params` error. Clients MUST NOT clamp the range to the head block or return a partial result.

Returns an array of all logs matching the specified filter.

Parameters (by position)​

Filter object or object required


Show Option 1 Filter by block range object

Filter by block range fields​

Filter object required

Filter by block range


Show Filter object

Filter fields​

  • address null or string or array<string>


    Show Option 1 Any Address null

    Any Address fields​

    address null

    Any Address


    Show Option 2 Address string

    Address fields​

    address string

    Address

    Match pattern: ^0x[0-9a-fA-F]{40}$


    Show Option 3 Addresses array

    Addresses fields​

    address array<string>

    hex encoded address

    Match pattern: ^0x[0-9a-fA-F]{40}$


  • fromBlock string or string


    Show Option 1 Block number string

    Block number fields​

    fromBlock string

    Block number

    Match pattern: ^0x(0|[1-9a-f][0-9a-f]*)$


    Show Option 2 Block tag string

    Block tag fields​

    earliest: The lowest numbered block the client has available; finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination; safe: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions; latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions. If the safe or finalized tag cannot be resolved to a block, the method responds as it does for an unknown block.

    fromBlock string

    earliest: The lowest numbered block the client has available; finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination; safe: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions; latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions. If the safe or finalized tag cannot be resolved to a block, the method responds as it does for an unknown block.

    Allowed values: earliest finalized safe latest


  • toBlock string or string


    Show Option 1 Block number string

    Block number fields​

    toBlock string

    Block number

    Match pattern: ^0x(0|[1-9a-f][0-9a-f]*)$


    Show Option 2 Block tag string

    Block tag fields​

    earliest: The lowest numbered block the client has available; finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination; safe: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions; latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions. If the safe or finalized tag cannot be resolved to a block, the method responds as it does for an unknown block.

    toBlock string

    earliest: The lowest numbered block the client has available; finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination; safe: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions; latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions. If the safe or finalized tag cannot be resolved to a block, the method responds as it does for an unknown block.

    Allowed values: earliest finalized safe latest


  • topics null or array<unknown>


    Show Option 1 Any Topic Match null

    Any Topic Match fields​

    topics null

    Any Topic Match


    Show Option 2 Specified Filter Topics array

    Specified Filter Topics fields​

    topics null or string or array<string>


    Show Option 1 Any Topic Match null

    Any Topic Match fields​

    topics array<null>

    Any Topic Match


    Show Option 2 Single Topic Match string

    Single Topic Match fields​

    topics array<string>

    Single Topic Match

    Match pattern: ^0x[0-9a-f]{64}$


    Show Option 3 Multiple Topic Match array

    Multiple Topic Match fields​

    topics array<string>

    32 hex encoded bytes

    Match pattern: ^0x[0-9a-f]{64}$


  • additionalProperties true


Show Option 2 Filter by block hash object

Filter by block hash fields​

Filter object required

Filter by block hash


Show Filter object

Filter fields​

  • address null or string or array<string>


    Show Option 1 Any Address null

    Any Address fields​

    address null

    Any Address


    Show Option 2 Address string

    Address fields​

    address string

    Address

    Match pattern: ^0x[0-9a-fA-F]{40}$


    Show Option 3 Addresses array

    Addresses fields​

    address array<string>

    hex encoded address

    Match pattern: ^0x[0-9a-fA-F]{40}$


  • blockHash string required

    block hash

    Match pattern: ^0x[0-9a-f]{64}$


  • topics null or array<unknown>


    Show Option 1 Any Topic Match null

    Any Topic Match fields​

    topics null

    Any Topic Match


    Show Option 2 Specified Filter Topics array

    Specified Filter Topics fields​

    topics null or string or array<string>


    Show Option 1 Any Topic Match null

    Any Topic Match fields​

    topics array<null>

    Any Topic Match


    Show Option 2 Single Topic Match string

    Single Topic Match fields​

    topics array<string>

    Single Topic Match

    Match pattern: ^0x[0-9a-f]{64}$


    Show Option 3 Multiple Topic Match array

    Multiple Topic Match fields​

    topics array<string>

    32 hex encoded bytes

    Match pattern: ^0x[0-9a-f]{64}$


  • additionalProperties true


Result​

Log objects array<string> or array<object>


Show Option 1 new block or transaction hashes array

new block or transaction hashes fields​

Log objects array<string>

32 byte hex value

Match pattern: ^0x[0-9a-f]{64}$


Show Option 2 new logs array

new logs fields​

Log objects array<object>

log


Show Log objects object

Log objects fields​

  • address string required

    address

    Match pattern: ^0x[0-9a-fA-F]{40}$


  • blockHash string

    block hash

    Match pattern: ^0x[0-9a-f]{64}$


  • blockNumber string

    block number

    Match pattern: ^0x(0|[1-9a-f][0-9a-f]*)$


  • blockTimestamp string

    block timestamp

    Match pattern: ^0x(0|[1-9a-f][0-9a-f]*)$


  • data string required

    data

    Match pattern: ^0x([0-9a-f]{2})*$


  • logIndex string

    log index

    Match pattern: ^0x(0|[1-9a-f][0-9a-f]*)$


  • removed boolean

    removed


  • topics array<string> required

    32 hex encoded bytes

    Match pattern: ^0x[0-9a-f]{64}$


  • transactionHash string required

    transaction hash

    Match pattern: ^0x[0-9a-f]{64}$


  • transactionIndex string

    transaction index

    Match pattern: ^0x(0|[1-9a-f][0-9a-f]*)$


  • additionalProperties false


Errors​

Error code: 4444

  • code

    4444

  • message

    Pruned history unavailable

Examples​

eth_getLogs example

Request​

{
"params": [
{
"fromBlock": "0x3",
"toBlock": "0x6",
"topics": [
[
"0x00000000000000000000000000000000000000000000000000000000656d6974"
],
[
"0x95b7276947f6331672b0c63eca28c1d39f25286d5e2793d6a487837ff1475ba0"
]
]
}
]
}

Response​

[
{
"address": "0x7dcd17433742f4c0ca53122ab541d0ba67fc27df",
"blockHash": "0x6500d67609fa59445104e2bd635aaef50ab0276c829bda33bc54c3dc18cd29ef",
"blockNumber": "0x4",
"blockTimestamp": "0x28",
"data": "0x0000000000000000000000000000000000000000000000000000000000000001",
"logIndex": "0x0",
"removed": false,
"topics": [
"0x00000000000000000000000000000000000000000000000000000000656d6974",
"0x95b7276947f6331672b0c63eca28c1d39f25286d5e2793d6a487837ff1475ba0"
],
"transactionHash": "0xd48ebacfb769b85602310e2e0cf322e19f8cce25ac69cfd52f2d8622e3bbc3c9",
"transactionIndex": "0x1"
}
]