Get Event Logs by Block Range and Address#
Query the event logs emitted by a given contract address within a specified block height range, returned page by page using a cursor. This endpoint supports EVM-compatible chains only.
Supported chains: see Get Event Log API Supported Chains (apiName: by-block-and-address).
Request URL#
GET
https://web3.okx.com/api/v6/explorer/log/by-block-and-addressRequest Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
| chainIndex | String | Yes | Unique identifier of the chain, e.g., 1 for ETH and 0 for BTC. See Get Event Log API Supported Chains for supported values. |
| startBlockHeight | String | Yes | Start block height, minimum 1. |
| endBlockHeight | String | Yes | End block height, minimum 1. |
| address | String | Yes | Contract address. |
| cursor | String | No | Cursor returned by the previous response. Omit it or pass an empty string to start from the first page. |
| limit | String | No | Number of entries per page. Default is 100, maximum is 1000. |
Response Parameters#
| Parameter | Type | Description |
|---|---|---|
| limit | String | Maximum number of entries on this page. |
| cursor | String | Cursor for the next page; an empty string means no more pages. Pass it back as-is; clients should not parse or construct it. |
| logList | Array | Event log list. |
| > height | String | Block height. |
| > address | String | Contract address that emitted the event log. |
| > topics | Array | Topic list, with String elements. |
| > data | String | The event log's data field, as a hexadecimal string. |
| > methodId | String | methodId, identifying the method that triggered the log. |
| > blockHash | String | Block hash. |
| > transactionTime | String | Transaction time, as a Unix timestamp in milliseconds. |
| > logIndex | String | Log index. |
| > txId | String | Transaction hash. |
Request Example#
shell
curl --location --request GET 'https://web3.okx.com/api/v6/explorer/log/by-block-and-address?chainIndex=1&startBlockHeight=19000000&endBlockHeight=19000100&address=0xdac17f958d2ee523a2206206994597c13d831ec7' \
--header 'OK-ACCESS-KEY: 37c541a1-****-****-****-10fe7a038418' \
--header 'OK-ACCESS-SIGN: leaV********3uw=' \
--header 'OK-ACCESS-PASSPHRASE: 1****6' \
--header 'OK-ACCESS-TIMESTAMP: 2023-10-18T12:21:41.274Z'
Response Example#
json
{
"code": "0",
"msg": "",
"data": [
{
"limit": "100",
"cursor": "100",
"logList": [
{
"height": "19000012",
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000005041ed759dd4afc3a72b8192c143f72f4724081a",
"0x000000000000000000000000c6a2ad8cc6e4a7e08fc37cc5954be07d499e7654"
],
"data": "0x00000000000000000000000000000000000000000000000000000000004c4b40",
"methodId": "0xa9059cbb",
"blockHash": "0x1f3c5a0d9e7b2c4a6d8f0b1c3e5a7d9f2b4c6e8a0d1f3b5c7e9a2d4f6b8c0e1a",
"transactionTime": "1705316735000",
"logIndex": "156",
"txId": "0x7d4b1e9c3a5f70d2b8e6c4a1f9d3b5e7c0a2d4f6b8e1c3a5d7f9b2e4c6a8d0f3"
}
]
}
]
}
