EQL queries follow this general structure:
GET <fields> FROM <entity> [WHERE <conditions>] ON <chains>
GET
: Specifies the fields you want to retrieveFROM
: Defines the entity type to queryWHERE
: (Optional) Filters the resultsON
: Specifies target chains
Entities are analogous to tables in a relational database and are used to query data. The supported entities are:
account
block
tx
log
Entities can be queried using:
- Single ID:
GET balance FROM account 0x123... ON eth
- Multiple IDs:
GET balance FROM account 0x123..., 0x456..., vitalik.eth ON eth
Accounts supports the following identifiers:
- Address: 0x prefixed hex string
- ENS name: A domain name registered on the ENS registry
balance
: Current balance in weinonce
: Transaction countcode
: Contract bytecode (if contract account)address
: Account addresschain
: Chain identifier (generally used for cross-chain queries)
GET * FROM account 0x123...abc ON eth
GET * FROM account 0x123..., 0x456... ON eth
GET * FROM account vitalik.eth ON eth
Blocks supports the following identifiers:
- Block number: Integer
- Block hash: 0x prefixed hex string
- Block range: Two integers separated by a colon (
:
), representing the start and end block numbers
number
: Block numberhash
: Block hashparent_hash
: Parent block hashtimestamp
: Block timestampstate_root
: A Merkle root hash of the state of the Ethereum network at a given block, including all account balances, code, and storage.transactions_root
: A Merkle root hash of all transactions included in the blockreceipts_root
: A Merkle root hash of all receipts included in the blocklogs_bloom
: A bit vector of size 256 that compactly represents the existence of topics in the logs of a block.extra_data
: Arbitrary data associated with the block, such as a block's metadata or a custom consensus algorithm's parameters.mix_hash
: A random hash used to ensure the uniqueness of the block.total_difficulty
: A cumulative measure of the difficulty of the proof-of-work algorithm that miners must solve to produce a valid block.base_fee_per_gas
: Base fee per gaswithdrawals_root
: A Merkle root hash of the withdrawals included in the blockblob_gas_used
: The total amount of gas used for blob transactions in the block.excess_blob_gas
: The amount of excess blob gas in the block.parent_beacon_block_root
: The hash of the parent beacon block.size
: Block size in bytes.chain
: Chain identifier
GET * FROM block latest ON eth
GET * FROM block 17000000 ON eth
GET * FROM block 1:1000 ON eth
Transactions supports the following identifiers:
- Transaction hash: 0x prefixed hex string
hash
: Transaction hashfrom
: Sender addressto
: Recipient addressvalue
: Transaction value in weidata
: Transaction input datanonce
: Transaction noncegas_price
: Gas price in weigas_limit
: Gas limittype
: Transaction typefee
: Transaction fee in weistatus
: Transaction status (true = success, false = failure)v
: v component of signaturer
: r component of signatures
: s component of signaturechain
: Chain identifiermax_fee_per_blob_gas
: Maximum fee per blob gasblob_versioned_hashes
: Blob versioned hashesmax_fee_per_gas
: Maximum fee per gasmax_priority_fee_per_gas
: Maximum priority fee per gasaccess_list
: Access listy_parity
: Y parity value
GET * FROM tx 0x456... ON eth
GET * FROM tx 0x456..., 0x789... ON eth
GET * FROM tx WHERE block = latest ON eth
Unlike transactions, blocks, and accounts, logs don't have a global identifier. Instead, they are stored in a vector inside a transaction receipt. Therefore, to fetch logs, you need to specify a combination of fields to filter them.
The filtering is done using the WHERE
clause, which is explained in more detail below.
Log queries are mapped to the eth_getLogs
JSON-RPC method, which requires either a block number or a block range to be specified.
Note: Log queries do not support lists of blocks Note: Log queries only support the
=
operator for comparisons
// ERC20 transfer events
GET * FROM logs
WHERE
address = 0x123...,
topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef,
block = latest
ON eth
// Using event signature
GET * FROM log WHERE block = 4638757, event_signature = Confirmation(address,uint256) ON eth
// Query with multiple conditions
GET * FROM logs
WHERE
address = 0x123...,
block = 17000000,
topic1 = 0x000000000000000000000000{address}
ON eth
Syntax:
WHERE <[conditions, ]>
The WHERE clause is used to filter the results of a query. Each condition must use the operators described below, with multiple conditions separated by commas. Example:
GET * FROM tx WHERE block = latest, value > 0 ON eth
The where clause is currently only available for transactions and logs queries, and they work differently for each type.
For transactions queries, the WHERE
clause requires users to specify a block number, list of block numbers, or block range to filter transactions by the block they are included in.
Users can also filter transactions by any other field using the operators described below, which will filter the transactions in memory.
Example: Get all transactions from the latest block with a value greater than 0 ether
GET * FROM tx WHERE block = latest AND value > 0 ether ON eth
For logs queries, the WHERE
clause is used to pass filter parameters to the JSON-RPC method called eth_getLogs
, which is used to filter the logs by the given parameters, therefore the only supported operator is =
.
This WHERE
clause also requires either a block number or a block range to be specified.
Example:
Get all logs emitted by the contract in block 4638757 with the event signature Confirmation(address,uint256)
GET * FROM log WHERE block = 4638757, event_signature = Confirmation(address,uint256) ON eth
=
: Equal to!=
: Not equal to>
: Greater than<
: Less than>=
: Greater than or equal to<=
: Less than or equal to
Query results can be exported to various file formats using the >>
operator. The syntax is:
GET <fields> FROM <entity> [WHERE <conditions>] ON <chains> >> filename.format
json
: JavaScript Object Notationcsv
: Comma-Separated Valuesparquet
: Apache Parquet columnar storage
GET balance FROM account 0x123...abc ON eth >> balances.csv
GET balance FROM account 0x123...abc ON eth >> balances.json
GET balance FROM account 0x123...abc ON eth, polygon >> multichain_balances.json
GET * FROM tx WHERE block = 1:100, from = 0x456... >> tx_history.parquet
- File names can include alphanumeric characters, hyphens, underscores, and forward slashes
- Forward slashes can be used to specify subdirectories
- File extension must match one of the supported formats
Since EQL uses JSON-RPC providers as the backbone for querying, it inherits some limitations, most commonly:
- Rate limits apply based on your RPC provider
- Some complex queries may timeout on congested networks
For rate limits, EQL enables users to specify their own RPC providers when installed locally. Check out the installation guide for more details.