Build your first wallet application with Cobo in 10 minutes
This content applies to WaaS 1.0 only. We highly recommend that you upgrade to WaaS 2.0.
This article provides an end-to-end demonstration of creating a crypto wallet application for your platform or exchange. Throughout the article, you will learn::
Make sure you have finished your wallet setup based on Quickstart. Before writing your first demo, make sure that the following actions have been completed:
You have pulled your preferred SDK for development.
Cobo SDKs have packaged RestClients to interact with Cobo Wallet-as-a-Service APIs. To start, you need to initialize these Clients
as well as the ApiSigner for API Authentication.Custodial Wallet
Copy
from cobo_custody.client import Clientfrom cobo_custody.config import DEV_ENVfrom cobo_custody.signer.local_signer import LocalSigner# input your API SECRETsigner = LocalSigner("YOUR_API_SECRET")client = Client(signer=signer, env=DEV_ENV, debug=True)
MPC Wallet
Copy
from cobo_custody.client import MPCClientfrom cobo_custody.config import DEV_ENVfrom cobo_custody.signer.local_signer import LocalSigner# input your API SECRETsigner = LocalSigner("YOUR_API_SECRET")mpc_client = MPCClient(signer=signer, env=DEV_ENV, debug=True)
Use the correct Client and Environment
Client is for custodial wallet, MPCClient is for MPC Co-managed and MPC Lite wallet. DEV_ENV is development environment, PROD_ENV is for production environment.
Now you are able to create your first deposit address. Let us take Goerli ETH as an example. Please make sure that you or your admin
have added GETH in the wallet. To verify, you can use Get Account Details
for Custodial Wallet or Get Wallet Supported Coins for MPC Wallets.Cusotidal Wallet
You can make a deposit transaction to your newly created GETH address from an external address.
After that, you can query the transaction by latest transaction time.Cusotidal Wallet
BBefore making the withdraw, you may want to find out the transaction fees. In Custodial Wallet, abs_estimate_fee in Get Coin Details
indicates the withdraw fees in fee_coin. In MPC Wallets, gas_price in Get Estimate Fee
indicates the on-chain real-time transaction fees.Cusotidal Wallet
Now you can create your first withdraw transaction, please use UUID for request_id to prevent any confusion in future reconcilation. From address is required in MPC wallets whereas exampted in Custodial wallet. Meanwhile, pay attention to amount value and decimal format of each coin (amount = abs_amount*10^decimal).
Here is an example of withdrawing 0.01 GETH to an external account:Cusotidal Wallet
Then you may use the request_id to query the transaction status. Please note that the transaction will only be confirmed once the on-chain confirmation blocks reach confirming_threshold.
Before that, you may use the GET /v1/custody/pending_transactions/
endpoint to query the details of a pending transaction under a Custodial Wallet. For an MPC Wallet, you may refer to the status field with code 501 PENDING_CONFIRMATION in any transactional APIs to retrieve the details of a pending transaction.
Prior to using any endpoints, however, you need to first head to Cobo Custody Web and enable the “Transaction Notification - Includes Block Confirmation Number” Status feature.
Failure to enable this feature will result in the inability to fetch transaction information. Do note that some transactions cannot be retrieved due to fast on-chain confirmations (e.g., TRON).Cusotidal Wallet