Utviklerportal
Tema

Get Event Logs by Transaction Hash#

Query all event logs emitted by a single transaction, returned as a flat list (each element of the data array is one log). A single transaction returns at most 1000 logs, with no pagination. This endpoint supports EVM-compatible chains only.

Supported chains: see Get Event Log API Supported Chains (apiName: by-transaction).

Request URL#

GET
https://web3.okx.com/api/v6/explorer/log/by-transaction

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.
txIdStringYesTransaction hash.

Response Parameters#

ParameterTypeDescription
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-transaction?chainIndex=1&txId=0x2d4f6b8e1c3a5d7f9b2e4c6a8d0f37d4b1e9c3a5f70d2b8e6c4a1f9d3b5e7c0a' \
--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": [
        {
            "height": "21284215",
            "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x0000000000000000000000005041ed759dd4afc3a72b8192c143f72f4724081a",
                "0x00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45"
            ],
            "data": "0x00000000000000000000000000000000000000000000000000000002540be400",
            "methodId": "0x38ed1739",
            "blockHash": "0xd9f2b4c6e8a0d1f3b5c7e9a2d4f6b8c0e1a1f3c5a0d9e7b2c4a6d8f0b1c3e5a7",
            "transactionTime": "1733200079000",
            "logIndex": "118",
            "txId": "0x2d4f6b8e1c3a5d7f9b2e4c6a8d0f37d4b1e9c3a5f70d2b8e6c4a1f9d3b5e7c0a"
        },
        {
            "height": "21284215",
            "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45",
                "0x0000000000000000000000005041ed759dd4afc3a72b8192c143f72f4724081a"
            ],
            "data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
            "methodId": "0x38ed1739",
            "blockHash": "0xd9f2b4c6e8a0d1f3b5c7e9a2d4f6b8c0e1a1f3c5a0d9e7b2c4a6d8f0b1c3e5a7",
            "transactionTime": "1733200079000",
            "logIndex": "119",
            "txId": "0x2d4f6b8e1c3a5d7f9b2e4c6a8d0f37d4b1e9c3a5f70d2b8e6c4a1f9d3b5e7c0a"
        }
    ]
}