Skip to main content
EVM

eth_getLogs

Summary: Get logs

This request passes a set of search conditions and returns an array of all logs matching those.

Parameters

filter
object

fromBlock
oneOf

Block number or string tag.

Block number
string

Block number in hexadecimal.

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

Block tag
enum

See the default block parameter.

  • 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.
  • 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.
  • pending: A sample next block built by the client on top of latest and containing the set of transactions usually taken from local mempool.

Enum:
"earliest"
"finalized"
"latest"
"pending"
toBlock
oneOf

Block number or string tag.

Block number
string

Block number in hexadecimal.

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

Block tag
enum

See the default block parameter.

  • 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.
  • 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.
  • pending: A sample next block built by the client on top of latest and containing the set of transactions usually taken from local mempool.

Enum:
"earliest"
"finalized"
"latest"
"pending"
address
oneOf

Any address
null

Any address

Address
string

Hex-encoded address.

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

Addresses
array

Hex-encoded address.

string

Hex-encoded address.

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

topics
oneOf

Filter topics.

Any topic match
null

Any topic match

Specified filter topics
array

Specified filter topics

oneOf

Filter topic list entry.

Single topic match
string

32 Hex-encoded bytes.

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

Multiple topic match
array

Multiple topic match

string

32 Hex-encoded bytes.

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

Returns

eth_getLogsResponse
oneOf

New block or transaction hashes
array

New block or transaction hashes

string

32 byte hex value.

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

New logs
array

New logs

object
required

removed
boolean

logIndex
string

Hex-encoded unsigned integer.

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

transactionIndex
string

A hexadecimal of the integer representing the position in the block.

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

transactionHash
string

The transaction hash in which the call was made.

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

blockHash
string

Block hash; 32 byte hex identifier for the block derived from the block header.

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

blockNumber
string

Block number as hex-encoded unsigned integer.

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

address
string

Hex-encoded address.

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

data
string

Hex-encoded bytes.

Pattern: ^0x[0-9a-f]*$

topics
array

string

32 Hex-encoded bytes.

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

Customize request
Parameter
Value
0x4fde9d
oneOf
0x4fde9d
oneOf
0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f
oneOf
oneOf

Request

curl https://linea-mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{"fromBlock":"0x4fde9d","toBlock":"0x4fde9d","address":"0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f","topics":[]}],
"id": 1
}'

Example response

{
"id": 1,
"jsonrpc": "2.0",
"result": [
{
"address": "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f",
"blockHash": "0xd459570b5d2994a81ec1875b058f665b7f9c006172a8bd2860de87aee9569ac8",
"blockNumber": "0x4fde9d",
"data": "0x0000000000000000000000000000000000000000000000000b6139a7cbd20000",
"logIndex": "0x0",
"removed": false,
"topics": [
"0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c",
"0x00000000000000000000000000381fd3e1ca2a3758bb86983836c645ca0c1f4a"
],
"transactionHash": "0x962e545e8ac3caef02f251d175cb0519c14db387559bb5804e988e175b3bc6c4",
"transactionIndex": "0x1"
},
{
"address": "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f",
"blockHash": "0xd459570b5d2994a81ec1875b058f665b7f9c006172a8bd2860de87aee9569ac8",
"blockNumber": "0x4fde9d",
"data": "0x000000000000000000000000000000000000000000000000001057acf5f78000",
"logIndex": "0x18",
"removed": false,
"topics": [
"0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c",
"0x000000000000000000000000fe6508f0015c778bdcc1fb5465ba5ebe224c9912"
],
"transactionHash": "0x1edcdbf205d33cb1f7f88eb58324f20aa32ad7af494ead208d7bc90762c304ea",
"transactionIndex": "0xa"
},
{
"address": "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f",
"blockHash": "0xd459570b5d2994a81ec1875b058f665b7f9c006172a8bd2860de87aee9569ac8",
"blockNumber": "0x4fde9d",
"data": "0x000000000000000000000000000000000000000000000000001057acf5f78000",
"logIndex": "0x1a",
"removed": false,
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000fe6508f0015c778bdcc1fb5465ba5ebe224c9912",
"0x000000000000000000000000586733678b9ac9da43dd7cb83bbb41d23677dfc3"
],
"transactionHash": "0x1edcdbf205d33cb1f7f88eb58324f20aa32ad7af494ead208d7bc90762c304ea",
"transactionIndex": "0xa"
},
{
"address": "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f",
"blockHash": "0xd459570b5d2994a81ec1875b058f665b7f9c006172a8bd2860de87aee9569ac8",
"blockNumber": "0x4fde9d",
"data": "0x00000000000000000000000000000000000000000000000000138a64211903b7",
"logIndex": "0x2a",
"removed": false,
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000e24b4a292ba102a9b7b7f9de20718d7ba45ddb29",
"0x000000000000000000000000d804ba88371a3f00ddaca03cbc2b6c47f38105fc"
],
"transactionHash": "0x3613dbdec4df03cd1efc903773ffad8703c8a6f902384299dc22e32bf3223fab",
"transactionIndex": "0x10"
}
]
}

Constraints

The following constraints apply:

To prevent queries from consuming too many resources, eth_getLogs requests are currently limited by three constraints:

  • A maximum of 5,000 parameters can be included in a single request.
  • A maximum of 10,000 results can be returned by a single query.
  • Query duration must not exceed 10 seconds.

If a query returns too many results or exceeds the max query duration, one of the following errors is returned:

{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32005,
"message": "query returned more than 10000 results"
}
}

or

{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32005,
"message": "query timeout exceeded"
}
}

If this happens:

  • Limit your query to a smaller number of blocks using fromBlock and toBlock.
  • If querying for commonly used topics, consider limiting to a single smart contract address.