開發者平臺
主題

获取区块内交易列表#

查询指定区块内的交易列表,支持按交易类型(普通交易、内部交易、代币转移等)筛选。

支持的链:见获取区块 API 支持的链apiNametransaction-list)。

请求地址#

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

请求参数#

参数名类型是否必填描述
chainIndexString链唯一标识,如 ETH 为 1、BTC 为 0;支持范围见获取区块 API 支持的链
heightString区块高度(纯数字)
protocolTypeString交易类型:普通交易 transaction(默认)、内部交易 internal、ERC-20 代币交易 token_transfer_20、ERC-721 代币交易 token_transfer_721、ERC-1155 代币交易 token_transfer_1155、TRC-10 代币交易 token_transfer_10
cursorString分页游标;取上次响应返回的 cursor,首次请求不传
limitString返回条数,默认返回最近的 20 条,最多 100 条

响应参数#

参数名类型描述
limitString本页条数上限
cursorString下一页游标;空串表示没有更多。请求时原样回传,客户端不应解析或构造
chainIndexString链唯一标识
transactionListArray区块内交易列表
> txidString交易哈希
> methodIdString方法 id
> blockHashString区块哈希
> heightString交易发生的区块高度
> transactionTimeString交易时间;Unix 时间戳的毫秒数格式,如 1597026383085
> fromString发送方地址
> isFromContractBooleanfrom 地址是否为合约地址
> isToContractBooleanto 地址是否为合约地址
> toString接收方地址
> amountString交易数量
> transactionSymbolString交易数量对应的币种
> txfeeString手续费;仅普通交易(transaction)返回,其他类型为空串 ""
> stateString交易状态
> tokenIdStringNFT 的 ID
> tokenContractAddressString代币合约地址

请求示例#

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'

响应示例#

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": ""
                }
            ]
        }
    ]
}