Portal para programadores
Tema

Get Transactions in a Block#

Retrieve the transaction list within a specified block, with filtering by transaction type (regular transactions, internal transactions, token transfers, and more).

Supported chains: see Get Block API Supported Chains (apiName: transaction-list).

Request URL#

GET
https://web3.okx.com/api/v6/explorer/block/transaction-list

Request Parameters#

ParameterTypeRequiredDescription
chainIndexStringYesUnique identifier of the chain, e.g., 1 for ETH, 0 for BTC. See Get Block API Supported Chains for supported values.
heightStringYesBlock height (digits only).
protocolTypeStringNoTransaction type: transaction for regular transactions (default), internal for internal transactions, token_transfer_20 for ERC-20 token transactions, token_transfer_721 for ERC-721 token transactions, token_transfer_1155 for ERC-1155 token transactions, token_transfer_10 for TRC-10 token transactions.
cursorStringNoPagination cursor. Pass the cursor returned by the previous response; omit it on the first request.
limitStringNoNumber of results to return. Defaults to the most recent 20, up to a maximum of 100.

Response Parameters#

ParameterTypeDescription
limitStringMaximum number of results per 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.
chainIndexStringUnique identifier of the chain.
transactionListArrayTransaction list within the block.
> txidStringTransaction hash.
> methodIdStringMethod ID.
> blockHashStringBlock hash.
> heightStringHeight of the block containing the transaction.
> transactionTimeStringTransaction time, as a Unix timestamp in milliseconds, e.g., 1597026383085.
> fromStringSender address.
> isFromContractBooleanWhether the from address is a contract address.
> isToContractBooleanWhether the to address is a contract address.
> toStringRecipient address.
> amountStringTransaction amount.
> transactionSymbolStringCurrency corresponding to the transaction amount.
> txfeeStringTransaction fee. Returned only for regular transactions (transaction); an empty string "" for other types.
> stateStringTransaction state.
> tokenIdStringNFT ID.
> tokenContractAddressStringToken contract address.

Request Example#

shell
curl --location --request GET 'https://web3.okx.com/api/v6/explorer/block/transaction-list?chainIndex=1&height=19000000&protocolType=transaction' \
--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": "20",
            "cursor": "2",
            "chainIndex": "1",
            "transactionList": [
                {
                    "txid": "0x9a92dcd2a29ba1b195f6ee752f8be5da96b03b25ad38ae12de304a01048bf9c4",
                    "methodId": "0xa9059cbb",
                    "blockHash": "0xba9ded5ca1ec9adb9451bf062c9de309d9552fa0f0254a7b982d3daf7ae436cd",
                    "height": "19000000",
                    "transactionTime": "1705146239000",
                    "from": "0x28c6c06298d514db089934071355e5743bf21d60",
                    "isFromContract": false,
                    "isToContract": true,
                    "to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
                    "amount": "0",
                    "transactionSymbol": "ETH",
                    "txfee": "0.001744128940281",
                    "state": "success",
                    "tokenId": "",
                    "tokenContractAddress": ""
                }
            ]
        }
    ]
}