Skip to content

CoboGlobal/cobo-waas2-java-sdk

Repository files navigation

cobo-waas2-java-sdk

Cobo Wallet as a Service 2.0

  • API version: 1.0.0
    • Generator version: 7.6.0

The Cobo Wallet-as-a-Service (WaaS) 2.0 API is the latest version of Cobo’s WaaS API offering. It enables you to access Cobo’s full suite of crypto wallet technologies with powerful and flexible access controls. By encapsulating complex security protocols and streamlining blockchain interactions, this API allows you to concentrate on your core business activities without worrying about the safety of your assets. The WaaS 2.0 API presents the following key features:

  • A unified API for Cobo’s all four wallet types
  • Support for 80+ chains and 3000+ tokens
  • A comprehensive selection of webhook events
  • Flexible usage models for MPC Wallets, including Organization-Controlled Wallets and User-Controlled Wallets
  • Programmatic control of smart contract wallets such as Safe{Wallet} with fine-grained access controls
  • Seamlessly transfer funds across multiple exchanges, including Binance, OKX, Bybit, Deribit, and more

For more information about the WaaS 2.0 API, see Introduction to WaaS 2.0.

For more information, please visit https://www.cobo.com/waas

Automatically generated by the OpenAPI Generator

Requirements

Building the API client library requires:

  1. Java 1.8+
  2. Maven (3.8.3+)/Gradle (7.2+)

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn clean deploy

Refer to the OSSRH Guide for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>com.cobo.waas2</groupId>
  <artifactId>cobo-waas2</artifactId>
  <version>1.8.1</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

  repositories {
    mavenCentral()     // Needed if the 'cobo-waas2' jar has been published to maven central.
    mavenLocal()       // Needed if the 'cobo-waas2' jar has been published to the local maven repo.
  }

  dependencies {
     implementation "com.cobo.waas2:cobo-waas2:1.8.1"
  }

Callback/Webhook Server Demo

A server demo for callback and webhook was implemented at src/main/java/com/cobo/waas2/demo. Run this demo with command:

mvn spring-boot:run

or

./gradlew bootRun

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/cobo-waas2-1.8.1.jar
  • target/lib/*.jar

Getting Started

Initiate the API client

The ApiClient class is designed to configure and interact with a web API. It supports the following main features:

  • Setting Private Key: You can set the private key using setPrivKey() for authentication. The method supports ED25519 keys by default, but can be customized for other key types as well.
  • Using a Custom Signer: If you want more control over the signing process, you can pass a custom signer object using the setSigner() method.
  • Setting Environment: You can switch between different environments (e.g., development, production) using setEnv().

Here’s an example of how to use the ApiClient:

public class Main {
    public static void main(String[] args) {
        ApiClient client = new ApiClient();

        // Set a private key with default ED25519 key type
        String privKey = "your-private-key-in-hex";
        client.setPrivKey(privKey);

        // Alternatively, set a private key with a custom key type
        client.setPrivKey(privKey, "SECP256K1");

        // Set a signer
        Signer signer = new LocalEd25519Signer(privKey);
        client.setSigner(signer);

        // for dev environment
        client.setEnv(Env.DEV);
        // for production environment
        client.setEnv(Env.PROD);

        // Now you can use the client to make API requests
        // Example: client.doSomething();
    }
}

In certain scenarios, the private key may be restricted from export, such as when it is stored in AWS Key Management Service (KMS). In such cases, please pass in a custom implementation using the ApiSigner interface:

import com.cobo.waas2.auth.Signer;
new Signer() {
    @Override
    public String sign(byte[] message) {
        return null;
    }

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

Call api methods

Please follow the installation instruction and execute the following Java code:

// Import classes:
import com.cobo.waas2.ApiClient;
import com.cobo.waas2.ApiException;
import com.cobo.waas2.Configuration;
import com.cobo.waas2.model.*;
import com.cobo.waas2.api.WalletsApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    // for dev environment
    // defaultClient.setEnv(Env.DEV);
    // for production environment
    // defaultClient.setEnv(Env.PROD);
    defaultClient.setPrivKey("<YOUR_API_PRIVATE_KEY_IN_HEX>");
    WalletsApi apiInstance = new WalletsApi();
    WalletType walletType = WalletType.fromValue("Custodial");
    WalletSubtype walletSubtype = WalletSubtype.fromValue("Asset");
    String chainIds = "BTC,ETH";
    Integer limit = 10;
    String before = "";
    String after = "";
    try {
      ListSupportedChains200Response result = apiInstance.listSupportedChains(walletType, walletSubtype, chainIds, limit, before, after);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling WalletsApi#listSupportedChains");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Documentation for API Endpoints

All URIs are relative to https://api.dev.cobo.com/v2

Class Method HTTP request Description
AddressBooksApi listAddressBooks GET /address_books List address book entries
DevelopersApi getApiKeyInfo GET /developers/api_key_info Get API key information
DevelopersApi listCallbackMessages GET /developers/callback_messages List all callback messages
DevelopersApi retryCallbackMessage POST /developers/callback_messages/{message_id}/retry Retry callback message
DevelopersWebhooksApi createWebhookEndpoint POST /webhooks/endpoints Register webhook endpoint
DevelopersWebhooksApi getWebhookEndpointById GET /webhooks/endpoints/{endpoint_id} Get webhook endpoint information
DevelopersWebhooksApi getWebhookEventById GET /webhooks/endpoints/{endpoint_id}/events/{event_id} Retrieve event information
DevelopersWebhooksApi listWebhookEndpoints GET /webhooks/endpoints List webhook endpoints
DevelopersWebhooksApi listWebhookEventDefinitions GET /webhooks/events/definitions Get webhook event types
DevelopersWebhooksApi listWebhookEventLogs GET /webhooks/endpoints/{endpoint_id}/events/{event_id}/logs List webhook event logs
DevelopersWebhooksApi listWebhookEvents GET /webhooks/endpoints/{endpoint_id}/events List all webhook events
DevelopersWebhooksApi retryWebhookEventById POST /webhooks/endpoints/{endpoint_id}/events/{event_id}/retry Retry event
DevelopersWebhooksApi triggerTestWebhookEvent POST /webhooks/events/trigger Trigger test event
DevelopersWebhooksApi updateWebhookEndpointById PUT /webhooks/endpoints/{endpoint_id} Update webhook endpoint
OAuthApi getToken GET /oauth/token Get Org Access Token
OAuthApi refreshToken POST /oauth/token Refresh Org Access Token
StakingsApi createClaimActivity POST /stakings/activities/claim Create claim activity
StakingsApi createStakeActivity POST /stakings/activities/stake Create stake activity
StakingsApi createUnstakeActivity POST /stakings/activities/unstake Create unstake activity
StakingsApi createWithdrawActivity POST /stakings/activities/withdraw Create withdraw activity
StakingsApi getStakingActivityById GET /stakings/activities/{activity_id} Get staking activity details
StakingsApi getStakingById GET /stakings/{staking_id} Get staking position details
StakingsApi getStakingEstimationFee POST /stakings/estimate_fee Estimate staking fees
StakingsApi getStakingEstimationFeeV2 POST /stakings/estimate_fee_v2 Estimate staking fees v2
StakingsApi getStakingPoolById GET /stakings/pools/{pool_id} Get staking pool details
StakingsApi listStakingActivities GET /stakings/activities List staking activities
StakingsApi listStakingPools GET /stakings/pools List staking pools
StakingsApi listStakings GET /stakings List staking positions
TransactionsApi broadcastSignedTransactions POST /transactions/broadcast Broadcast signed transactions
TransactionsApi cancelTransactionById POST /transactions/{transaction_id}/cancel Cancel transaction
TransactionsApi checkLoopTransfers GET /transactions/check_loop_transfers Check Cobo Loop transfers
TransactionsApi createContractCallTransaction POST /transactions/contract_call Call smart contract
TransactionsApi createMessageSignTransaction POST /transactions/message_sign Sign message
TransactionsApi createTransferTransaction POST /transactions/transfer Transfer token
TransactionsApi dropTransactionById POST /transactions/{transaction_id}/drop Drop transaction
TransactionsApi estimateFee POST /transactions/estimate_fee Estimate transaction fee
TransactionsApi getTransactionById GET /transactions/{transaction_id} Get transaction information
TransactionsApi listTransactions GET /transactions List all transactions
TransactionsApi resendTransactionById POST /transactions/{transaction_id}/resend Resend transaction
TransactionsApi speedupTransactionById POST /transactions/{transaction_id}/speedup Speed up transaction
TravelRuleApi getTransactionLimitation GET /travel_rule/transaction/limitation Retrieve transaction limitations
TravelRuleApi listSupportedCountries GET /travel_rule/transaction/countries List supported countries
TravelRuleApi submitDepositTravelRuleInfo POST /travel_rule/transaction/deposit/travel_rule_info Submit Travel Rule information for deposits
TravelRuleApi submitWithdrawTravelRuleInfo POST /travel_rule/transaction/withdraw/travel_rule_info Submit Travel Rule information for withdrawals
WalletsApi checkAddressChainsValidity GET /wallets/check_address_chains_validity Check address validity across chains
WalletsApi checkAddressValidity GET /wallets/check_address_validity Check address validity
WalletsApi checkAddressesValidity GET /wallets/check_addresses_validity Check addresses validity
WalletsApi createAddress POST /wallets/{wallet_id}/addresses Create addresses in wallet
WalletsApi createWallet POST /wallets Create wallet
WalletsApi deleteWalletById POST /wallets/{wallet_id}/delete Delete wallet
WalletsApi getChainById GET /wallets/chains/{chain_id} Get chain information
WalletsApi getMaxTransferableValue GET /wallets/{wallet_id}/max_transferable_value Get maximum transferable value
WalletsApi getTokenById GET /wallets/tokens/{token_id} Get token information
WalletsApi getWalletById GET /wallets/{wallet_id} Get wallet information
WalletsApi listAddresses GET /wallets/{wallet_id}/addresses List wallet addresses
WalletsApi listEnabledChains GET /wallets/enabled_chains List enabled chains
WalletsApi listEnabledTokens GET /wallets/enabled_tokens List enabled tokens
WalletsApi listSupportedChains GET /wallets/chains List supported chains
WalletsApi listSupportedTokens GET /wallets/tokens List supported tokens
WalletsApi listTokenBalancesForAddress GET /wallets/{wallet_id}/addresses/{address}/tokens List token balances by address
WalletsApi listTokenBalancesForWallet GET /wallets/{wallet_id}/tokens List token balances by wallet
WalletsApi listUtxos GET /wallets/{wallet_id}/utxos List UTXOs
WalletsApi listWallets GET /wallets List all wallets
WalletsApi lockUtxos POST /wallets/{wallet_id}/utxos/lock Lock UTXOs
WalletsApi unlockUtxos POST /wallets/{wallet_id}/utxos/unlock Unlock UTXOs
WalletsApi updateWalletById PUT /wallets/{wallet_id} Update wallet
WalletsExchangeWalletApi listAssetBalancesForExchangeWallet GET /wallets/{wallet_id}/exchanges/assets List asset balances
WalletsExchangeWalletApi listExchanges GET /wallets/exchanges List supported exchanges
WalletsExchangeWalletApi listSupportedAssetsForExchange GET /wallets/exchanges/{exchange_id}/assets List supported assets
WalletsExchangeWalletApi listSupportedChainsForExchange GET /wallets/exchanges/{exchange_id}/assets/{asset_id}/chains List supported chains
WalletsMpcWalletsApi cancelTssRequestById POST /wallets/mpc/vaults/{vault_id}/tss_requests/{tss_request_id}/cancel Cancel TSS request
WalletsMpcWalletsApi createKeyShareHolderGroup POST /wallets/mpc/vaults/{vault_id}/key_share_holder_groups Create key share holder group
WalletsMpcWalletsApi createMpcProject POST /wallets/mpc/projects Create project
WalletsMpcWalletsApi createMpcVault POST /wallets/mpc/vaults Create vault
WalletsMpcWalletsApi createTssRequest POST /wallets/mpc/vaults/{vault_id}/tss_requests Create TSS request
WalletsMpcWalletsApi deleteKeyShareHolderGroupById POST /wallets/mpc/vaults/{vault_id}/key_share_holder_groups/{key_share_holder_group_id}/delete Delete key share holder group
WalletsMpcWalletsApi getKeyShareHolderGroupById GET /wallets/mpc/vaults/{vault_id}/key_share_holder_groups/{key_share_holder_group_id} Get key share holder group information
WalletsMpcWalletsApi getMpcProjectById GET /wallets/mpc/projects/{project_id} Get project information
WalletsMpcWalletsApi getMpcVaultById GET /wallets/mpc/vaults/{vault_id} Get vault information
WalletsMpcWalletsApi getTssRequestById GET /wallets/mpc/vaults/{vault_id}/tss_requests/{tss_request_id} Get TSS request
WalletsMpcWalletsApi listCoboKeyHolders GET /wallets/mpc/cobo_key_share_holders List all Cobo key share holders
WalletsMpcWalletsApi listKeyShareHolderGroups GET /wallets/mpc/vaults/{vault_id}/key_share_holder_groups List all key share holder groups
WalletsMpcWalletsApi listMpcProjects GET /wallets/mpc/projects List all projects
WalletsMpcWalletsApi listMpcVaults GET /wallets/mpc/vaults List all vaults
WalletsMpcWalletsApi listTssRequests GET /wallets/mpc/vaults/{vault_id}/tss_requests List TSS requests
WalletsMpcWalletsApi updateKeyShareHolderGroupById PUT /wallets/mpc/vaults/{vault_id}/key_share_holder_groups/{key_share_holder_group_id} Update key share holder group
WalletsMpcWalletsApi updateMpcProjectById PUT /wallets/mpc/projects/{project_id} Update project name
WalletsMpcWalletsApi updateMpcVaultById PUT /wallets/mpc/vaults/{vault_id} Update vault name
WalletsSmartContractWalletsApi listSafeWalletDelegates POST /wallets/{wallet_id}/smart_contracts/delegates List Delegates

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

CoboAuth

  • Type: API key
  • API key parameter name: BIZ-API-KEY
  • Location: HTTP header

OAuth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://auth.cobo.com/authorize
  • Scopes:
    • custodial_asset_wallet:create: Create access to custodial asset wallets
    • custodial_asset_wallet:add: Generate address access to custodial asset wallets
    • custodial_asset_wallet:edit: Change wallet name access to custodial asset wallets
    • custodial_asset_wallet:withdraw: Withdraw access to custodial asset wallets
    • mpc_organization_controlled_wallet:create: Create access to MPC organization-controlled wallets
    • mpc_organization_controlled_wallet:add: Generate address access to MPC organization-controlled wallets
    • mpc_organization_controlled_wallet:edit: Change wallet name access to MPC organization-controlled wallets
    • mpc_organization_controlled_wallet:withdraw: Withdraw access to MPC organization-controlled wallets
    • mpc_organization_controlled_wallet:contract_call: Contract call access to MPC organization-controlled wallets
    • mpc_organization_controlled_wallet:message_sign: Message sign access to MPC organization-controlled wallets
    • mpc_organization_controlled_vault:manage: Create/Edit access to MPC organization-controlled vaults
    • mpc_organization_controlled_key_group:manage: Create/Edit/Delete access to MPC organization-controlled key groups
    • mpc_organization_controlled_tss_request:manage: Create/Cancel access to MPC organization-controlled tss requests
    • mpc_user_controlled_wallet:create: Create access to MPC user-controlled wallets
    • mpc_user_controlled_wallet:add: Generate address access to MPC user-controlled wallets
    • mpc_user_controlled_wallet:edit: Change wallet name access to MPC user-controlled wallets
    • mpc_user_controlled_wallet:withdraw: Withdraw access to MPC user-controlled wallets
    • mpc_user_controlled_wallet:contract_call: Contract call access to MPC user-controlled wallets
    • mpc_user_controlled_wallet:message_sign: Message sign access to MPC user-controlled wallets
    • mpc_user_controlled_project:manage: Create/Edit access to MPC user-controlled projects
    • mpc_user_controlled_vault:manage: Create/Edit access to MPC user-controlled vaults
    • mpc_user_controlled_key_group:manage: Create/Edit/Delete access to MPC user-controlled key groups
    • mpc_user_controlled_tss_request:manage: Create/Cancel access to MPC user-controlled tss requests
    • webhook:resend: Resend access to webhook events
    • webhook_url:edit: Create/Edit access to webhook urls

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Author

[email protected]