Installation

Step 1. Add the JitPack repository to your build file

gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

maven:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Step 2. Add the dependency

gradle:

dependencies {
    implementation 'com.github.CoboGlobal:cobo-java-api:v0.62'
}

maven:

<dependency>
    <groupId>com.github.CoboGlobal</groupId>
    <artifactId>cobo-java-api</artifactId>
    <version>v0.55</version>
</dependency>

Test

 ./gradlew test -DEnv=develop/prod -DApiSecret=<yourApiSecret>

Usage

Initialize

Generate Key Pair

import com.cobo.custody.api.client.impl.LocalSigner;

String[] key = LocalSigner.generateKeyPair();
String secretKey = key[0];
String apiKey = key[1];

Please refer to the link for how to use apiKey

Initialize RestClient

These can be instantiated through the corresponding factory method of CoboApiClientFactory

import com.cobo.custody.api.client.CoboApiClientFactory;
import com.cobo.custody.api.client.CoboApiRestClient;
import com.cobo.custody.api.client.config.CoboApiConfig;
import com.cobo.custody.api.client.config.Env;
import com.cobo.custody.api.client.impl.LocalSigner;

CoboApiRestClient client = CoboApiClientFactory.newInstance(
                new LocalSigner(apiSecret),
                Env.DEVELOP,
                false).newRestClient();

Initialize ApiSigner

ApiSigner can be instantiated through new LocalSigner("secretkey" )

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:


import com.cobo.custody.api.client.ApiSigner;
new ApiSigner() {
    @Override
    public String sign(byte[] message) {
        return null;
    }

    @Override
    public String getPublicKey() {
        return null;
    }
}

Account

Check Account Details

ApiResponse<OrgInfo> orgInfo = client.getOrgInfo()

Get Coin Details

ApiResponse<CoinInfo> coinInfo = client.getCoinInfo("ETH")

Get New Deposit Address

ApiResponse<Address> res = client.newAddress("ETH", false);

Batch New Deposit Address

ApiResponse<Address> res = client.newAddress("ETH", false);

Verify Deposit Address

ApiResponse<Address> res = client.addressInfo("ETH", "0x05325e6f9d1f0437bd78a72c2ae084fbb8c039ee");

Batch Verify Deposit Address

ApiResponse<List<InternalAddressInfo>> res = client.getInternalAddressInfoBatch("ETH", "0xe7ebdc5bbb6c99cc8f7f2c1c83ff38aa6647f38a,0xe7ebdc5bbb6c99cc8f7f2c1c83ff38aa6647f38a");

Verify Valid Address

ApiResponse<Boolean> res = client.isValidAddress("ETH", "0xf3a4a281e92631cb06b53895b6db25c6ffcf7c3d");

Get Address History List

ApiResponse<List<Address>> res = client.getAddressHistory("ETH");

Get Address History List With Page

ApiResponse<List<Address>> res = client.getAddressHistory("ETH" ,0, 50);

Get Address History List With Page Sort

ApiResponse<List<Address>> res = client.getAddressHistory("ETH" ,0, 50, SortFlagEnum.DESCENDING);

Loop Alliance

Check Loop Address Details

ApiResponse<InternalAddressInfo> res = client.getInternalAddressInfo("ETH", "0xe7ebdc5bbb6c99cc8f7f2c1c83ff38aa6647f38a");

Verify Loop Address List

List<String> list = new ArrayList<>();
        list.add("0x05325e6f9d1f0437bd78a72c2ae084fbb8c039ee");
        list.add("0xe105a42297428575086387de415900a08765a8af");
        list.add("0x641733cde30e99fe0d6082c2ed96601c37a1718b");
        list.add("0xf3a4a281e92631cb06b53895b6db25c6ffcf7c3d");

        ApiResponse<Addresses> res = client.addressesInfo("ETH", list);

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

ApiResponse<Transaction> res = client.getTransactionById("20210422193807000343569000002370");

Get Transactions By txId

ApiResponse<List<Transaction>> res = client.getTransactionByTxId("0x5d5396c3992ed524bf68a22a7ab6ae503f0349354ad69bc5204d5214085d4e9f");

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

ApiResponse<List<Transaction>> res = client.getTransactionsById(null, Side.Any, null, null, null, 2, null);

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

ApiResponse<List<Transaction>> res = client.getTransactionsByTime(null, Side.Any, null, 0, 0, 2, null);

Get Pending Transactions

ApiResponse<List<Transaction>> pendingTransactions = client.getPendingTransactions(null, Side.Any, null, null, 50);

Get Pending Deposit Details

ApiResponse<Transaction> res = client.getPendingTransaction("20200604171238000354106000006405");

Get Transaction History

ApiResponse<List<Transaction>> res = client.getTransactionHistory("ETH", Side.Any, null, null, null, 50, 0, System.currentTimeMillis(), null);

Withdrawal

Submit Withdraw Request

ApiResponse<String> res = client.withdraw("TETH",
                "api_request_id_8888888",
                "0xb744adc8d75e115eec8e582eb5e8d60eb0972037",
                "1", null, "true", null);

Get Withdraw Information

ApiResponse<Transaction> res = client.queryWithdrawInfo("teth29374893624");

Staking

Get a Staking Product Details

ApiResponse<List<StakingProduct>> res = client.getStakingProducts(null, Lang.CHINESE);

Get All Staking Product List

ApiResponse<List<StakingProduct>> res = client.getStakingProducts(null, Lang.CHINESE);

Stake

ApiResponse<Void> res = client.stake("159165", new BigInteger("1000000"));

Unstake

ApiResponse<Void> res = client.unstake("159165", new BigInteger("1000000"));

Get Staking Data

ApiResponse<List<StakingProduct>> res = client.getStakings(null, Lang.ENGLISG);

Get Unstaking Data

ApiResponse<List<Unstaking>> res = client.getUnstakings(null, Lang.ENGLISG);

Get All Staking History

ApiResponse<List<StakingHistory>> res = client.getStakingHistory(null, null, null, null, null);