[Filter] klay_getLogs
Returns an array of all logs matching a given filter object.
The execution of this API can be limited by two node configurations to manage resources of Kaia node safely.
-The number of maximum returned results in a single query (Default: 10,000).
-The execution duration limit of a single query (Default: 10 seconds).
NOTE: In versions earlier than Kaia v1.7.0, only integer block number, the string "earliest" and "latest" are available.
JSONRPC: klay_getLogs
Request
- application/json
Body
Array [
- IntegerBlockNumber
- HexadecimalBlockNumber
- BlockTag
- IntegerBlockNumber
- HexadecimalBlockNumber
- BlockTag
- Address
- ArrayOfAddress
Array [
]
]
params
object[]
The filter options.
fromBlock
object
(optional, default "latest") Integer or hexadecimal block number, or the string "earliest", "latest" or "pending" as in the default block parameter.
oneOf
the block number with type integer
number
the block number with type hexadecimal
string
the block tag [latest, pending, earliest]
string
toBlock
object
(optional, default "latest") Integer or hexadecimal block number, or the string "earliest", "latest" or "pending" as in the default block parameter.
oneOf
the block number with type integer
number
the block number with type hexadecimal
string
the block tag [latest, pending, earliest]
string
address
object
(optional) Contract address or a list of addresses from which logs should originate.
oneOf
Contract address
string
string
(optional) Array of 32-byte DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with “or” options.
(optional) A filter option that 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 in the filter criteria, then neither fromBlock nor toBlock are allowed
Responses
- 200
Returns an array of all logs matching a given filter object.
- application/json
- Schema
- Example (from schema)
Schema
Array [
- BlockHash
- TransactionHash
- LogObject
]
error
object
A Number that indicates the error type that occurred. This MUST be an integer.
code | message | description |
---|---|---|
-32700 | Parse error | invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. |
-32602 | Invalid params | Invalid method parameter(s). |
A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.
A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).
result
object[]
Array of log objects, or an empty array if nothing has changed since last poll.
anyOf
For filters created with klay_newBlockFilter, the return are block hashes (32-byte DATA), e.g., ["0x3454645634534..."].
string
For filters created with klay_newPendingTransactionFilter, the return are transaction hashes (32-byte DATA), e.g., ["0x6345343454645..."].
string
For filters created with klay_newFilter logs are objects with following properties
true when the log was removed, due to a chain reorganization. false if its a valid log.
Integer of the log index position in the block. null when it is a pending log.
Integer of the transactions index position log was created from. null when pending.
Hash of the transactions this log was created from. null when pending.
Hash of the block where this log was in. null when pending.
The block number where this log was in. null when pending.
Address from which this log originated.
Contains the non-indexed arguments of the log.
Array of 0 to 4 32-byte 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 declared the event with the anonymous specifier.).
{
"jsonrpc": "2.0",
"id": 0,
"error": {
"code": -32700,
"message": "Parse error",
"data": "string"
},
"result": [
{
"address": "0x87ac99835e67168d4f9a40580f8f5c33550ba88b",
"topics": [
"0xfa9b2165fc71c1d6ffa03291c7f5d223ea363ec063d747eec9ce2d30d24855ef"
],
"data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000d3564e57bb5c6f4d983a493a946534f8e1e8b481000000000000000000000000000000000000000000000000000000000000001341646472657373426f6f6b436f6e747261637400000000000000000000000000",
"blockNumber": "0xd3b5",
"transactionHash": "0x57ca8ff0a0d454d4c5418694c21bc4ef3de26cf7cd18dd404d6a7189a826bfe0",
"transactionIndex": "0x0",
"blockHash": "0x279251a907c6ab1fb723595511ff401432e7c2437d54189298f53a7d33ce3a60",
"logIndex": "0x0",
"removed": false
},
{
"address": "0x87ac99835e67168d4f9a40580f8f5c33550ba88b",
"topics": [
"0xfa3e1e272694072320aad73a3fadd8876c4bf8f40899c6c7ce2fda9f4e652cfa"
],
"data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000300000000000000000000000041383b6ee0ea5108d6b139165a9c85351aacd39800000000000000000000000057f7439898e652fa9b5654022297588532e5e0370000000000000000000000005b5b7a718a4124eb746ae00b1ce6edcaa5ab55bc",
"blockNumber": "0xd3b5",
"transactionHash": "0x57ca8ff0a0d454d4c5418694c21bc4ef3de26cf7cd18dd404d6a7189a826bfe0",
"transactionIndex": "0x0",
"blockHash": "0x279251a907c6ab1fb723595511ff401432e7c2437d54189298f53a7d33ce3a60",
"logIndex": "0x1",
"removed": false
}
]
}