钱包 API

查询特定 Tx#

根据 txHash 查询某个交易的详情。

注意
钱包 API 将一笔交易和其中的内部交易都分解成子交易,并根据变动的资产类型给出了不同的子交易类型:
0: 外层主链币转移
1: 合约内层主链币转移
2: token转移

请求路径#

GET https://www.okx.com/api/v5/wallet/post-transaction/transaction-detail-by-txhash

请求参数#

ParameterTypeRequiredDescription
chainIndexStringYes链唯一标识
txHashStringYes交易哈希
iTypeStringNoEVM 交易的层级类型
0:外层主链币转移
1:合约内层主链币转移
2:token转移

响应参数#

ParameterTypeDescription
chainIndexString链的唯一标识
heightString交易发生的区块高度
txTimeString交易时间;Unix时间戳的毫秒数格式
txhashString交易哈希
txStatusString交易状态
1:pending 确认中
2:success:成功
3:fail:失败
gasLimitStringgas限额
gasUsedStringgas消耗
gasPriceStringgas价格
txFeeString交易手续费
nonceStringnonce
amountString交易数量
symbolString交易数量对应的币种简称
methodIdString合约调用函数
fromDetailsArray交易输入详情
>addressString发送/输入地址
>vinIndexString位于当前交易输入的序号
>preVoutIndexString位于上一笔输出里的序号
>txhashString交易哈希,和 prevoutIndex 一起唯一确认输入的 UTXO
> isContractBoolean发送地址是否是合约地址 true:是 ;false:否
> amountString交易数量
toDetailsArray交易输出详情
>addressString接收/输出地址
>voutIndexString输出的序号
> isContractBoolean接收地址是否是合约地址 true:是 ;false:否
> amountString交易数量
internalTransactionDetailsArray内部交易详情
> fromString交易发送方的地址
> toString交易接受方的地址
> isFromContractBooleanfrom地址是否是合约地址
> isToContractBooleanto地址是否是合约地址
> amountString交易数量
>txStatusString交易状态
tokenTransferDetailsArray代币交易详情
> fromString交易发送方的地址
> toString交易接受方的地址
> isFromContractBooleanfrom地址是否是合约地址
> isToContractBooleanto地址是否是合约地址
> tokenContractAddressString代币合约地址
> symbolString交易代币的简称
> amountString交易数量
l1OriginHashStringL1执行的交易哈希

请求示例#

shell
curl --location --request GET 'https://www.okx.com/api/v5/wallet/post-transaction/transaction-detail-by-txhash?txHash=0x9ab8ccccc9f778ea91ce4c0f15517672c4bd06d166e830da41ba552e744d29a5&chainIndex=42161' \
--header 'Content-Type: application/json' \
--header 'OK-ACCESS-PROJECT: 86af********d1bc' \
--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'

响应示例#

200
以 ETH 为例

{
    "code": "0",
    "msg": "success",
    "data": [
        {
            "chainIndex": "42161",
            "height": "245222398",
            "txTime": "1724253417000",
            "txhash": "0x9ab8ccccc9f778ea91ce4c0f15517672c4bd06d166e830da41ba552e744d29a5",
            "gasLimit": "2000000",
            "gasUsed": "2000000",
            "gasPrice": "10000000",
            "txFee": "",
            "nonce": "0",
            "symbol": "ETH",
            "amount": "0",
            "txStatus": "success",
            "methodId": "0xc9f95d32",
            "l1OriginHash": "0xa6a87ba2f18cc32bbae8f3b2253a29a9617ed1eb0940d80443f6e3bf9873dbad",
            "fromDetails": [
                {
                    "address": "0xd297fa914353c44b2e33ebe05f21846f1048cfeb",
                    "vinIndex": "",
                    "preVoutIndex": "",
                    "txHash": "",
                    "isContract": false,
                    "amount": ""
                }
            ],
            "toDetails": [
                {
                    "address": "0x000000000000000000000000000000000000006e",
                    "voutIndex": "",
                    "isContract": false,
                    "amount": ""
                }
            ],
            "internalTransactionDetails": [
                {
                    "from": "0x0000000000000000000000000000000000000000",
                    "to": "0xd297fa914353c44b2e33ebe05f21846f1048cfeb",
                    "isFromContract": false,
                    "isToContract": false,
                    "amount": "0.02",
                    "state": "success"
                },
                {
                    "from": "0xd297fa914353c44b2e33ebe05f21846f1048cfeb",
                    "to": "0x428ab2ba90eba0a4be7af34c9ac451ab061ac010",
                    "isFromContract": false,
                    "isToContract": false,
                    "amount": "0.00998",
                    "state": "success"
                },
                {
                    "from": "0xd297fa914353c44b2e33ebe05f21846f1048cfeb",
                    "to": "0x428ab2ba90eba0a4be7af34c9ac451ab061ac010",
                    "isFromContract": false,
                    "isToContract": false,
                    "amount": "0.009977946366846017",
                    "state": "success"
                }
            ],
            "tokenTransferDetails": []
        }
    ]
}

以 BTC 为例

{
    "code": "0",
    "msg": "success",
    "data": [
        {
            "chainIndex": "0",
            "height": "858056",
            "txTime": "1724403746000",
            "txhash": "0538eec298699ff4b7cc07163c7216c48fe40caed492a3c655382bf0ae63db1a",
            "gasLimit": "",
            "gasUsed": "",
            "gasPrice": "",
            "txFee": "",
            "nonce": "",
            "symbol": "BTC",
            "amount": "",
            "txStatus": "success",
            "methodId": "",
            "l1OriginHash": "",
            "fromDetails": [
                {
                    "address": "bc1py4kmmdsae08zd6jlfdkcr9gzagxrs3z5elw2hjyc5u883a8ah7ps98s0mn",
                    "vinIndex": "0",
                    "preVoutIndex": "1",
                    "txHash": "b7b1460db2e7fff53cb1da10ad5351bd9a684668f21968a6b292dfe019605c4c",
                    "isContract": false,
                    "amount": "0.00001296"
                }
            ],
            "toDetails": [
                {
                    "address": "bc1p7pgnqe87red4cvd7ml6rh9pl9ufpr522k2y3dpeyrvfc6g2g3r3s3ae9dr",
                    "voutIndex": "0",
                    "isContract": false,
                    "amount": "0.00000546"
                }
            ],
            "internalTransactionDetails": [],
            "tokenTransferDetails": []
        }
    ]
}