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 objectFilter by block range fields
Filter object required
Filter by block range
Show Filter object
Filter objectFilter fields
-
address
null or string or array<string>
Show Option 1
Any AddressnullShow Option 2
AddressstringShow Option 3
Addressesarray -
fromBlock
string or string
Show Option 1
Block numberstringShow Option 2
Block tagstringBlock tagfieldsearliest: 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 thesafeorfinalizedtag cannot be resolved to a block, the method responds as it does for an unknown block.fromBlock
stringearliest: 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 thesafeorfinalizedtag cannot be resolved to a block, the method responds as it does for an unknown block.Allowed values:
earliestfinalizedsafelatest -
toBlock
string or string
Show Option 1
Block numberstringShow Option 2
Block tagstringBlock tagfieldsearliest: 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 thesafeorfinalizedtag cannot be resolved to a block, the method responds as it does for an unknown block.toBlock
stringearliest: 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 thesafeorfinalizedtag cannot be resolved to a block, the method responds as it does for an unknown block.Allowed values:
earliestfinalizedsafelatest -
topics
null or array<unknown>
Show Option 1
Any Topic MatchnullShow Option 2
Specified Filter TopicsarraySpecified Filter Topicsfieldstopics
null or string or array<string>Show Option 1
Any Topic MatchnullShow Option 2
Single Topic MatchstringShow Option 3
Multiple Topic Matcharray -
additionalProperties
true
Show Option 2 Filter by block hash object
Filter by block hash objectFilter by block hash fields
Filter object required
Filter by block hash
Show Filter object
Filter objectFilter fields
-
address
null or string or array<string>
Show Option 1
Any AddressnullShow Option 2
AddressstringShow Option 3
Addressesarray -
blockHash
stringrequiredblock hash
Match pattern:
^0x[0-9a-f]{64}$
-
topics
null or array<unknown>
Show Option 1
Any Topic MatchnullShow Option 2
Specified Filter TopicsarraySpecified Filter Topicsfieldstopics
null or string or array<string>Show Option 1
Any Topic MatchnullShow Option 2
Single Topic MatchstringShow Option 3
Multiple Topic Matcharray -
additionalProperties
true
Result
Log objects array<string> or array<object>
Show Option 1 new block or transaction hashes array
new block or transaction hashes arraynew 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 arraynew logs fields
Log objects array<object>
log
Show Log objects object
Log objects objectLog objects fields
-
address
stringrequiredaddress
Match pattern:
^0x[0-9a-fA-F]{40}$
-
blockHash
stringblock hash
Match pattern:
^0x[0-9a-f]{64}$
-
blockNumber
stringblock number
Match pattern:
^0x(0|[1-9a-f][0-9a-f]*)$
-
blockTimestamp
stringblock timestamp
Match pattern:
^0x(0|[1-9a-f][0-9a-f]*)$
-
data
stringrequireddata
Match pattern:
^0x([0-9a-f]{2})*$
-
logIndex
stringlog index
Match pattern:
^0x(0|[1-9a-f][0-9a-f]*)$
-
removed
booleanremoved
-
topics
array<string>required32 hex encoded bytes
Match pattern:
^0x[0-9a-f]{64}$
-
transactionHash
stringrequiredtransaction hash
Match pattern:
^0x[0-9a-f]{64}$
-
transactionIndex
stringtransaction 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"
}
]