Filter
klay_getFilterChanges
Polling method for a filter, which returns an array of logs which occurred since last poll.
Parameters
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.
klay_newBlockFilter로 생성된 필터의 경우 블록 해시(32바이트 크기의 DATA)를 반환합니다. 예.
["0x3454645634534..."].klay_newPendingTransactionFilter로 생성된 필터의 경우 트랜잭션 해시(32바이트 크기의 DATA)를 반환합니다. 예.
["0x6345343454645..."].klay_newFilter로 생성된 필터의 경우 로그는 다음의 매개변수들을 가지는 객체입니다.
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.).
Example
klay_getFilterLogs
입력된 필터 ID와 일치하는 모든 로그를 배열 형태로 반환합니다. 필터 ID는 klay_newFilter를 통해 얻을 수 있습니다. 이때 klay_newBlockFilter, klay_newPendingTransactionFilter와 같은 다른 필터 생성 함수를 통해 얻은 필터 ID는 본 함수에 사용할 수 없습니다.
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
QUANTITY
string
The filter id
Return Value
Example
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 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:
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: In versions earlier than Klaytn v1.7.0, only integer block number, the string "earliest" and "latest" are available.
Return Value
Examples
klay_newBlockFilter
Creates a filter in the node, to notify when a new block arrives. 상태가 변경되었는지 확인하려면 klay_getFilterChanges를 호출하세요.
Parameters
None
Return Value
QUANTITY
A filter id.
Example
klay_newFilter
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.
klay_newFilter로 생성된 필터와 일치하는 모든 로그를 가져오려면 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:
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: In versions earlier than Klaytn v1.7.0, only integer block number, the string "earliest" and "latest" are available.
Return Value
QUANTITY
A filter id
Example
klay_newPendingTransactionFilter
Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call klay_getFilterChanges.
Parameters
None
Return Value
QUANTITY
A filter id.
Example
klay_subscribe
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
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.
klay_uninstallFilter
Uninstalls a filter with given id. Should always be called when watch is no longer needed. 또한, 일정 주기 동안 klay_getFilterChanges를 통해 요청되지 않으면 필터는 타임아웃 됩니다.
Parameters
filter
QUANTITY
A filter id.
Return Value
Boolean
true if the filter was successfully uninstalled, otherwise false.
Example
klay_unsubscribe
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
QUANTITY
A subscription id.
Return Value
Boolean
true if the subscription was successfully canceled, otherwise false.
Example
This API is appropriate for use with a WebSocket tool, wscat.
Last updated
Was this helpful?