Polling method for a filter, which returns an array of logs which occurred since last poll.
Parameters
Name
Type
Description
QUANTITY
string
The filter id (e.g., "0x16" // 22).
Return Value
Array - Array of log objects, or an empty array if nothing has changed since last poll.
For filters created with klay_newBlockFilter, the return are block hashes (32-byte DATA), e.g., ["0x3454645634534..."].
For filters created with klay_newPendingTransactionFilter, the return are transaction hashes (32-byte DATA), e.g., ["0x6345343454645..."].
For filters created with klay_newFilter, logs are objects with following parameters:
Name
Type
Description
removed
TAG
true when the log was removed, due to a chain reorganization. false if it is a valid log.
logIndex
QUANTITY
Integer of the log index position in the block. null when it is a pending log.
transactionIndex
QUANTITY
Integer of the transactions index position log was created from. null when pending.
transactionHash
32-byte DATA
Hash of the transactions this log was created from. null when pending.
blockHash
32-byte DATA
Hash of the block where this log was in. null when pending.
blockNumber
QUANTITY
The block number where this log was in. null when pending.
address
20-byte DATA
Address from which this log originated.
data
DATA
Contains the non-indexed arguments of the log.
topics
Array of DATA
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.).
Returns an array of all logs matching filter with given id, which has been obtained using klay_newFilter. Note that filter ids returned by other filter creation functions, such as klay_newBlockFilter or klay_newPendingTransactionFilter, cannot be used with this function.
The execution of this API can be limited by two node configurations to manage resources of Klaytn 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).
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 Klaytn 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).
Parameters
Object - The filter options:
Name
Type
Description
fromBlock
QUANTITY | TAG
(optional, default: "latest") Integer or hexadecimal block number, or the string "earliest", "latest" or "pending" as in the default block parameter.
toBlock
QUANTITY | TAG
(optional, default: "latest") Integer or hexadecimal block number, or the string "earliest", "latest" or "pending" as in the default block parameter.
address
20-byte DATA | Array
(optional) Contract address or a list of addresses from which logs should originate.
topics
Array of DATA
(optional) Array of 32-byte DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with “or” options.
blockHash
32-byte DATA
(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.
:::note
NOTE: In versions earlier than Klaytn v1.7.0, only integer block number, the string "earliest" and "latest" are available.
Creates a filter object, based on filter options, to notify when the state changes (logs).
To check if the state has changed, call klay_getFilterChanges.
To obtain all logs matching the filter created by klay_newFilter, call klay_getFilterLogs.
A note on specifying topic filters: Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters:
[] "anything"
[A] "A in first position (and anything after)"
[null, B] "anything in first position AND B in second position (and anything after)"
[A, B] "A in first position AND B in second position (and anything after)"
[[A, B], [A, B]] "(A OR B) in first position AND (A OR B) in second position (and anything after)"
Parameters
Object - The filter options:
Name
Type
Description
fromBlock
QUANTITY | TAG
(optional, default: "latest") Integer or hexadecimal block number, or the string "earliest", "latest" or "pending" as in the default block parameter.
toBlock
QUANTITY | TAG
(optional, default: "latest") Integer or hexadecimal block number, or the string "earliest", "latest" or "pending" as in the default block parameter.
address
20-byte DATA | Array
(optional) Contract address or a list of addresses from which logs should originate.
topics
Array of DATA
(optional) Array of 32-byte DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
:::note
NOTE: In versions earlier than Klaytn v1.7.0, only integer block number, the string "earliest" and "latest" are available.
Creates a new subscription to specific events by using either RPC Pub/Sub over WebSockets or filters over HTTP. It allows clients to wait for events instead of polling for them.
The node will return a subscription id for each subscription created. For each event that matches the subscription, a notification with relevant data is sent together with the subscription id. If a connection is closed, all subscriptions created over the connection are removed.
Parameters
Object - A notification type: "newHeads" or "logs".
"newHeads" notifies you of each block added to the blockchain. "logs" notifies you of logs included in new blocks. This type requires a second parameter that specifies filter options. For more details, go to klay_newFilter > parameters.
Return Value
Type
Description
QUANTITY
A subscription id when a subscription is created. For each event that matches the subscription, a notification with relevant data will be delivered as well.
Example
This API is appropriate for use with a WebSocket tool, wscat.
Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additionally, filters timeout when they are not requested with klay_getFilterChanges for a period of time.
Parameters
Name
Type
Description
filter
QUANTITY
A filter id.
Return Value
Type
Description
Boolean
true if the filter was successfully uninstalled, otherwise false.
Cancels the subscription with a specific subscription id by using either RPC Pub/Sub over WebSockets or filters over HTTP. Only the connection that created a subscription can unsubscribe from it.
Parameters
Type
Description
QUANTITY
A subscription id.
Return Value
Type
Description
Boolean
true if the subscription was successfully canceled, otherwise false.
Example
This API is appropriate for use with a WebSocket tool, wscat.