Installation

add dependency in package.json

  "dependencies": {
     ...
    "cobo-custody": "https://github.com/CoboGlobal/cobo-js-api/releases/download/v0.34.0/release.tgz"
  }

Test

yarn build
yarn test -env=develop/prod -secretKey=<yourApiSecret>

Usage

Initialize

Generate Key Pair

const { LocalSigner } = require("cobo-custody");

const keyPair = LocalSigner.newKeyPair();
console.log(keyPair);

Please refer to the link for how to use apiKey

Initialize RestClient

const { Client } = require("cobo-custody");
const { LocalSigner } = require("cobo-custody");
const { DEVELOP, PROD } = require("cobo-custody");
const client = new Client(API_SIGNER, DEVELOP, true);

Initialize ApiSigner

ApiSigner can be instantiated through

const { LocalSigner } = require("cobo-custody");
const signer = new LocalSigner(
  "e7e73fabdd9edb8bddf947954c400a63bf93edc57abf170544ec570757df5453"
);

In some cases, your private key cannot be exported, for example, your private key is in aws kms, you should pass in your own implementation by implements ApiSigner interface

Account

Check Account Details

const res = await client.getAccountInfo();

Get Coin Details

const res = await client.getCoinInfo("ETH");

Get New Deposit Address

const res = await client.newDepositAddress("BTC", true);

Batch New Deposit Address

const res = await client.batchNewDepositAddress("ETH", 4, true);

Verify Deposit Address

const res = await client.verifyDepositAddress(
  "ETH",
  "0x05325e6f9d1f0437bd78a72c2ae084fbb8c039ee"
);

Batch Verify Deposit Address

const res = await client.batchVerifyDepositAddress(
  "ETH",
  "0x05325e6f9d1f0437bd78a72c2ae084fbb8c039ee,0x05325e6f9d1f0437bd78a72c2ae084fbb8c039e1"
);

Verify Valid Address

let res = await client.verifyValidAddress(
  "ETH",
  "0x05325e6f9d1f0437bd78a72c2ae084fbb8c039ee"
);

Get Address History List

const res = await client.getAddressHistory("ETH", 0, 50, 0);

Loop Alliance

Check Loop Address Details

const res = await client.checkLoopAddressDetails(
  "ETH",
  "0xe7ebdc5bbb6c99cc8f7f2c1c83ff38aa6647f38a"
);

Verify Loop Address List

const res = await client.verifyLoopAddressList(
  "ETH",
  "0xe7ebdc5bbb6c99cc8f7f2c1c83ff38aa6647f38a,0x05325e6f9d1f0437bd78a72c2ae084fbb8c039ee"
);

Loop Transaction Explorer

To help your user to check the Loop transaction, we offer you an explorer, you may insert the following URL in your platform:https://loop.top/tx/[Loop_ID] e.g. https://loop.top/tx/L456e5cb652dcfe557a43fd9d8e48627

Transactions

Get Transaction Details

const res = await client.getTransactionDetail(
  "20210422193807000343569000002370"
);

Get Transactions By Txid

const res = await client.getTransactionsByTxId(
  "0x5d5396c3992ed524bf68a22a7ab6ae503f0349354ad69bc5204d5214085d4e9f"
);

Obtain the list of confirmed transactions through ID query(deposit&withdraw)

const res = await client.getTransactionsById({});

Obtain the list of confirmed transactions through time query(deposit&withdraw)

const res = await client.getTransactionsByTime({});

Get Pending Transactions

const res = await client.getPendingTransactions({});

Get Pending Deposit Details

const res = await client.getPendingDepositDetails(
  "20200604171238000354106000006405"
);

Withdrawal

Submit Withdraw Request

const res = await client.withdraw({
  coin: "TETH",
  request_id: "request_id_" + String(new Date().getTime()),
  address: "0xb744adc8d75e115eec8e582eb5e8d60eb0972037",
  amount: "1",
  memo: "cobo",
});

Get Withdraw Information

const res = await client.getWithdrawInfo("teth29374893624");

Staking

Get a Staking Product Details

let res = await client.getStakingProductList(productId, "en");

Get All Staking Product List

const res = await client.getStakingProductList();

Stake

res = await client.stake(productId, "1000000");

Unstake

res = await client.unstake(productId, "1000000");

Get Staking Data

const res = await client.getStakingData();

Get Unstaking Data

const res = await client.getStakingHistory({});

Get All Staking History

client.get_staking_history();