跳至主要內容

交易监控APIs

tokenview大约 7 分钟

交易监控APIs

推送的消息格式

Tokenview开发者平台会把Json 格式的交易消息POST到您设置的Webhook URL。您的服务器收到通知后,响应码需是200,并且应答body里必须返回非空文本信息,比如 ok。如发送失败,会自动重试 3 次。

推送的消息为 json 文本,依据监控项目的不同而推送不同的消息格式。

Token Create(代币上链) 消息的格式如下

{
    "coin": "ETH",
    "confirmations": 1, // 确认数
    "creator": "0x8d47eaac5f9ccbe55de70801439fdd4613d74289", // 创建者 
    "height": 19481566, // 交易发生的块高
    "network": "ETH",   // 交易发生在哪条链上
    "time": 1711006247, // 交易发生时间UTC
    "tokenAddress": "0xadff34ea821f1be68a610f9266733302c07c5d57",  // token的地址
    "tokenCategory": "RC20",    // token 类型
    "tokenDecimal": "9",        // token 精度
    "tokenName": "Chain AI",    // token 名称
    "tokenSymbol": "CAI",       // token 简称
    "totalSupply": "100000000", // 总发行量
    "txChangeType": "tokencreate", // 消息类型
    "txid": "0xa6be4a5781cd7ff649b6191352c39f522bbdcfeb400506873b8336bbd9a74be8" // 交易hash
}

Token Transfer Volume(代币交易大额异动) 消息的格式如下

{
	"coin": "ETH",
	"confirmations": 1, // 确认数
	"fromAddr": "0x918c4602d9f1768b4c6e16b0e4ae3ac55f0a4dd9", // from地址
	"height": 19482378, // 交易发生的块高
	"network": "ETH",   // 交易发生在哪条链上
	"time": 1711016075, // 交易发生时间UTC
	"toAddr": "0x23878914efe38d27c4d67ab83ed1b93a74d4086a",   // to地址
	"tokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7", // token的地址
	"tokenCategory": "RC20",  // token 类型
	"tokenDecimal": "6",      // token 精度
	"tokenName": "Tether USD",// token 名称
	"tokenSymbol": "USDT",    // token 简称
	"totalSupply": "32313908246",// 总发行量
	"txChangeType": "tokentransfervolume", // 消息类型
	"txid": "0xdb3d74cc9759ca1e47cb4f52523925e28892b96758583ad33b0c11d2b35e18f7", // 交易hash
	"value": "17996180000"  // 转账金额
}

Web3 Event 消息的格式如下

{
	"coin": "ETH",
	"confirmations": 1,  // 确认数
	"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",  // 监控的地址
	"event": "{\"address\":\"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\"logIndex\":\"0x6f\",\"data\":\"0x1737f321dc32ec09\",\"removed\":false,\"topics\":[\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\",\"0x69c66beafb06674db41b22cfc50c34a93b8d82a2\",\"0xf3de3c0d654fda23dad170f0f320a92172509127\"],\"transactionIndex\":\"0x6d\"}",
	"height": 19487178,  // 交易发生的块高
	"network": "ETH",    // 交易发生在哪条链上
	"time": 1711074347,  // 交易发生时间UTC
	"topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", // 监控的topic
	"txChangeType": "event", // 消息类型
	"txid": "0x94d7a6786b5f3da48c7c4e4bd3bb99c72804645eec416c7ba851b895a10b0faa" // 交易hash
}

Webhook 签名 & 安全

为了确保您的 Webhook 安全,您可以使用您唯一的 Webhook 签名密钥生成 HMAC SHA-256 哈希码来验证它们是否来自 Tokenview。

如何获取 signing key

导航至 services 后台的项目设置open in new window页面。 单击“获取”:将显示签名密钥并可以复制以供使用。 获取SignKey

验证收到的签名

每个出站请求的header中都包含经过哈希处理的身份验证签名(X-Tokenview-Signature)。它是通过将您的签名密钥和请求正文连接在一起来计算的。 然后使用 HMAC SHA256 哈希算法生成一个哈希值。
为了验证签名来自 Tokenview,您需要生成 HMAC SHA256 哈希并将其与收到的签名进行比较。

请求头示例
Content-Type: application/json;charset=UTF-8
X-Tokenview-Signature: your-hashed-signature

签名验证示例(python)
import hmac
import hashlib
# abcde是要加密的内容,即webhook消息的body
data=bytes('abcde','utf-8')
key=bytes('signkey string','utf-8')
# digest为signature,即X-Tokenview-Signature的值
digest=hmac.new(key,data,digestmod=hashlib.sha256).hexdigest()
print(digest) 

设置 webhook URL

POST https://services.tokenview.io/vipapi/txmonitor/setwebhookurl?apikey={apikey}'

参数

Request

curl -X POST -H 'content-type:text/plain' -d '{your_webhook_url}' 'https://services.tokenview.io/vipapi/txmonitor/setwebhookurl?apikey={apikey}'

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

查询 webhook URL

GET https://services.tokenview.io/vipapi/txmonitor/getwebhookurl?apikey={apikey}

参数

Request

curl --location https://services.tokenview.io/vipapi/txmonitor/getwebhookurl?apikey={apikey}

Response

{
    "code": 1,
    "msg": "success",
    "data": "https://9aa90255-9cde-453e-83a6-2916cd2c3725.mock.pstmn.io/webhook"
}

Token Create 订阅

增加一个订阅项

POST https://services.tokenview.io/vipapi/txmonitor/addTrackingItem?apikey={apikey}

参数

Body
{
    "currency": "ETH",
    "trackType": "tokencreate"
}

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/addTrackingItem?apikey={apikey}' \
--header 'Content-Type: application/json' \
--data '{
    "currency": "ETH",
    "trackType": "tokencreate"
}'

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

查询已经订阅的监控项

GET https://services.tokenview.io/vipapi/txmonitor/getTrackingItems?apikey={apikey}

参数

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/getTrackingItems?apikey={apikey}'

Response

{
    "code": 1,
    "msg": "success",
    "data": [
        {
            "apiKey": "apikey",
            "currency": "eth", // 监控的链
            "token": null,
            "min": null,
            "max": null,
            "trackType": "tokencreate", // 监控类型
            "address": null,
            "topic": null
        }
    ]
}

查询已经订阅的监控项-按链

POST https://services.tokenview.io/vipapi/txmonitor/getTrackingItemsByNetwork?apikey={apikey}

参数

Body
{
    "currency": "ETH"
}

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/getTrackingItemsByNetwork?apikey={apikey}' \
--header 'Content-Type: application/json' \
--data '{
    "currency": "ETH"
}'

Response

{
    "code": 1,
    "msg": "success",
    "data": [
        {
            "apiKey": "apikey",
            "currency": "eth", // 监控的链
            "token": null,
            "min": null,
            "max": null,
            "trackType": "tokencreate", // 监控类型
            "address": null,
            "topic": null
        }
    ]
}

删除一个订阅项

POST https://services.tokenview.io/vipapi/txmonitor/delTrackingItem?apikey={apikey}

参数

Body
{
    "currency": "ETH",
    "trackType": "tokencreate"
}

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/delTrackingItem?apikey={apikey}' \
--header 'Content-Type: application/json' \
--data '{
    "currency": "ETH",
    "trackType": "tokencreate"
}'

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

Token Transfer Volume 订阅

增加一个订阅项

POST https://services.tokenview.io/vipapi/txmonitor/addTrackingItem?apikey={apikey}

参数

  • {currency}: ETH,BSC
  • {trackType}: tokentransfervolume
  • {token}: 可以传[原生代币]或者[RC20代币hash地址]
    • 原生代币: ETH代表以太坊, BNB代表BSC
    • RC20代币: 代币Hash地址
  • {min}: 监控的最小阈值
    • 原生代币: min >= 1000
    • RC20代币: min >= 10000
  • {max}: 监控的最大阈值
    • 原生代币: max <= 2 * min
    • RC20代币: max <= 2 * min
  • {apikey}: 可在Tokenview API 后台管理系统获取激活状态的 APIKEY: https://services.tokenview.ioopen in new window
Body
{
    "currency": "BSC", // 监控所属的链
    "trackType": "tokentransfervolume", // 监控类型
    "token": "0x52242cbab41e290e9e17ccc50cc437bb60020a9d", // 可以传原生代币或者RC20代币hash地址
    "min": 10000, // 监控阈值的最小值
    "max": 20000  // 监控阈值的最大值
}

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/addTrackingItem?apikey={apikey}' \
--header 'Content-Type: application/json' \
--data '{
    "currency": "BSC",
    "trackType": "tokentransfervolume",
    "token": "0x52242cbab41e290e9e17ccc50cc437bb60020a9d",
    "min": 10000,
    "max": 20000
}'

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

查询已经订阅的监控项

GET https://services.tokenview.io/vipapi/txmonitor/getTrackingItems?apikey={apikey}

参数

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/getTrackingItems?apikey={apikey}'

Response

{
    "code": 1,
    "msg": "success",
    "data": [
        {
            "apiKey": "your-apikey",
            "currency": "bsc",  // 监控所属的链
            "token": "0x52242cbab41e290e9e17ccc50cc437bb60020a9d", // 监控目标
            "min": 10000, // 监控阈值的最小值
            "max": 20000, // 监控阈值的最大值
            "trackType": "tokentransfervolume",  // 监控类型
            "address": null,
            "topic": null
        }
    ]
}

查询已经订阅的监控项-按链

POST https://services.tokenview.io/vipapi/txmonitor/getTrackingItemsByNetwork?apikey={apikey}

参数

Body
{
    "currency": "BSC"
}

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/getTrackingItemsByNetwork?apikey={apikey}' \
--header 'Content-Type: application/json' \
--data '{
    "currency": "BSC"
}'

Response

{
    "code": 1,
    "msg": "success",
    "data": [
        {
            "apiKey": "your-apikey",
            "currency": "bsc",  // 监控所属的链
            "token": "0x52242cbab41e290e9e17ccc50cc437bb60020a9d", // 监控目标
            "min": 10000, // 监控阈值的最小值
            "max": 20000, // 监控阈值的最大值
            "trackType": "tokentransfervolume",  // 监控类型
            "address": null,
            "topic": null
        }
    ]
}

删除一个订阅项

POST https://services.tokenview.io/vipapi/txmonitor/delTrackingItem?apikey={apikey}

参数

  • {currency}: 添加监控时的币种。ETH,BSC
  • {trackType}: tokentransfervolume
  • {token}: 添加监控时的token
  • {min}: 添加监控时的最小阈值
  • {max}: 添加监控时的最大阈值
  • {apikey}: 可在Tokenview API 后台管理系统获取激活状态的 APIKEY: https://services.tokenview.ioopen in new window
Body
{
    "currency": "BSC",
    "trackType": "tokentransfervolume",
    "token": "0x52242cbab41e290e9e17ccc50cc437bb60020a9d",
    "min": 10000,
    "max": 20000
}

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/delTrackingItem?apikey={apikey}' \
--header 'Content-Type: application/json' \
--data '{
    "currency": "BSC",
    "trackType": "tokentransfervolume",
    "token": "0x52242cbab41e290e9e17ccc50cc437bb60020a9d",
    "min": 10000,
    "max": 20000
}'

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

Event 订阅

增加一个订阅项

POST https://services.tokenview.io/vipapi/txmonitor/addTrackingItem?apikey={apikey}

参数

Body
{
    "currency": "ETH",
    "trackType": "event",
    "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
    "topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
}

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/addTrackingItem?apikey={apikey}' \
--header 'Content-Type: application/json' \
--data '{
    "currency": "ETH",
    "trackType": "event",
    "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
    "topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
}'

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

查询已经订阅的监控项

GET https://services.tokenview.io/vipapi/txmonitor/getTrackingItems?apikey={apikey}

参数

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/getTrackingItems?apikey={apikey}'

Response

{
    "code": 1,
    "msg": "success",
    "data": [
        {
            "apiKey": "QoaG1XCpsvW7On40Fzte",
            "currency": "eth", // 监控的链
            "token": null,
            "min": null,
            "max": null,
            "trackType": "event", // 监控类型
            "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
            "topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
        }
    ]
}

查询已经订阅的监控项-按链

POST https://services.tokenview.io/vipapi/txmonitor/getTrackingItemsByNetwork?apikey={apikey}

参数

Body
{
    "currency": "ETH"
}

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/getTrackingItemsByNetwork?apikey={apikey}' \
--header 'Content-Type: application/json' \
--data '{
    "currency": "ETH"
}'

Response

{
    "code": 1,
    "msg": "success",
    "data": [
        {
            "apiKey": "QoaG1XCpsvW7On40Fzte",
            "currency": "eth", // 监控的链
            "token": null, 
            "min": null,
            "max": null,
            "trackType": "event", // 监控类型
            "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
            "topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
        }
    ]
}

删除一个订阅项

POST https://services.tokenview.io/vipapi/txmonitor/delTrackingItem?apikey={apikey}

参数

Body
{
    "currency": "ETH",
    "trackType": "event",
    "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
    "topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
}

Request

curl --location 'https://services.tokenview.io/vipapi/txmonitor/delTrackingItem?apikey={apikey}' \
--header 'Content-Type: application/json' \
--data '{
    "currency": "ETH",
    "trackType": "event",
    "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
    "topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
}'

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}
上次编辑于: