NAV Navbar
shell python

Introduction

https://testnet.sectoken.io/

The token id of USDT in the test network is 1

Get Fee Address

Get the fee address of current account. A new fee address will be created if not exists.

Cost address role:

Used to pay for multi-signed wallet transfers

When all USDT in the wallet is transferred out, the BTC balance of the wallet will be transferred to the fee address.

The fee address is recommended to be recharged above 100000 satoshi

import requests

requests.get(
    url="https://testnet.sectoken.io/wallet/usdt/fee/", 
    headers={"HMAC": "your token"}
)
curl "https://testnet.sectoken.io/wallet/usdt/fee/" \
    -X GET \
    -H "HMAC:your token" \

Response Samples

{
    "code": 200,
    "data": {
      "address": "2N91dXMR7p8ne2Asuy8vgkwZ4DtwVszeCDw",
      "confirmed": "1000000"
      "unconfirmed":"10000"
    }
}

HTTP Request

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

No Request Parameters

Response Parameters

Parameter Name Type Description
code integer Status code. Successful return 200. Others are Error Codes
data object Response data.

Data Parameters

Parameter Name Type Description
address string Fee address.
confirmed string confirmed btc amount (Minimum unit)
unconfirmed string unconfirmed btc amount (Minimum unit)

Create Multi-sign Wallet

Create a new USDT wallet for current account

import requests

requests.post(
    url="https://testnet.sectoken.io/wallet/usdt/create/", 
    headers={"HMAC": "your token"}, 
    json={
        "pubkeys": [
            "03a6725ab3589cb91b416706fb23fe3f0b179d9d46af95d36606dc03cc24b99ec2", 
            "0392bdf172b6aeba9d68c93d1adc22c10ea865caacf0f601a31e938e053b537845"
        ],
        "privkeys":[
          "Y1QxVGFIaFZEMXVOR21xVG1OakNUZ3J6WUo1OHZSVUNGNldxc0FZclZTckxFNEF3cXZBeQ==", 
         "Y05LaHlwbnBKWDZkWEt5QmJuN2k0WVo0YnhUN2hlUUxOSDdhRjVhN0JLblFIeDJSV3VqSg==", 
        ],
        "wallet_name": "your wallet name",
    }
)
curl "https://testnet.sectoken.io/wallet/usdt/create/" \
    -H "HMAC:your token" \
    -H "Content-Type:application/json" \
    -X POST \
    -d '{"pubkeys": ["03a6725ab3589cb91b416706fb23fe3f0b179d9d46af95d36606dc03cc24b99ec2", "0392bdf172b6aeba9d68c93d1adc22c10ea865caacf0f601a31e938e053b537845"], "privkeys": ["Y1QxVGFIaFZEMXVOR21xVG1OakNUZ3J6WUo1OHZSVUNGNldxc0FZclZTckxFNEF3cXZBeQ==", "Y05LaHlwbnBKWDZkWEt5QmJuN2k0WVo0YnhUN2hlUUxOSDdhRjVhN0JLblFIeDJSV3VqSg=="], "wallet_name": "your wallet name"}'

Response Samples

{
    "code": 200,
    "data": {
        "wallet_id": "926e4ac3939e351927cf11ef69005ddc",
        "activate_code": "352147",
        "server_pubkey": "xpub6AZMDpGgTSsnVxLt9YHE1uT8AF7KHUqQzAM7Fpe4qXpfGZFEcYpe9WRVKzpHFEi7n16h463FLAtQZ9LFeKXLNTwHCuRevoo58LBKFAjUZxK"
    }
}

HTTP Request

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

Request Parameters

Parameter Name Type Required Description
pubkeys array Yes Pubkey list
privkeys array Optional Privkey list
wallet_name string Yes Wallet name

Response Parameters

Parameter Name Type Description
code integer Status code. Successful return 200. Others are Error Codes
data object Response data.

Data Parameters

Parameter Name Type Description
wallet_id string Wallet id
activate_code string Activate code
server_pubkey string HD pubkey

Activate Wallet

import requests

requests.post(
    url="https://testnet.sectoken.io/wallet/usdt/activate/",
    headers={"HMAC": "your token"},
    json={
        "wallet_id": "your wallet id",
        "activate_code": "your activate code",
    } 
)
curl "https://testnet.sectoken.io/wallet/usdt/activate/" \
    -H "HMAC:your token" \
    -H "Content-Type:application/json" \
    -X POST \
    -d '{"wallet_id": "your wallet id", "activate_code": "your activate code"}'

Response Samples

{
    "code": 200,
    "data": {
        "address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
    }
}

HTTP Request

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

Request Parameters

Parameter Name Type Required Description
wallet_id string Yes Wallet id
activate_code string Yes Activate code

Response Parameters

Parameter Name Type Description
code integer Status code. Successful return 200. Others are Error Codes
data object Response data.

Data Parameters

Parameter Name Type Description
address string address of wallet

Get Wallet Details

import requests

requests.get(
    url="https://testnet.sectoken.io/wallet/usdt/detail/",
    headers={"HMAC": "your token"}, 
    params={"wallet_id": "your wallet id", "coin_type": "usdt"}
)
curl "https://testnet.sectoken.io/wallet/usdt/detail/?wallet_id=your_wallet_id" \
    -H "HMAC:your token" \
    -X GET    
{
    "code": 200,
    "data": {
        "wallet_id": "926e4ac3939e351927cf11ef69005ddc",
        "wallet_name": "UsdtTest",
        "address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
        "balance": "9990",
        "send_max": "0",
        "send_day_max": "0",
        "send_day_limit": 0,
        "freeze_overtime": 0
    }
}

HTTP Request

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

Request Parameters

Parameter Name Type Required Description
wallet_id string Yes Wallet id

Response Parameters

Parameter Name Type Description
code integer Status code. Successful return 200. Others are Error Codes
data object Response data.

Data Parameters

Parameter Name Type Description
wallet_id string Wallet id
wallet_name string Wallet name
address string address of wallet
balance string Balance. (Minimum unit)
send_max string Maximum amount per transfer. "0" is unlimited.
send_day_limit integer Maximum number of transfers per day. 0 is unlimited.
send_day_max string Maximum number of transfers per day. "0" is unlimited.
freeze_overtime integer Wallet freeze deadline. 0 is not frozen.

Get Wallet List

import requests

requests.get(
    url="https://testnet.sectoken.io/wallet/usdt/wallet_list/?page=1, 
    headers={"HMAC": "your token"}
)
curl "https://testnet.sectoken.io/wallet/usdt/wallet_list/?page=1" \
    -X GET \
    -H "HMAC:your token"

Response Samples

{
    "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/usdt/wallet_list/

Request Parameters

Parameter Name Type Required Description
page integer Optional Page number. Default get all addresses.

Response Parameters

Parameter Name Type Description
code integer Status code. Successful return 200. Others are Error Codes
data array Response data

Data Parameters

Parameter Name Type Description
wallet_id string Wallet id
wallet_name string Wallet name
address string address of wallet
create_time string Creation time of wallet

Build Transaction

When all USDT in the wallet is transferred out, the BTC balance of the wallet will be transferred to the fee address.

import requests

requests.post(
    url="https://testnet.sectoken.io/wallet/usdt/dotx/",
    headers={"HMAC": "your token"},
    json={
        "wallet_id": "your wallet id",
        "to_address": "destination address",
        "value": "1000000000",
        "feerate": 1,
        "memo":"abcdefg"
    }
)
curl "https://testnet.sectoken.io/wallet/usdt/dotx/" \
    -X POST \
    -H "Content-Type:application/json" \
    -H "HMAC:your token" \
    -d '{"wallet_id": "your wallet id", "to_address": "destination address", "value": "1000000000", "feerate": 1, "memo":"abcdefg"}'

Response Samples

{
  "code": 200,
  "data": {
    "unsigned_tx": {
      "inputs": [
        {
          "txid": "4d626a3304ff16bd9e8b563fe96817b14f43dc0bbd08d52d1dd48abd7d75b239",
          "index": 2,
          "value": "540"
        },
        {
          "txid": "565fa9d010a86a363bb14cd677958093056b0f2ff2703a7adf54e72e75c8cdbc",
          "index": 1,
          "value": "1000"
        }
      ],
      "scripts": [
        "522103a6725ab3589cb91b416706fb23fe3f0b179d9d46af95d36606dc03cc24b99ec2210392bdf172b6aeba9d68c93d1adc22c10ea865caacf0f601a31e938e053b5378452103a5d8b0d33032480c167478da2d2935d630e45626a5341ce99f1635485591d15e53ae",
        "522103a6725ab3589cb91b416706fb23fe3f0b179d9d46af95d36606dc03cc24b99ec2210392bdf172b6aeba9d68c93d1adc22c10ea865caacf0f601a31e938e053b5378452103a5d8b0d33032480c167478da2d2935d630e45626a5341ce99f1635485591d15e53ae"
      ],
      "outputs": [
        {
          "address": "2NBZYNybgWhdbwXLhEpraaUdBJ6qs8Pcwnz",
          "value": "614"
        },
        {
          "address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
          "value": "540"
        },
        {
          "address": "6f6d6e6900000000000000010000000000000a8c",
          "value": "0"
        }
      ]
    },
    "fee": 349,
    "privkey": "Y1QxVGFIaFZEMXVOR21xVG1OakNUZ3J6WUo1OHZSVUNGNldxc0FZclZTckxFNEF3cXZBeQ=="
  }
} 

HTTP Request

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

Request Parameters

Parameter Name Type Required Description
wallet_id string Yes Wallet id
to_address string Yes Destination address.
value string Yes Transfer amount. (Minimum unit).
memo string Optional Remark info, record into blockchain
feerate integer Optional Transfer speed. 1 is fast, 0 is normal. Default is 0.
total boolean Optional Send All Balance, default is False

Response Parameters

Parameter Name Type Description
code integer Status code. Successful return 200. Others are Error Codes
data object Response data.

Data Parameters

Parameter Name Type Description
unsigned_tx object Data for signature.
privkey string the string of encrypted privkey,if no this parameter when you created wallet,it's will be a null string

Submit Signature

Submit the signature result for the transaction id, and if the signature number is valid and reaches the broadcast limit, the transaction will be broadcast to the blockchain

import requests

requests.post(
    url="https://testnet.sectoken.io/wallet/usdt/send/"
    headers={"HMAC": "your token"},
    json={
        "wallet_id": "your wallet id",
        "signed_tx": "0b1e9cf915d8d04592c81e4accf06194ca3069c38c53ecf2fabe149e3612284532369a161599127a44e85b5a7039c9426ddd516273b07ddb82a11e10800ae01a00"
    }
)
curl "https://testnet.sectoken.io/wallet/usdt/send/" \
    -X POST \
    -H "Content-Type:application/json" \
    -H "HMAC:your token" \
    -d '{"wallet_id": "your wallet id", "signed_tx": "0b1e9cf915d8d04592c81e4accf06194ca3069c38c53ecf2fabe149e3612284532369a161599127a44e85b5a7039c9426ddd516273b07ddb82a11e10800ae01a00"}'

Response Samples

{
  "code": 200,
  "data": {
    "txid": "1c93e587fb3193969fb1f775835f07fb4517ffd24afd36df4b118ab52c9ba63f",
    "is_sent": true
  }
}

HTTP Request

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

Request Parameters

Parameter Name Type Required Description
wallet_id string Yes Wallet id
signed_tx string Yes Signature

Response Parameters

Parameter Name Type Description
code integer Status code. Successful return 200. Others are Error Codes
data object Response data.

Data Parameters

Parameter Name Type Description
is_sent bool Whether to broadcast.If the number of signatures does not reach the broadcast limit, it indicates that the final signature was not successful. Otherwise, it returns true.
txid string Transaction id

Add Wallet WebHook

Add a webhook that will result in an HTTP callback at the specified URL from Sectoken when events are triggered.

There is a limit of 10 webhooks per wallet.

import requests

requests.post(
    url="https://testnet.sectoken.io/wallet/usdt/webhook_add/", 
    headers={"HMAC": "your token"}, 
    json={
        "wallet_id": "your wallet id",
        "url": "https://your.server.com/webhook",
        "label": "test callback",
        "type": "deposit",
    }
)
curl "https://testnet.sectoken.io/wallet/usdt/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"}'

Response Samples

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

HTTP Request

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

Request Parameters

Parameter Name Type Required Description
wallet_id string Yes Wallet id
url string Yes URL to fire the webhook to, the protocol must be HTTP or HTTPS
type string Yes Transfer status. Transfer status, deposit or withdraw
label string Optional Label of the new webhook

Response Parameters

Parameter Name Type Description
code integer Status code. Successful return 200. Others are Error Codes
data object Response data.

Data Parameters

Parameter Name Type Description
callbackid string callback id

List Wallet WebHook

List webhooks set up on the wallet

import requests

requests.get(
    url="https://testnet.sectoken.io/wallet/usdt/webhook_list/", 
    headers={"HMAC": "your token"}, 
    params={"wallet_id": "your wallet id"}
)
curl "https://testnet.sectoken.io/wallet/usdt/webhook_list/?wallet_id=your_wallet_id" \
    -H "HMAC:your token" \
    -X GET

Response Samples

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

HTTP Request

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

Request Parameters

Parameter Name Type Required Description
wallet_id string Yes Wallet id

Response Parameters

Parameter Name Type Description
code integer Status code. Successful return 200. Others are Error Codes
data array Response data.

Data Parameters

Parameter Name Type Description
label string label of the webhook
url string URL to fire the webhook to
type string Transfer status, deposit or withdraw
token string Coin types
callbackid string callback id
wallet_id string Wallet id
create_time string Create Timestamp

Delete Wallet WebHook

Del a webhook.

import requests

requests.post(
    url="https://testnet.sectoken.io/wallet/usdt/webhook_del/", 
    headers={"HMAC": "your token"}, 
    json={
        "callbackid": "your callback id",
    }
)
curl "https://testnet.sectoken.io/wallet/usdt/webhook_del/" \
    -H "HMAC:your token" \
    -H "Content-Type:application/json" \
    -X POST \
    -d  '{"callbackid": "your callback id"}'

Response Samples

{
    "code": 200,
}

HTTP Request

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

Request Parameters

Parameter Name Type Required Description
callbackid string Yes callback id

Response Parameters

Parameter Name Type Description
code integer Status code. Successful return 200. Others are Error Codes

Transaction Callback

After making a transfer, Sectoken will make a POST request to a url specified by the user,A service designed by yourself should be bind to the url to deal with the request.Need to add the wallet Webhook first.

The content-type header of the request is application/json.

import requests
requests.get(
    url="http://your.server.com/diy/url",
    headers={"HMAC": "your token"},
    params={
        "wallet_id": "6004e156344ec27cad24a8df5bbaa5ab",
        "txid": "46ab8299ed14ba7d57b57210b7756d80f67b3db2448fd4d1f1fb78039e5bfd6d",
        "height": 1431122,
        "output": 
        [
            {
                "address": "2N4b5ham6n4y4gMkrN8R5sswvvmJdrGV3u7",
                "value": "1000000000"
            },
            {
                "address": "2N1DDUWKa3kdaKaPrPX5eZEMgFHxtU2JPmG",
                "value": "363"
            }                                     
        ], 
        "type": "withdraw",
        "timestamp": 1572510180,
        "coin_type": "BTC",
        "decimal": 8,
        "memo": "",
        "callbackid": "fa5dc2025e79c37b8656ef4b89619d9d"
    }
)
curl "http://your.server.com/diy/url" \  
    -X post -H "content-type:application/json" \
    -d '{"wallet_id": "6004e156344ec27cad24a8df5bbaa5ab","txid": "d1372a31c23a064953aa61144d1f37297cda7e0222c73fe428499fa36dcd8e3b","height": 4340000,"dst_address": "2NCZhNEVm2QJJmBwvL2JC7mpNavR8sJNNLm","src_address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN","type": "deposit","timestamp": 1872340000,"value": "10000000000","wallet_balance": "100000""coin_type": "USDT","decimal": 8,"callbackid": "fa5dc2025e79c37b8656ef4b89619d9d"'

request body

deposit Example:
{
    "wallet_id": "6004e156344ec27cad24a8df5bbaa5ab",
    "txid": "d1372a31c23a064953aa61144d1f37297cda7e0222c73fe428499fa36dcd8e3b",
    "height": 4340000,
    "dst_address": "2NCZhNEVm2QJJmBwvL2JC7mpNavR8sJNNLm",
    "src_address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
    "type": "deposit",
    "timestamp": 1872340000,
    "value": "10000",
    "coin_type": "USDT",
    "decimal": 8
}

withdraw Example:
{
    "wallet_id": "6004e156344ec27cad24a8df5bbaa5ab",
    "txid": "d1372a31c23a064953aa61144d1f37297cda7e0222c73fe428499fa36dcd8e3b",
    "height": 4340000,
    "dst_address": "2NCZhNEVm2QJJmBwvL2JC7mpNavR8sJNNLm",
    "src_address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
    "type": "withdraw",
    "timestamp": 1872340000,
    "value": "10000",
    "coin_type": "USDT",
    "decimal": 8
}

Parameters descriptions

Parameter Name Type Description
wallet_id string wallet_id
txid string Transaction id
height integer Block height
dst_address string Destination address
src_address string Source address
type string Transfer status, deposit or withdraw
timestamp integer Block confirmation time
value string Transfer amount
coin_type string coin type
decimal integer Coin balance decimal places
callbackid string Callback id

Get Transaction Records

import requests

requests.get(url="https://testnet.sectoken.io/flow/record/usdt/",
            headers={"HMAC": "your token"},
            params={
                "wallet_id": "b81d38f5f250c36a05da0d0e1f9bd394",
                "year": "2019",
                "month": "10"
            }
)
curl "https://testnet.sectoken.io/flow/record/usdt/?wallet_id=b81d38f5f250c36a05da0d0e1f9bd394&year=2019&month=10" \
    -H "HMAC:your token"
var request = require('request');
request({
        url: 'https://testnet.sectoken.io/flow/record/usdt/?wallet_id=your_wallet_id&&year=2019&&month=12',
        method: "get",
        headers: {
            'Content-Type': 'application/json',
            'HMAC': 'your token',
        },
    }, function (error, response, body) {
        console.log(body)
    }
);

Response Samples

{
  "code": 200,
  "data": [
    {
      "txid": "791cf3d20239523a21db332863b61c7728fadc3045f96cade72d4e509d1839f8",
      "src_address": "2N5JY64urDm63s8kBijvp4B8P7KZMxn33e9",
      "dst_address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
      "value": "2700",
      "timestamp": 1574244951,
      "type": "withdraw",
      "height": 1609149,
      "memo": "",
      "coin_type": "USDT",
      "decimal": 8
    },
    {
      "txid": "a62c383a41fd85fd5730a2c1e12e77389e40c63e1248415c5575e7b51eb7de3e",
      "src_address": "2N5JY64urDm63s8kBijvp4B8P7KZMxn33e9",
      "dst_address": "2NCHYvPEaYtoLQr7sNGSTWyJ91baPnAL3eN",
      "value": "300",
      "timestamp": 1574243041,
      "type": "withdraw",
      "height": 1609147,
      "memo": "",
      "coin_type": "USDT",
      "decimal": 8
    }
  ]
}

HTTP Request

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

Request Parameters

Parameter Name Type Required Description
wallet_id string Yes wallet_id
year string Yes year
month string Yes month
day string Optional day

Response Parameters

Parameter Name Type Description
code integer Status code. Successful return 200. Others are Error Codes
data array Response data

Data Parameters

Parameter Name Type Description
txid string Transaction id
src_address string Transaction source address
det_address string Transaction destination address
value string Transfer amount
timestamp integer Transfer time
type string Transfer status, deposit or withdraw
height integer Block height
decimal integer Coin balance decimal places
coin_type string Coin types

Error Codes

The error code returned when an error occurs

Error code Description
4000 Invalid params
5000 Unknown error, Please contact Sectoken.
4201 Wallet not exist
4202 Wallet frozen
4204 Wallet insufficient balance
4209 Activate code error
4210 The number of webhook reaches an upper limit
4401 Illegal operation
4402 The wallet not belong to the user
4403 The number of wallets reached the limit
4404 No operation permissions
4503 Can't transfer funds to yourself
4504 Signature error
4506 Invalid public key
4507 Private Key Must be base64 format
4508 Webhook not exist
4512 Can not send already sent transaction
4513 Unspent allready used
4601 There is no fee address for the current account
4602 Fee addr insufficient balance
4603 No unspent available