ETH API 文档

您所在的位置:网站首页 eth多签 ETH API 文档

ETH API 文档

2023-09-20 04:16| 来源: 网络整理| 查看: 265

介绍说明

https://testnet.sectoken.io/

获取当前账户的费用地址import requests requests.get( url="https://testnet.sectoken.io/wallet/eth/fee/", headers={"HMAC": "your token"} ) curl "https://testnet.sectoken.io/wallet/eth/fee/" \ -X GET \ -H "HMAC:your token" \ var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/fee/', method: "get", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": { "address": "0x1B004A73c74aC24891a1618e8b66C7dC95716E4b", "balance": "318062988000000000" } }

获取当前账户的费用地址,如果不存在,则创建新的一个ETH地址。费用地址作用:

用来支付创建多签钱包部署合约的矿工费

用来支付新增收款地址合约部署的的矿工费

用来支付多签钱包转账的矿工费

把ERC20从钱包收款地址归集到钱包多签地址,也需要支付矿工费。

费用地址建议充值0.01ETH以上。

HTTP Request

GET https://testnet.sectoken.io/wallet/eth/fee/

无请求参数返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data object 返回内容 data 参数 参数名 参数类型 说明 address string 费用地址 balance string 余额,单位为Wei 创建eth多签钱包

创建一个多签钱包所需成本大约 910000 gas

import requests requests.post( url="https://testnet.sectoken.io/wallet/eth/create/", headers={"HMAC": "your token"}, json={ "pubkeys": [ "027c9612b91ed830de2259819c85e160084fb1fb0ca5ad2d02537c085f3b93246c", "02d654b7b6829df777a32267d366b4c24fd30fc1a61d816e043104edd198678e52" ], "privkeys":[ "NjdhOTg1MjNlYjBkMDJiNTEzYTQyZjA3OGNiYTVjNGYwNThjODhjOGY3MGY5YjI3NTVkODI3ODUzMDE4MTgyMg==", "YTU4MWRiYjlhZjA1NGM5MGY3Y2RkYzc3NjdlN2JhZmM5YjdlNjI0MGQyNGQ0ZWRlYjc0YjM3YmQ5MjBjOWVlMg==", ], "wallet_name": "your wallet name", } ) curl "https://testnet.sectoken.io/wallet/eth/create/" \ -H "HMAC:your token" \ -H "Content-Type:application/json" \ -X POST \ -d '{"pubkeys": ["027c9612b91ed830de2259819c85e160084fb1fb0ca5ad2d02537c085f3b93246c", "02d654b7b6829df777a32267d366b4c24fd30fc1a61d816e043104edd198678e52"], "privkeys": ["NjdhOTg1MjNlYjBkMDJiNTEzYTQyZjA3OGNiYTVjNGYwNThjODhjOGY3MGY5YjI3NTVkODI3ODUzMDE4MTgyMg==", "YTU4MWRiYjlhZjA1NGM5MGY3Y2RkYzc3NjdlN2JhZmM5YjdlNjI0MGQyNGQ0ZWRlYjc0YjM3YmQ5MjBjOWVlMg=="], "wallet_name": "your wallet name"}' var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/create/', method: "post", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, body: JSON.stringify({ 'pubkeys': ['02f9ecb53c10e999fd2ca3a8f4503d2c5df3521e38cef44570e34f7bdc23219c70', '023a602328d823875cd8a00393dbade47bd1f16dab100ad89ee35b1bc61607f10c'], 'wallet_name': 'your token' }) }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": { "wallet_id": "cf761ad1b6c5f30a1557d942cb557b07", "activate_code": "712968", "server_pubkey": "xpub6AZMDpGgTSsnXRfapb7wm3fMppz38ayMmHePm7A27noBxiiBV7YzPqX71dZMgHkRQZWSC2WK2dXQs6tGBqqXvo3TTUWW6BmSNucv5iVRDfa" } } HTTP Request

POST https://testnet.sectoken.io/wallet/eth/create/

请求参数 参数名 参数类型 必填 说明 pubkeys array 是 公钥列表 privkeys array 否 私钥列表 wallet_name string 是 钱包名 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data object 返回内容 data 参数 参数名 参数类型 说明 wallet_id string 钱包的id activate_code string 钱包激活码 server_pubkey string 钱包的xpub 激活钱包import requests requests.post( url="https://testnet.sectoken.io/wallet/eth/activate/", headers={"HMAC": "your token"}, json={ "wallet_id": "your wallet id", "activate_code": "your activate code", } ) curl "https://testnet.sectoken.io/wallet/eth/activate/" \ -H "HMAC:your token" \ -H "Content-Type:application/json" \ -X POST \ -d '{"wallet_id": "your wallet id", "activate_code": "your activate code"}' var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/activate/', method: "post", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, body: JSON.stringify({ 'wallet_id': 'fbff0c98881b4b20b3368e1fa1e64b85', 'activate_code': '298301' }) }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": { "address": "0x4b81124e2C5B6a774c0d4CFa0c346D37c5d9087B", } } HTTP Request

POST https://testnet.sectoken.io/wallet/eth/activate/

请求参数 参数名 参数类型 必填 说明 wallet_id string 是 钱包id activate_code string 是 钱包激活码 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data object 返回内容 data 参数 参数名 参数类型 说明 address string 钱包的地址 查看钱包信息import requests requests.get( url="https://testnet.sectoken.io/wallet/eth/detail/", headers={"HMAC": "your token"}, params={"wallet_id": "your wallet id", "coin_type": "eth"} ) curl "https://testnet.sectoken.io/wallet/eth/detail/?wallet_id=your_wallet_id&coin_type=eth" \ -H "HMAC:your token" \ -X GET var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/detail/?wallet_id=your_wallet_id', method: "get", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": { "wallet_id": "2cc5abb2b9932ca1ec5513ad1a9685f9", "wallet_name": "TestSeven", "address": "0x32FfC556A1E1deEfE1084A0E276501d0B347bb39", "balance": "999999999997000", "send_max": "0", "send_day_max": "0", "send_day_limit": 0, "freeze_overtime": 0 } } HTTP Request

GET https://testnet.sectoken.io/wallet/eth/detail/

请求参数 参数名 参数类型 必填 说明 wallet_id string 是 钱包id coin_type string 否 币种,默认为eth,可以指定为平台支持的erc20 token,如erc20_ht,erc20_usdt 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data object 返回内容 data 参数 参数名 参数类型 说明 wallet_id string 钱包id wallet_name string 钱包名 address string 钱包地址 balance string 钱包余额,单位为最小单位 send_max string 单次转账上限,"0"为无上限 send_day_limit integer 单日转账次数上限,0为无上限 send_day_max string 单日转账上限,"0"为无上限 freeze_overtime integer 钱包冻结截止时间,0为未冻结 查看钱包列表import requests requests.get( url="https://testnet.sectoken.io/wallet/eth/wallet_list/?page=1, headers={"HMAC": "your token"} ) curl "https://testnet.sectoken.io/wallet/eth/wallet_list/?page=1" \ -X GET \ -H "HMAC:your token" var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/wallet_list/?page=1', method: "get", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": [ { "wallet_name": "TestSeven", "wallet_id": "2cc5abb2b9932ca1ec5513ad1a9685f9", "address":"0x32FfC556A1E1deEfE1084A0E276501d0B347bb39", "create_time": "2019-10-09T02:27:18.465" } ] } HTTP Request

GET https://testnet.sectoken.io/wallet/eth/wallet_list/

请求参数 参数名 参数类型 必填 说明 page integer 是 页码,默认显示所有钱包列表 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data array 返回内容 data 参数 参数名 参数类型 说明 wallet_id string 钱包的id wallet_name string 钱包名 address string 钱包地址 create_time string 钱包创建时间 钱包地址列表import requests requests.get( url="https://testnet.sectoken.io/wallet/eth/addr_list/, headers={"HMAC": "your token"}, params={"wallet_id": "your wallet id", "page": 1} ) curl "https://testnet.sectoken.io/wallet/eth/addr_list/?wallet_id=your_wallet_id&page=1" \ -X GET \ -H "HMAC:your token" \ var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/addr_list/?wallet_id=a399855021ccdbc2820de597952a54c9', method: "get", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": ["0x32FfC556A1E1deEfE1084A0E276501d0B347bb39"] } HTTP Request

GET https://testnet.sectoken.io/wallet/eth/addr_list/

请求参数 参数名 参数类型 必填 说明 wallet_id string 是 钱包id page integer 否 页码,默认获取全部地址,如果填写,每页获取10条数据 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data array 返回内容,每一个元素是一个地址 生成收款地址

生成收款地址,所需成本大约 420000 gas

该地址收到eth后,自动转账到归属钱包的多签地址

该地址收到ERC20代币后,需要手动触发归集转账到归属钱包的多签地址

该地址不能对外部的任何地址进行支出转账

import requests requests.post( url="https://testnet.sectoken.io/wallet/eth/derive/", headers={"HMAC": "your token"}, json={"wallet_id": "your wallet id"} ) curl "https://testnet.sectoken.io/wallet/eth/derive/" \ -X POST \ -H "Content-Type:application/json" \ -H "HMAC:your token" \ -d '{"wallet_id": "your wallet id"}' var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/derive/', method: "post", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, body: JSON.stringify({ 'wallet_id': 'a399855021ccdbc2820de597952a54c9', }) }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": {"address": "0xcf58D46C7b760c298fAFBf75D70D9E641f8357d7", "txid":"0xc99629ab2d9472aea0450f3f881e07d5c3d8d9444131430df2e7fb3a95dbb44b" } } HTTP Request

POST https://testnet.sectoken.io/wallet/eth/derive/

请求参数 参数名 参数类型 必填 说明 wallet_id string 是 钱包id 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data object 返回内容 data 参数 参数名 参数类型 说明 address string 派生的新地址 txid string 派生地址返回的交易单id 查询地址余额import reqeusts requests.get( url="https://testnet.sectoken.io/wallet/eth/addr_balance/", headers={"HMAC": "your token"}, params={"address": "your address"} ) curl "https://testnet.sectoken.io/wallet/eth/addr_balance/?address=your_address" \ -X GET \ -H "HMAC:your token" var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/addr_balance/?address=0x215a21ec6562b08e0123147AbD28f3Dd7B2c565f', method: "get", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": { "balance": "312672375000000000" } } HTTP Request

GET https://testnet.sectoken.io/wallet/eth/addr_balance/

请求参数 参数名 参数类型 必填 说明 address string 是 查询余额的地址 coin_type string 否 币种,默认为eth,可以指定为平台支持的erc20 token,如erc20_ht,erc20_usdt 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data object 返回内容 data 参数 参数名 参数类型 说明 balance string 地址的余额,最小单位 资金归集

把收款地址上的ERC20代币转账到归属钱包的多签地址

一个收款地址的ERC20代币归集转账操作所需成本大约 32000 gas

import requests requests.post( url="https://testnet.sectoken.io/wallet/eth/flush/", headers={"HMAC": "your token"}, json={"wallet_id": "your wallet id", "coin_type":"erc20_usdt", "derive_address":"your receipt address" } ) curl "https://testnet.sectoken.io/wallet/eth/flush/" \ -X POST \ -H "Content-Type:application/json" \ -H "HMAC:your token" \ -d '{"wallet_id": "your wallet id", "coin_type": "erc20_usdt", "derive_address":"your receipt address"}' var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/flush/', method: "post", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, body: JSON.stringify({ 'wallet_id': 'fbff0c98881b4b20b3368e1fa1e64b85', 'coin_type': 'erc20_usdt', 'derive_address': '0xff727C39b97947B18118D0866fc4761ed55dbacD' }) }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": {"txids":["0xc99629ab2d9472aea0450f3f881e07d5c3d8d9444131430df2e7fb3a95dbb44b"]} } HTTP Request

POST https://testnet.sectoken.io/wallet/eth/flush/

请求参数 参数名 参数类型 必填 说明 wallet_id string 是 钱包id coin_type string 是 币种,只支持当前平台支持的 erc20 token derive_address string 否 当前钱包的收款地址,如果不填写则默认对钱包内全部收款地址进行归集 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data object 返回内容 Data参数 参数名 参数类型 说明 txids array 交易单id列表 构建交易单impor requests requests.post( url="https://testnet.sectoken.io/wallet/eth/dotx/", headers={"HMAC": "your token"}, json={ "wallet_id": "your wallet id", "to_address": "destination address", "value": "1000000000", "coin_type": "eth", "feerate": 1, } ) curl "https://testnet.sectoken.io/wallet/eth/dotx/" \ -X POST \ -H "Content-Type:application/json" \ -H "HMAC:your token" \ -d '{"wallet_id": "your wallet id", "to_address": "destination address", "value": "1000000000", "coin_type": "eth", "feerate": 1}' var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/dotx/', method: "post", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, body: JSON.stringify({ 'wallet_id': '788da6819ec461dd99accdeffc1831e4', 'to_address': '0x05C1FcBF26b0FA3f6A107dd3D496FaCcb55644DA', 'value': '2', 'coin_type': 'eth', 'feerate': 1 }) }, function (error, response, body) { console.log(body) } );

返回示例

{ "code":200, "data":{ "data": "3851e44d1d73cedce686642211588a1137f21d01fe772c88ab49ff7fc6fa4911", "privkey": "" } } HTTP Request

POST https://testnet.sectoken.io/wallet/eth/dotx/

请求参数 参数名 参数类型 必填 说明 wallet_id string 是 钱包id to_address string 是 收款地址 value string 是 转账金额,最小单位 coin_type string 否 币种,默认为eth,可以指定为平台支持的erc20 token,如erc20_ht,erc20_usdt feerate integer 否 转账速度,1快速0普通,默认为0 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data object 返回内容 data 参数 参数名 参数类型 说明 data string 待签名的字段 privkey string 创建钱包时上传的私钥密文,如果创建钱包时没有上传,则为空 构建批量转账交易单impor requests requests.post( url="https://testnet.sectoken.io/wallet/eth/batch_dotx/", headers={"HMAC": "your token"}, json={ "wallet_id": "your wallet id", "outputs": [ {"address":"recipient address", "value":"1000"}, {"address":"recipient address", "value":"1000"} ], "value": "1000000000", "coin_type": "eth", "feerate": 1, } ) curl "https://testnet.sectoken.io/wallet/eth/dotx/" \ -X POST \ -H "Content-Type:application/json" \ -H "HMAC:your token" \ -d '{"wallet_id": "your wallet id", "outputs": [{"address":"recipient address", "value":"1000"}{"address":"recipient address", "value":"1000"}], "coin_type": "eth", "feerate": 1}' var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/dotx/', method: "post", headers: { 'Content-Type': 'application/json', 'HMAC': 'your token', }, body: JSON.stringify({ 'wallet_id': 'your wallet id', "outputs": [ {"address":"recipient address", "value":"1000"}, {"address":"recipient address", "value":"1000"} ], 'coin_type': 'eth', 'feerate': 1 }) }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": { "data": "f863808459682f008252089405c1fcbf26b0fa3f6a107dd3d496faccb55644da01801ca05aa02750896c8581304a7e0de9f2a4f7674ef275a033c006ce5f70cd58ca7b6ba07998e979e5c918d4e0a1b047788c43636ed3627d265a875c464f1c1c8ede095e", "privkey": "" } } HTTP Request

POST https://testnet.sectoken.io/wallet/eth/batch_dotx/

请求参数 参数名 参数类型 必填 说明 wallet_id string 是 钱包id outputs array 是 转账目标地址及金额信息 coin_type string 否 币种,默认为eth,可以指定为平台支持的erc20 token,如erc20_ht,erc20_usdt feerate integer 否 转账速度,1快速,0普通,默认为0 Outputs 请求参数 参数名 参数类型 必填 说明 address string 是 目标地址 value string 是 转账金额 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data object 返回的待签名的字段 data 参数 参数名 参数类型 说明 data string 未签名的交易 privkey string 创建钱包时提交的privkey字段,未提交则返回空字符串 提交签名信息

用户在本地对交易单进行签名,并将签名后的数据提交Sectoken,Sectoken对签名进行验证后,将交易广播到区块链上

import requests requests.post( url="https://testnet.sectoken.io/wallet/eth/send/" headers={"HMAC": "your token"}, json={ "wallet_id": "your wallet id", "data": "3851e44d1d73cedce686642211588a1137f21d01fe772c88ab49ff7fc6fa4911", "signature": "signature data" } ) curl "https://testnet.sectoken.io/wallet/eth/send/" \ -X POST \ -H "Content-Type:application/json" \ -H "HMAC:your token" \ -d '{"wallet_id": "your wallet id", "data": "3851e44d1d73cedce686642211588a1137f21d01fe772c88ab49ff7fc6fa4911", "signature": "0b1e9cf915d8d04592c81e4accf06194ca3069c38c53ecf2fabe149e3612284532369a161599127a44e85b5a7039c9426ddd516273b07ddb82a11e10800ae01a00"}' var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/send/', method: "post", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, body: JSON.stringify({ 'data': '14f0ed21fdca0f3e9a11116fddd550e79c47926bef44935c70e39163433c49a5', 'signature': '43ee124edabb6dc45d20c2cb55ea3cef96c875d7b1c5b2da48907d4f51f1f6f43ed75e55da0595567b5a3e70e7b8ab0e666321e842fcce2d5a270d5bb243fc8b01', 'wallet_id': '788da6819ec461dd99accdeffc1831e4', }) }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": { "is_sent": true } } HTTP Request

POST https://testnet.sectoken.io/wallet/eth/send/

请求参数 参数名 参数类型 必填 说明 wallet_id string 是 钱包id data string 是 待签名字段 signature string 是 签名结果 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data object 返回内容 data 参数 参数名 参数类型 说明 is_sent bool 是否广播。如果签名数量未达到广播限制,说明未最终签名成功,返回false,否则返回true。 txid string 交易单的txid,可以在区块浏览器上进行查找 获取合约部署状态import requests reqeuests.get( url="https://testnet.sectoken.io/wallet/eth/receipt/", params={ "address": "0xa5f84276010fabe2017f9ecceea4720b8eca5527" } ) curl "https://testnet.sectoken.io/wallet/eth/receipt/?address=0xa5f84276010fabe2017f9ecceea4720b8eca5527" \ -H "HMAC:your token" var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/receipt/?address=your_address', method: "get", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": {"status": true} } HTTP Request

GET https://testnet.sectoken.io/wallet/eth/receipt/

请求参数 参数名 参数类型 必填 说明 address string 是 合约地址 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data object 返回内容 data 参数 参数名 参数类型 说明 status bool 合约部署状态 合约确认需要大约15秒 获取ERC20代币列表

获取平台支持的ETH ERC20 token列表

import requests requests.get( url="https://testnet.sectoken.io/wallet/eth/coin_types/", headers={"HMAC": "your token"} ) curl "https://testnet.sectoken.io/wallet/eth/coin_types/" \ -H "HMAC:your token" var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/receipt/?address=your_address', method: "get", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": [ {"coin_type": "ERC20_MT", "contract_address": "0x37aef616A9d15563F3267b3776f9FFDdb8797879", "decimal": 3}, {"coin_type": "ERC20_HT", "contract_address": "0x0f2Dac5Bfdc7Ce4aea8dfb9a085703a92998aA48", "decimal": 4}, {"coin_type": "ERC20_JLL", "contract_address": "0x7e326A29f182544E3982CDB3E0e24e19412CA34D", "decimal": 18}, {"coin_type": "ERC20_FFA", "contract_address": "0xa227E7eEecc599600c767CcE8D5e0B40eB5A860e", "decimal": 18}, {"coin_type": "ERC20_KOZ", "contract_address": "0x9d79bb99b41dbe5a3cf037ae8e8d22425c8e823d", "decimal": 18}, {"coin_type": "ERC20_USDT", "contract_address": "0x41BaE6D3389Faf27762CFcCEdd003C6242197f5f", "decimal": 6} ] } HTTP Request

GET https://testnet.sectoken.io/wallet/eth/coin_types/

无请求参数返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data array 返回内容 data 参数 参数名 参数类型 说明 coin_type string 币种 decimal integer 精度 新增钱包WebHook

添加 一个 webhook, 当触发指定类型的事件的时候,Sectoken 将会向指定的URL发送一条请求信息,每个钱包最多绑定10条webhook

import requests requests.post( url="https://testnet.sectoken.io/wallet/eth/webhook_add/", headers={"HMAC": "your token"}, json={ "wallet_id": "your wallet id", "url": "https://your.server.com/webhook", "label": "test callback", "type": "deposit", "token": "erc20_ht" } ) curl "https://testnet.sectoken.io/wallet/eth/webhook_add/" \ -H "HMAC:your token" \ -H "Content-Type:application/json" \ -X POST \ -d '{"wallet_id": "your wallet id", "url":"https://your.server.com/webhook", "label":"test callback", "type":"deposit", "token": "erc20_ht"}' var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/webhook_add/', method: "post", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, body: JSON.stringify({ 'wallet_id': '788da6819ec461dd99accdeffc1831e4', 'url': 'https://your.server.com/webhook', 'type': 'deposit', 'label': 'test callback', 'token': 'erc20_ht' }) }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": { "callbackid": "da0e3f3530cb7f63695d8eaad351fdc1" } } HTTP Request

POST https://testnet.sectoken.io/wallet/eth/webhook_add/

请求参数 参数名 参数类型 必填 说明 wallet_id string 是 钱包id url string 是 接受通知的url地址, 必须使用HTTP或者HTTPS协议 type string 是 交易类型, deposit or withdraw label string 否 webhook 的标签 token string 否 erc20_usdt,erc20_usdt, default eth 返回参数 Parameter Name Type Description code integer Status code. Successful return 200. Others are Error Codes data object Response data. Data 参数 Parameter Name Type Description callbackid string callback id 获取钱包WebHook

获取钱包的Webhook设置列表

import requests requests.get( url="https://testnet.sectoken.io/wallet/eth/webhook_list/", headers={"HMAC": "your token"}, params={"wallet_id": "your wallet id"} ) curl "https://testnet.sectoken.io/wallet/eth/webhook_list/?wallet_id=your_wallet_id" \ -H "HMAC:your token" \ -X GET var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/webhook_list/?wallet_id=your_wallet_id', method: "get", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": [ { "label": "test callback", "url": "https://your.server.com/webhook", "type": "deposit", "token": "erc20_ht", "callbackid": "da0e3f3530cb7f63695d8eaad351fdc1", "wallet_id": "your wallet id" "create_time": "2019-10-31T19:54:22.977" } ] } HTTP Request

GET https://testnet.sectoken.io/wallet/eth/webhook_list/

请求参数 参数名 参数类型 必填 说明 wallet_id string 是 钱包ID Response Parameters 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data array 返回内容 Data参数 参数名 参数类型 说明 label string label of the webhook url string URL to fire the webhook to type string Transfer status, deposit or withdraw token string erc20 token name or eth callbackid string callback id wallet_id string 钱包ID create_time string Create Timestamp 删除钱包WebHook

删除钱包的Webhook

import requests requests.post( url="https://testnet.sectoken.io/wallet/eth/webhook_del/", headers={"HMAC": "your token"}, json={ "callbackid": "your callback id", } ) curl "https://testnet.sectoken.io/wallet/eth/webhook_del/" \ -H "HMAC:your token" \ -H "Content-Type:application/json" \ -X POST \ -d '{"callbackid": "your callback id"}' var request = require('request'); request({ url: 'https://testnet.sectoken.io/wallet/eth/webhook_del/', method: "post", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, body: JSON.stringify({ 'callbackid': 'b43e128d3950dcd6afe32473b8c768a1', }) }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, } HTTP Request

POST https://testnet.sectoken.io/wallet/eth/webhook_del/

请求参数 Parameter Name Type Required Description callbackid string Yes callback id 返回参数 Parameter Name Type Description code integer Status code. Successful return 200. Others are Error Codes 交易Callback通知

当用户钱包发生交易时,会向指定的url发送HTTP POST请求,请求头content-type为application/json。

此url由用户指定,用户须部署服务接收HTTP POST请求。同时需先添加钱包Webhook

请求body示例

Deposit Example: { "wallet_id": "6004e156344ec27cad24a8df5bbaa5ab", "txid": "0x2b4675aff7efad0c7dcee09a943f9cc501402f18b67393a47cdcfa887f5ab2da", "height": 4340000, "dst_address": "0x759ac48a2754be136d495da1a826200ab1c911f2", "src_address": "0x8cb9e65d6a771424dfabbda4221bdb446d9183fe", "type": "deposit", "timestamp": 1872340000, "value": "10000000000", "coin_type": "ETH", "decimal": 18, "callbackid": "fa5dc2025e79c37b8656ef4b89619d9d" } Withdraw Example: { "wallet_id": "6004e156344ec27cad24a8df5bbaa5ab", "txid": "0x2b4675aff7efad0c7dcee09a943f9cc501402f18b67393a47cdcfa887f5ab2da", "height": 4340000, "dst_address": "0x759ac48a2754be136d495da1a826200ab1c911f2", "src_address": "0x8cb9e65d6a771424dfabbda4221bdb446d9183fe", "type": "withdraw", "timestamp": 1872340000, "value": "10000000000", "coin_type": "ETH", "decimal": 18, "callbackid": "fa5dc2025e79c37b8656ef4b89619d9d" } 参数说明 参数名 参数类型 说明 wallet_id string 用户钱包id txid string 交易id height integer 交易所在区块高度 dst_address string 交易目的地址 src_address string 交易来源地址 type string 交易状态,withdraw 转出 deposit收款 timestamp integer 交易时间戳 value string 交易金额 coin_type string 币种类型 decimal integer 精度 获取交易记录import requests requests.get(url="https://testnet.sectoken.io/flow/record/eth/", headers={"HMAC": "your token"}, params={ "wallet_id": "b81d38f5f250c36a05da0d0e1f9bd394", "year": "2019", "month": "10" } ) curl "https://testnet.sectoken.io/flow/record/eth/?wallet_id=b81d38f5f250c36a05da0d0e1f9bd394&year=2019&month=10" \ -H "HMAC:your token" var request = require('request'); request({ url: 'https://testnet.sectoken.io/flow/record/eth/?wallet_id=788da6819ec461dd99accdeffc1831e4&&year=2019&&month=12', method: "get", headers: { 'Content-Type': 'application/json', 'HMAC': 'MTdmYWM4ZmMyZjk3YmZhNTkzZTdhNWYyMjk1MTE1ZTk=', }, }, function (error, response, body) { console.log(body) } );

返回示例

{ "code": 200, "data": [ { "txid": "0xab5e867f7246ac484d79d9d5c73fbdf7a96227ec0d1c5f18340a860d4bf6cb72", "src_address": "0xcc6620eACfFe84e936285b167F0D2c7C24155363", "dst_address": "0xa2465290580A948063B713cFf09dD550e4C4E3DB", "value": "10000", "timestamp": 1572259477, "type": "withdraw", "height": 5278224, "coin_type": "ETH", "decimal": 18 } ] } HTTP Request

GET https://testnet.sectoken.io/flow/record/eth/

请求参数 参数名 参数类型 必填 说明 wallet_id string 是 钱包id year string 是 年份 month string 是 月份 day string 否 日期 返回参数 参数名 参数类型 说明 code integer 返回码,200成功,其他失败,请查看错误码 data array 返回内容 data 参数 参数名 参数类型 说明 txid string 交易单id src_address string 交易来源地址 det_address string 交易目的地址 value string 交易金额 timestamp integer 交易时间 type string 交易状态,withdraw 转出 deposit收款 height integer 交易区块高度 decimal integer 精度 错误码

当发生错误时返回的错误码

错误码 错误说明 4000 请求参数错误 5000 未知错误, 请联系Sectoken 4201 钱包不存在 4202 钱包冻结中 4204 钱包余额不足 4209 钱包激活码错误 4210 钱包Webhook数目超限 4401 非法操作 4402 此钱包不属于当前账户 4403 钱包个数达到上限 4404 用户权限不足 4503 不能转账给钱包自己 4504 签名错误 4506 无效公钥 4507 私钥密文必须base64 4508 Webhook不存在 4512 无法广播已经广播过的交易单 4601 当前用户没有费用地址 4602 费用地址余额不足 4605 ERC20 token未支持 4606 未确认的交易过多


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3