跳至主要內容

ETH 系列

tokenview大约 2 分钟

ETH 系列

发送 RawTransaction

POST https://services.tokenview.io/vipapi/onchainwallet/{公链简称小写}?apikey={apikey}

参数

应用场景:发送已经签完名打包好的交易上链。

备注:

post 请求 body 是 json 格式的文本。格式如下:只需将“16进制文本” 替换成打包的交易。

{"jsonrpc": "2.0", "id":"viewtoken", "method": "eth_sendRawTransaction", "params": ["16进制文本"] }

详细说明请参考:ETH官方RPC文档open in new window

正确应答格式
{"result":"交易hash","jsonrpc": "2.0", "id":"viewtoken"}

错误应答格式
{"result":null,"error":{"code":错误码,"message":"错误消息提示"},"jsonrpc": "2.0", "id":"viewtoken"}

Request

curl --location 'https://services.tokenview.io/vipapi/onchainwallet/eth' \
--header 'Content-Type: application/json' \
--data '{"jsonrpc": "2.0", "id":"viewtoken", "method": "eth_sendRawTransaction", "params": ["0xf8695984f01db23082520894b0028b81dfe5463dd2b5802b76a0d3e18993e81a8609184e72a0008025a00d8c88cc81e7994ab0a8f0bbf02b609dd921ca078d91645d2c12d8353cd25611a022bbe387aa6bb7a01a52bdca2efda76ce90cf4778222cfced828ee580e4651cb"] }'

Response

{
    "jsonrpc": "2.0",
    "id": "viewtoken",
    "result": "0x806352ce30267f28a0562ec3f7a8dfa271a950992c8beec2c5d4c20eddc1bfbc"
}

预估 Gas 花费量

POST https://services.tokenview.io/vipapi/onchainwallet/{公链简称小写}?apikey={apikey}

参数

备注: post 请求 body 是 json 格式的文本。格式如下:只需将“16进制文本” 替换成打包的交易。

{"jsonrpc": "2.0", "id":"viewtoken", "method": "eth_estimateGas", "params": ["16进制文本"] }

详细说明请参考:ETH官方RPC文档open in new window

正确应答格式
{"result":"交易hash","jsonrpc": "2.0", "id":"viewtoken"}

错误应答格式
{"result":null,"error":{"code":错误码,"message":"错误消息提示"},"jsonrpc": "2.0", "id":"viewtoken"}

Request

curl --location 'https://services.tokenview.io/vipapi/onchainwallet/eth' \
--header 'Content-Type: application/json' \
--data '{"jsonrpc": "2.0", "id": 1, "method": "eth_estimateGas", "params": [{"nonce": "0x6", "from": "0xa434a044d758cd940239c5258a9b14abde75d03f", "to": "0x6667ed6cb6e7accc4004e8844dbdd0e72d58c31c", "gas": "0x55F0", "gasPrice": "0x4190ab00", "value": "0x5bf32d963800", "data": "0x00"}]}'

Response

{"jsonrpc":"2.0","id":1,"result":"0x520c"}

地址 Nonce

POST https://services.tokenview.io/vipapi/onchainwallet/{公链简称小写}?apikey={apikey}

参数

应用场景:获取地址 Nonce
post 请求 body 是json格式的文本,格式如下
{"jsonrpc": "2.0", "id":"viewtoken", "method": "eth_getTransactionCount", "params": ["地址hash"] }

正确应答格式
{"result":"nonce 16进制值","jsonrpc": "2.0", "id":"viewtoken"}

错误应答格式
{"result":null,"error":{"code":错误码,"message":"错误消息提示"},"jsonrpc": "2.0", "id":"viewtoken"}

Request

curl --location 'https://services.tokenview.io/vipapi/onchainwallet/eth?apikey=MSfxNCmIT9me6c4GCDiGWjm1' \
--header 'Content-Type: application/json' \
--data '{"jsonrpc": "2.0", "id": 1, "method": "eth_getTransactionCount", "params": ["0x445f06cc3c47e28c1f58f509043e491c6ff6af4a","latest"]}'

Response

{"jsonrpc":"2.0","id":1,"result":"0x2e"}

上次编辑于: