Installation

add dependency in composer.json

"require": {
    ...
    "cobo/cobo_custody": "0.2.10",
  }

Test

php phpunit.phar ClientTest.php

Usage

Initialize

Generate Key Pair

<?php
require 'vendor/autoload.php';

use Cobo\Custody\Config;
use Cobo\Custody\LocalSigner;
use Cobo\Custody\Client;
$key = LocalSigner::generateKeyPair();
echo "apiSecret:", $key['apiSecret'],"\n";
echo "apiKey:", $key['apiKey'];

Please refer to the link for how to use apiKey

Initialize RestClient

<?php
require 'vendor/autoload.php';

use Cobo\Custody\Config;
use Cobo\Custody\LocalSigner;
use Cobo\Custody\Client;

$client = new Client($signer, Config::DEVELOP, false);

Initialize ApiSigner

ApiSigner can be instantiated through $signer = new LocalSigner("secret key");

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

$client->getAccountInfo();

Get Coin Details

$client->getCoinDetails("ETH");

Get New Deposit Address

$client->newDepositAddress("BTC");

Batch New Deposit Address

$client->batchNewDepositAddress("ETH", 4);

Verify Deposit Address

$client->verifyDepositAddress("BTC", "3Qd8ZV4DWxMPK1HfitxccZXV2H8mCST3kM");

Batch Verify Deposit Address

$addresses = [
            "0x05325e6f9d1f0437bd78a72c2ae084fbb8c039ee",
            "0xe105a42297428575086387de415900a08765a8af",
            "0x641733cde30e99fe0d6082c2ed96601c37a1718b",
            "0xf3a4a281e92631cb06b53895b6db25c6ffcf7c3d"
        ];

        $client->batchVerifyDepositAddress("ETH", join(",", $addresses));

Verify Valid Address

$client->verifyValidAddress("BTC", "3Qd8ZV4DWxMPK1HfitxccZXV2H8mCST3kM");

Get Address History List

$client->getAddressHistoryList("ETH", 0, 5);

Loop Alliance

Check Loop Address Details

$client->checkLoopAddressDetails("ETH", "0x05325e6f9d1f0437bd78a72c2ae084fbb8c039ee");

Verify Loop Address List

$client->verifyLoopAddressList("ETH", "0xe7ebdc5bbb6c99cc8f7f2c1c83ff38aa6647f38a,0xe7ebdc5bbb6c99cc8f7f2c1c83ff38aa6647f38a");

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

$client->getTransactionDetails("20210422193807000343569000002370");

Get Transactions By Txid

$client->getTransactionsByTxid("0x5d5396c3992ed524bf68a22a7ab6ae503f0349354ad69bc5204d5214085d4e9f");

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

$client->getTransactionsById(["max_id"]=>"id*********")

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

$client->getTransactionsByTime();

Get Pending Transactions

$client->getPendingTransactions();

Get Pending Deposit Details

$client->getPendingDepositDetails("20200604171238000354106000006405");

Get Transaction History

$client->getTransactionHistory();

Withdrawal

Submit Withdraw Request

$client->withdraw("TETH",
            "request_id_" . time(),
            "0xb744adc8d75e115eec8e582eb5e8d60eb0972037",
            new BigInteger("1"));

Get Withdraw Information

$client->getWithdrawInfo("teth29374893624");

Staking

Get a Staking Product Details

$client->getStakingProductDetails($prooductId);

Get All Staking Product List

$client->getStakingProductList(null, "zh");

Stake

$client->stake($product_id, new BigInteger("100000"));

Unstake

$client->unstake($product_id, new BigInteger("100000"));

Get Staking Data

$client->getStakingData();

Get Unstaking Data

$client->getUnstakingData();

Get All Staking History

$client->getStakingHistory();