跳至主要內容

交易

tokenview大约 5 分钟

交易

交易详情

GET https://services.tokenview.io/vipapi/tx/{公链简称小写}/{交易哈希}?apikey={apikey}

参数

备注:

调用ETH接口时,请务必将地址hash或交易hash中的大写字母转化成小写字母。

Request

curl --location https://services.tokenview.io/vipapi/tx/etc/0x6c6050578b74a33fff4511380d3596afc700a547a87f1bc80c76b336584fa2af?apikey={apikey}

Response

{
    "code": 1,
    "msg": "成功",
    "data": {
        "type": "tx",
        "network": "ETH",
        "block_no": 5500018,
        "height": 5500018,
        "index": 1,
        "time": 1524611547,
        "txid": "0x914443ef1e9028e031ace86264593afc4d03fbdb77725ef92bcd75b2f9a8df26",
        "fee": "0.003067845",
        "from": "0x0681d8db095565fe8a346fa0277bffde9c0edbbf",
        "fromAlias": "Binance-Hot",
        "to": "0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0",
        "toAlias": "EOS: Old Token",
        "nonce": 587427,
        "toIsContract": 1,
        "gasPrice": 55000000000,
        "gasLimit": 111558,
        "value": "0",
        "gasUsed": 55779,
        "tokenTransfer": [
            {
                "index": 1,
                "token": "0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0",
                "tokenAddr": "0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0",
                "tokenSymbol": "EOS",
                "tokenDecimals": "18",
                "tokenInfo": {
                    "h": "0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0",
                    "p": "ETH",
                    "f": "",
                    "s": "EOS",
                    "d": "18",
                    "t": "1000000000"
                },
                "from": "0x0681d8db095565fe8a346fa0277bffde9c0edbbf",
                "to": "0x4fc0b58336ca227f9227709fff57026d23251670",
                "fromAlias": "Binance-Hot",
                "value": "600000000000000000"
            }
        ]
    }
}

应答字段说明

"data": {
    "type": "tx",        // 返回的记录类型:交易transaction
    "network": "ETH",    // 公链符号
    "block_no": 9296272, // 区块高度
    "height": 9296272,   // 区块高度deprecated
    "index": 141,        // 此交易在区块里位置索引
    "time": 1579231507,  // 区块生成时间UTC
    "txid": "0x99ad94a572e8b12b95f559dfe0385ea3821fd8e276671a8862dc3d4d485ca867",   // 此交易的hash
    "fee": "0.000224526",// 交易的手续费
    "confirmations": 188,// 确认数
    "from": "0x476a64bfc50541cedb4154a84c67632b25b0c300", // 发起交易的地址hash(如果是转账:就是转出地址;如果是调用合约:就是调用合约的发起方的地址)
    "to": "0x58b6a8a3302369daec383334672404ee733ab239", // 被动交易的地址hash(如果是转账:就是转入地址;如果是调用合约:就是被调用合约的地址)
    "toAlias": "Livepeer Token", // to地址的别名
    "nonce": 6,          // 交易的nonce
    "toIsContract": 1,   // 如果出现该字段,表示to地址是合约地址
    "gasPrice": 6000000000, // gas价格
    "gasLimit": 300000,  // gas最大使用量
    "value": "0",        // 转账的金额(单位ETH)
    "gasUsed": 37421,    // 实际的gas使用量
    "tokenTransfer": [   // 如果出现此tokenTransfer字段,表示此交易里包含了代币转账
        {
            "index": 141, // 此交易在区块里位置索引
            "token": "0x58b6a8a3302369daec383334672404ee733ab239", // 代币名称或者hash地址
            "tokenAddr": "0x58b6a8a3302369daec383334672404ee733ab239", // 代币的hash地址
            "tokenSymbol": "LPT",// 代币符号symbol
            "tokenDecimals": "18", // 代币精度
            "tokenInfo": {       
                "h": "0x58b6a8a3302369daec383334672404ee733ab239", // 代币hash地址
                "f": "Livepeer Token", //代币全称 name
                "s": "LPT", // 代币符号 symbol
                "d": "18"   // 代币精度 decimals
            },
            "from":   // 转出代币的地址 "0x476a64bfc50541cedb4154a84c67632b25b0c300",
            "to": "0xf4f08ecfeebcdf5a0845fdbe4d8afea71ef38aa2", // 接收代币的地址
            "value": "2075683957459207235" // 转账金额(单位是代币),需要除以10的decimals次方才是真实数字
        }
    ],
    "callTransfer": [ // 如果出现此callTransfer字段,表示此交易里包含了合约调用转账
    {
        "index": 21, // 此交易在区块里位置索引
        "fromIsContract": 1, // 如果出现此字段,表示from是一个合约地址
        "from": "0x3dae53ee778a324bd317bd270d6227406b6bd4ed", // 转出地址
        "to": "0xe828273d4de447079b610bdde4fe22f3a21fe94c", // 转入地址
        "value": "0.212", // 转账金额(单位ETH)
        "gasUsed": 0, // gas实际使用量
        "gasLimit": 2300 // gas最大使用量
    }
]
}
交易异常的判断: 如果data里出现“status”字段且值为0,或者data里出现了“receiptErr”字段,或者data里出现了“error”字段。只要出现3个条件中的一个,交易就是异常的。

交易确认数

GET https://services.tokenview.io/vipapi/tx/confirmation/{公链简称小写}/{交易哈希}?apikey={apikey}

参数

备注:

调用ETH接口时,请务必将地址hash或交易hash中的大写字母转化成小写字母。

Request

curl --location https://services.tokenview.io/vipapi/tx/confirmation/eth/0x914443ef1e9028e031ace86264593afc4d03fbdb77725ef92bcd75b2f9a8df26?apikey={apikey}

Response

{
    "code": 1,
    "msg": "成功",
    "data": {
        "network": "ETH",
        "txId": "0x914443ef1e9028e031ace86264593afc4d03fbdb77725ef92bcd75b2f9a8df26",
        "confirmation": 2572000
    }
}

应答字段说明

"data": {
    "network": "ETH", // 公链的简称
    "txId": "0x914443ef1e9028e031ace86264593afc4d03fbdb77725ef92bcd75b2f9a8df26", // 交易hash
    "confirmation": 3966037 // 此交易的确认数
}

交易是否确认

GET https://services.tokenview.io/vipapi/pending/{公链简称小写}/{交易哈希}?apikey={apikey}

参数

备注:

调用ETH接口时,请务必将地址hash或交易hash中的大写字母转化成小写字母。

1. 待确认交易:交易还等待打包,还没有进入到区块链里。如果返回404,说明待确认队列里,没有这笔交易,交易已成功或失败。
2. 如果该交易在待确认队列里,应答如下(因为还没打包,所以块高未知):
"data": {
    "type": "tx",  // 类型 tx表示交易
    "network": "ETH",
    "time": 1670445653, // 交易发生的时间戳
    "txid": "0xcd3fb5d9e3b0157c39936570eb534f9480e685024b1d5481697353f744b48a8c", // 交易ID
    "fee": "0.000031807059501", // 手续费
    "from": "0x173ef98a63d7b968dc3aac38522e76706147f6a9", // 发送方
    "to": "0x3975bfdfdc680179c63e8230ab52548f643097e9", // 接收方
    "nonce": 503,
    "gasPrice": 1514621881,
    "gasLimit": 21000,
    "value": "0.00003550946857299", // 转账金额
    "gasUsed": 0
  }

Request

curl --location https://services.tokenview.io/vipapi/pending/eth/0xcd3fb5d9e3b0157c39936570eb534f9480e685024b1d5481697353f744b48a8c?apikey={apikey}

Response

{
    "code": 1,
    "msg": "成功",
    "data": {
        "type": "tx",
        "network": "ETH",
        "time": 1670445653,
        "txid": "0xcd3fb5d9e3b0157c39936570eb534f9480e685024b1d5481697353f744b48a8c",
        "fee": "0.000031807059501",
        "from": "0x173ef98a63d7b968dc3aac38522e76706147f6a9",
        "to": "0x3975bfdfdc680179c63e8230ab52548f643097e9",
        "nonce": 503,
        "gasPrice": 1514621881,
        "gasLimit": 21000,
        "value": "0.00003550946857299",
        "gasUsed": 0
    }
}

交易日志详情

GET https://services.tokenview.io/vipapi/{公链简称小写}/tx/runlog/{交易所在的区块高度}/{交易在区块里的位置}?apikey={apikey}

参数

  • {公链简称小写}:eth, bsc, kcs, movr
  • {交易所在的区块高度}:此笔交易在该区块链的区块高度;
  • {交易在区块里的位置}:该区块中,这笔交易是第几笔交易;
  • {apikey}: 可在Tokenview API 后台管理系统获取激活状态的 APIKEY: https://services.tokenview.ioopen in new window
备注:

调用ETH接口时,请务必将地址hash或交易hash中的大写字母转化成小写字母。

Request

curl --location https://services.tokenview.io/vipapi/eth/tx/runlog/9000000/2?apikey={apikey}

Response

{
    "code": 1,
    "msg": "成功",
    "data": {
        "block_no": 9000000,
        "trace": [
            {
                "result": {
                    "output": "0x01",
                    "gasUsed": "0x6f95"
                },
                "traceAddress": [],
                "action": {
                    "input": "0xa9059cbb0000000000000000000000005f5b019fd4b42cf0c92e3ec1bf85f2c56210557800000000000000000000000000000000000000000000000000000008bb2c9700",
                    "gas": "0x6f95",
                    "from": "0x2e1809d345216aa72833ba5f2881885c2999c103",
                    "to": "0xe5caef4af8780e59df925470b050fb23c43ca68c",
                    "value": "0x0",
                    "callType": "call"
                },
                "type": "call",
                "subtraces": 0
            }
        ],
        "txid": "0xc15d28717343a2573250d8d1435fc24d4bc2935b96a7cf2db06130704b8d7319",
        "index": 2,
        "receipt": {
            "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000008000000000000000000000000008000000000000000000200000000000000000400000000000000000000000000000000000000000002000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000820000000002000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000",
            "gasUsed": "0x8f15",
            "cumulativeGasUsed": "0x13325",
            "logs": [
                {
                    "address": "0xe5caef4af8780e59df925470b050fb23c43ca68c",
                    "transactionLogIndex": "0x0",
                    "logIndex": "0x0",
                    "data": "0x08bb2c9700",
                    "removed": false,
                    "topics": [
                        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                        "0x2e1809d345216aa72833ba5f2881885c2999c103",
                        "0x5f5b019fd4b42cf0c92e3ec1bf85f2c562105578"
                    ],
                    "type": "mined"
                }
            ],
            "status": "0x1"
        }
    }
}

应答字段说明

"data": {
        "block_no": 9000000, // 区块高度
        "index": "2",   // 交易在区块里的位置索引
        "receipt": {    // 这个是geth全节点的Event日志
            "status": "0x1",
            "cumulativeGasUsed": "0x13325",
            "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000008000000000000000000000000008000000000000000000200000000000000000400000000000000000000000000000000000000000002000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000820000000002000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000",
            "gasUsed": "0x8f15",
            "logs": [
                {
                    "type": "mined",
                    "topics": [
                        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                        "0x2e1809d345216aa72833ba5f2881885c2999c103",
                        "0x5f5b019fd4b42cf0c92e3ec1bf85f2c562105578"
                    ],
                    "address": "0xe5caef4af8780e59df925470b050fb23c43ca68c",
                    "transactionLogIndex": "0x0",
                    "logIndex": "0x0",
                    "data": "0x08bb2c9700"
                }
            ]
        },
        "trace": [  // 这个是parity全节点的trace日志
            {
                "traceAddress": [],
                "subtraces": 0,
                "type": "call",
                "action": {
                    "callType": "call",
                    "from": "0x2e1809d345216aa72833ba5f2881885c2999c103",
                    "gas": "0x6f95",
                    "value": "0x0",
                    "to": "0xe5caef4af8780e59df925470b050fb23c43ca68c",
                    "input": "0xa9059cbb0000000000000000000000005f5b019fd4b42cf0c92e3ec1bf85f2c56210557800000000000000000000000000000000000000000000000000000008bb2c9700"
                },
                "result": {
                    "output": "0x01",
                    "gasUsed": "0x6f95"
                }
            }
        ]
    }

上次编辑于: