Dev portal
Theme

Get Event Logs by Address and Topic#

Query the event logs under a given contract address that match a specified event signature (topic0), returned page by page using a cursor. This endpoint supports EVM-compatible chains only.

This endpoint uses a scan-style cursor: on each request, the server scans a fixed number of logs from that address's log stream and filters them by topic0 (which keeps the time cost of a single request bounded). As a result, the number of matches returned on a single page may be fewer than limit, or even 0. As long as cursor is non-empty, unscanned data remains, and the client must keep paginating with the returned cursor until cursor is an empty string.

Supported chains: see Get Event Log API Supported Chains (apiName: by-address-and-topic).

Request URL#

GET
https://web3.okx.com/api/v6/explorer/log/by-address-and-topic

Request Parameters#

ParameterTypeRequiredDescription
chainIndexStringYesUnique identifier of the chain, e.g., 1 for ETH and 0 for BTC. See Get Event Log API Supported Chains for supported values.
addressStringYesContract address.
topic0StringYesEvent signature hash (topic0), e.g., 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef for the ERC-20 Transfer event.
cursorStringNoScan cursor returned by the previous response. Omit it or pass an empty string to start scanning from the latest logs.
limitStringNoMaximum number of matches returned per page. Default is 100, maximum is 1000 (with a scan-style cursor, a single page may return fewer than this value).

Response Parameters#

ParameterTypeDescription
limitStringMaximum number of entries on this page.
cursorStringCursor for the next page; an empty string means no more pages. Pass it back as-is; clients should not parse or construct it.
logListArrayEvent log list.
> heightStringBlock height.
> addressStringContract address that emitted the event log.
> topicsArrayTopic list, with String elements.
> dataStringThe event log's data field, as a hexadecimal string.
> methodIdStringmethodId, identifying the method that triggered the log.
> blockHashStringBlock hash.
> transactionTimeStringTransaction time, as a Unix timestamp in milliseconds.
> logIndexStringLog index.
> txIdStringTransaction hash.

Request Example#

shell
curl --location --request GET 'https://web3.okx.com/api/v6/explorer/log/by-address-and-topic?chainIndex=1&address=0xdac17f958d2ee523a2206206994597c13d831ec7&topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' \
--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": "21283946",
                    "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
                    "topics": [
                        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                        "0x000000000000000000000000f89d7b9c864f589bbf53a82105107622b35eaa40",
                        "0x00000000000000000000000028c6c06298d514db089934071355e5743bf21d60"
                    ],
                    "data": "0x000000000000000000000000000000000000000000000000000000174876e800",
                    "methodId": "0xa9059cbb",
                    "blockHash": "0x9b2e4c6a8d0f31f3c5a0d9e7b2c4a6d8f0b1c3e5a7d9f2b4c6e8a0d1f3b5c7e9",
                    "transactionTime": "1733196827000",
                    "logIndex": "87",
                    "txId": "0x3a5f70d2b8e6c4a1f9d3b5e7c0a2d4f6b8e1c3a5d7f9b2e4c6a8d0f37d4b1e9c"
                }
            ]
        }
    ]
}