get https://example.com
Xlayer API- Returns an array of all logs matching a given filter object. For more information about eth_getLogs check out our Deep Dive into eth_getLogs page.
Parameters
Object - The filter options:
- fromBlock: QUANTITY|TAG - (optional, default: "latest") Value:
- Integer block number
- "latest" for the last mined block
- "pending", "earliest" for not yet mined transactions.
- toBlock: QUANTITY|TAG - (optional, default: "latest") Value:
- Integer block number
- "latest" for the last mined block
- "pending", "earliest" for not yet mined transactions.
- address: DATA|Array, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.
- topics: Array of DATA, - (optional) Array of 32 Bytes DATA topics.
- Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
- Check out more details on how to format topics in eth_newFilter.
- blockHash: DATA, 32 Bytes - (optional) With the addition of EIP-234 (Geth >= v1.8.13 or Parity >= v2.1.0), blockHash is 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.
params: [
{
"blockHash": "0xab001a17d72e49200f7115c4a59d7e12c6ac7d305b0b0318c275b137e1544f9d",
"topics": [
"0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"
]
}
]
Returns
Array - Array of log objects, or an empty array if nothing has changed since last poll.
- For filters created with eth_newBlockFilter the return are block hashes (DATA, 32 Bytes), e.g. ["0x3454645634534..."].
- For filters created with eth_newPendingTransactionFilter the return are transaction hashes (DATA, 32 Bytes), e.g. ["0x6345343454645..."].
- For filters created with eth_newFilter logs are objects with following params:
- removed: TAG - true when the log was removed, due to a chain reorganization. false if its a valid log.
- logIndex: QUANTITY - integer of the log index position in the block. null when its pending log.
- transactionIndex: QUANTITY - integer of the transactions index position log was created from. null when its pending log.
- transactionHash: DATA, 32 Bytes - hash of the transactions this log was created from. null when its pending log.
- blockHash: DATA, 32 Bytes - hash of the block where this log was in. null when its pending. null when its pending log.
- blockNumber: QUANTITY - the block number where this log was in. null when its pending. null when its pending log.
- address: DATA, 20 Bytes - address from which this log originated.
- data: DATA - contains one or more 32 Bytes non-indexed arguments of the log.
- topics: Array of DATA - 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 declare the event with the anonymous specifier.
Provider limits: For reliability, query smaller block ranges and include
address
and/ortopics
filters. Large unfiltered ranges may be rejected.
Example
Request
curl https://xlayer-mainnet.unifra.io/v1/your-api-key \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{
"address": "0x2ef3723bb09c311d035334b11614efadbd0d7a24",
"topics": ["0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"],
"blockHash": "0xab001a17d72e49200f7115c4a59d7e12c6ac7d305b0b0318c275b137e1544f9d"
}],
"id": 1
}'
URL: https://Xlayer-mainnet.unifra.io/v1/your-api-key
RequestType: POST
Body:
{
"jsonrpc":"2.0",
"method":"eth_getLogs",
"params":[{
"address": "0x2ef3723bb09c311d035334b11614efadbd0d7a24",
"topics": ["0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"],
"blockHash": "0xab001a17d72e49200f7115c4a59d7e12c6ac7d305b0b0318c275b137e1544f9d"
}],
"id":0
}
Result
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"address": "0x2ef3723bb09c311d035334b11614efadbd0d7a24",
"topics": [
"0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"
],
"data": "0x00000000000000000000000000000000000000000012f0881b264de1f245e399000000000000000000000000000000000000000000000031038e8956add503f6",
"blockNumber": "0x2208075",
"transactionHash": "0x339bcbcde793ca98a74feb14b753f0868aaa152c77770c3875f8cf932df03e92",
"transactionIndex": "0xc",
"blockHash": "0xab001a17d72e49200f7115c4a59d7e12c6ac7d305b0b0318c275b137e1544f9d",
"logIndex": "0x10",
"removed": false
},
{
"address": "0x2ef3723bb09c311d035334b11614efadbd0d7a24",
"topics": [
"0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"
],
"data": "0x00000000000000000000000000000000000000000012eef8f1831877968dc2ad000000000000000000000000000000000000000000000031079a74b37e4a8d38",
"blockNumber": "0x2208075",
"transactionHash": "0x339bcbcde793ca98a74feb14b753f0868aaa152c77770c3875f8cf932df03e92",
"transactionIndex": "0xc",
"blockHash": "0xab001a17d72e49200f7115c4a59d7e12c6ac7d305b0b0318c275b137e1544f9d",
"logIndex": "0x14",
"removed": false
}
]
}