import jsonimport cobo_waas2from cobo_waas2.models.create_wallet_params import CreateWalletParamsfrom cobo_waas2.models.created_wallet_info import CreatedWalletInfofrom cobo_waas2.models.wallet_subtype import WalletSubtypefrom cobo_waas2.models.wallet_type import WalletTypefrom cobo_waas2.rest import ApiExceptionfrom pprint import pprint# Defining the host is optional and defaults to https://api.dev.cobo.com/v2# See configuration.py for a list of all supported configuration parameters.configuration = cobo_waas2.Configuration( api_private_key="<YOUR_API_SECRET>", host="https://api.dev.cobo.com/v2")# Enter a context with an instance of the API clientwith cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = cobo_waas2.WalletsApi(api_client) create_wallet_params = cobo_waas2.CreateWalletParams( actual_instance=cobo_waas2.CreateMpcWalletParams( name="<YOUR_WALLET_NAME>", wallet_type=WalletType.MPC, wallet_subtype=WalletSubtype.ORG_CONTROLLED, vault_id="<YOUR_VAULT_ID>" ) ) try: # Create a wallet api_response = api_instance.create_wallet(create_wallet_params=create_wallet_params) print("The response of WalletsApi->create_wallet:\n") print(json.dumps(api_response.to_dict(), indent=2)) except Exception as e: print("Exception when calling WalletsApi->create_wallet: %s\n" % e)
Sample code in Java
import com.cobo.waas2.ApiClient;import com.cobo.waas2.ApiException;import com.cobo.waas2.Configuration;import com.cobo.waas2.Env;import com.cobo.waas2.api.WalletsApi;import com.cobo.waas2.model.*;public class CreateWalletExample { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); // Use the development environment defaultClient.setEnv(Env.DEV); // Replace `<YOUR_API_SECRET>` with your API secret defaultClient.setPrivKey("<YOUR_API_SECRET>"); WalletsApi apiInstance = new WalletsApi(); try { CreateMpcWalletParams params = new CreateMpcWalletParams() .name("OCW Example Wallet Demo(Java)") .walletType(WalletType.MPC) .walletSubtype(WalletSubtype.ORG_CONTROLLED) .vaultId("<YOUR_VAULT_ID>"); CreatedWalletInfo result = apiInstance.createWallet(new CreateWalletParams(params)); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling WalletsApi#createWallet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } }}
import jsonimport cobo_waas2from cobo_waas2 import ( CreateAddressRequest, AddressEncoding,)configuration = cobo_waas2.Configuration( # Replace `<YOUR_API_SECRET>` with your API secret api_private_key="<YOUR_API_SECRET>", # Use the development environment host="https://api.dev.cobo.com/v2")# Enter a context with an instance of the API clientwith cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class wallet_api_instance = cobo_waas2.WalletsApi(api_client) try: # Generate two addresses on the Bitcoin testnet3 (XTN) chain using P2TR encoding api_response = wallet_api_instance.create_address( wallet_id="<Your Wallet ID>", create_address_request=CreateAddressRequest( chain_id="XTN", count=2, encoding=AddressEncoding.ENCODING_P2_TR ), ) print("The response of WalletsApi->create_address:") for address_info in api_response: print(json.dumps(address_info.to_dict(), indent=2)) except Exception as e: print("Exception when calling WalletsApi->create_address, %s\n", e)
Sample code in Java
import com.cobo.waas2.ApiClient;import com.cobo.waas2.ApiException;import com.cobo.waas2.Configuration;import com.cobo.waas2.Env;import com.cobo.waas2.api.WalletsApi;import com.cobo.waas2.model.AddressEncoding;import com.cobo.waas2.model.AddressInfo;import com.cobo.waas2.model.CreateAddressRequest;import java.util.List;import java.util.UUID;public class CreateAddressExample { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); // Use the development environment defaultClient.setEnv(Env.DEV); // Replace `<YOUR_API_SECRET>` with your API secret defaultClient.setPrivKey("<YOUR_API_SECRET>"); WalletsApi apiInstance = new WalletsApi(); try { UUID wallet_id = UUID.fromString("<YOUR_WALLET_ID>"); CreateAddressRequest params = new CreateAddressRequest() .chainId("XTN") .count(2) .encoding(AddressEncoding.BECH32); List<AddressInfo> result = apiInstance.createAddress(wallet_id, params); for (AddressInfo addressInfo : result) System.out.println(addressInfo); } catch (ApiException e) { System.err.println("Exception when calling WalletsApi#createAddress"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } }}
import jsonimport uuidimport cobo_waas2from cobo_waas2 import ( CreateAddressRequest, AddressEncoding, TransferParams, TransferSource, MpcTransferSource, WalletSubtype, TransferDestination, AddressTransferDestination, TransferDestinationType, AddressTransferDestinationAccountOutput,)configuration = cobo_waas2.Configuration( # Replace `<YOUR_API_SECRET>` with your API secret. api_private_key="<YOUR_API_SECRET>", # Use the development environment. host="https://api.dev.cobo.com/v2")# Enter a context with an instance of the API clientwith cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class transaction_api_instance = cobo_waas2.TransactionsApi(api_client) try: # List deposit transactions api_response = transaction_api_instance.list_transactions( types="Deposit", statuses="Confirming, Completed", wallet_ids="<YOUR_WALLET_ID>" ) print("The response of TransactionsApi->list_transactions:") print(json.dumps(api_response.to_dict(), indent=2)) except Exception as e: print("Exception when calling TransactionsApi->list_transactions, %s\n", e)
import jsonimport uuidimport cobo_waas2from cobo_waas2 import ( CreateAddressRequest, AddressEncoding, TransferParams, TransferSource, MpcTransferSource, WalletSubtype, TransferDestination, AddressTransferDestination, TransferDestinationType, AddressTransferDestinationAccountOutput,)configuration = cobo_waas2.Configuration( # Replace `<YOUR_API_SECRET>` with your API secret api_private_key="<YOUR_API_SECRET>", # Use the development environment host="https://api.dev.cobo.com/v2")# Enter a context with an instance of the API clientwith cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class transaction_api_instance = cobo_waas2.TransactionsApi(api_client) try: # Withdraw Bitcoin testnet3(XTN) tokens from the wallet api_response = transaction_api_instance.create_transfer_transaction( transfer_params=TransferParams( request_id=str(uuid.uuid4()), source=TransferSource( actual_instance=MpcTransferSource ( source_type=WalletSubtype.ORG_CONTROLLED, wallet_id="<YOUR_WALLET ID>", ) ), token_id="XTN", destination=TransferDestination( actual_instance=AddressTransferDestination( destination_type=TransferDestinationType.ADDRESS, account_output=AddressTransferDestinationAccountOutput( address="<TARGET_ADDRESS>", amount="<TRANSFER_AMOUNT>" ) ) ), category_names=["<CATEGORY_NAME>"], description="<DESCRIPTION>", ) ) print("The response of TransactionsApi->create_transfer_transaction:") print(json.dumps(api_response.to_dict(), indent=2)) except Exception as e: print("Exception when calling TransactionsApi->create_transfer_transaction, %s\n", e)
Sample code in Java
import com.cobo.waas2.ApiClient;import com.cobo.waas2.ApiException;import com.cobo.waas2.Configuration;import com.cobo.waas2.Env;import com.cobo.waas2.api.TransactionsApi;import com.cobo.waas2.model.*;import java.util.ArrayList;import java.util.List;import java.util.UUID;public class TransferExample { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); // Use the development environment defaultClient.setEnv(Env.DEV); // Replace `<YOUR_API_SECRET>` with your API secret defaultClient.setPrivKey("<YOUR_API_SECRET>"); TransactionsApi apiInstance = new TransactionsApi(); try { UUID walletId = UUID.fromString("<YOUR_WALLET_ID>"); TransferParams params = new TransferParams(); params.setRequestId("Demo" + UUID.randomUUID()); MpcTransferSource transferSource = new MpcTransferSource().sourceType(WalletSubtype.ORG_CONTROLLED).walletId(walletId); params.setSource(new TransferSource(transferSource)); params.setTokenId("XTN"); AddressTransferDestination addressTransferDestination = new AddressTransferDestination() .destinationType(TransferDestinationType.ADDRESS) .accountOutput(new AddressTransferDestinationAccountOutput() .address("<TARGET_ADDRESS>") .amount("<TRANSFER_AMOUNT>")); params.setDestination(new TransferDestination(addressTransferDestination)); List<String> categoryNames = new ArrayList<>(); categoryNames.add("<Category Example>"); params.categoryNames(categoryNames).description("<Description Example>"); CreateTransferTransaction201Response result = apiInstance.createTransferTransaction(params); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling TransactionsApi#createTransferTransaction"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } }}
import jsonimport uuidimport cobo_waas2from cobo_waas2 import ( CreateAddressRequest, AddressEncoding, TransferParams, TransferSource, MpcTransferSource, WalletSubtype, TransferDestination, AddressTransferDestination, TransferDestinationType, AddressTransferDestinationAccountOutput,)configuration = cobo_waas2.Configuration( # Replace `<YOUR_API_SECRET>` with your API secret. api_private_key="<YOUR_API_SECRET>", # Use the development environment. host="https://api.dev.cobo.com/v2")# Enter a context with an instance of the API clientwith cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class transaction_api_instance = cobo_waas2.TransactionsApi(api_client) try: # Get transaction by ID api_response = transaction_api_instance.get_transaction_by_id( transaction_id="<YOUR_TRANSACTION_ID>" ) print("The response of TransactionsApi->get_transaction_by_id:") print(json.dumps(api_response.to_dict(), indent=2)) except Exception as e: print("Exception when calling TransactionsApi->get_transaction_by_id, %s\n", e)
Sample code in Java
import com.cobo.waas2.ApiClient;import com.cobo.waas2.ApiException;import com.cobo.waas2.Configuration;import com.cobo.waas2.Env;import com.cobo.waas2.api.TransactionsApi;import com.cobo.waas2.model.TransactionDetail;import java.util.UUID;public class GetTransactionExample { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); // Use the development environment defaultClient.setEnv(Env.DEV); // Replace `<YOUR_API_SECRET>` with your API secret defaultClient.setPrivKey("<YOUR_API_SECRET>"); TransactionsApi apiInstance = new TransactionsApi(); try { UUID transactionId = UUID.fromString("<YOUR_TRANSACTION_ID>"); TransactionDetail result = apiInstance.getTransactionById(transactionId); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling TransactionsApi#getTransactionById"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } }}
import jsonimport cobo_waas2from cobo_waas2 import ( WalletType, WalletSubtype,)configuration = cobo_waas2.Configuration( # Replace `<YOUR_API_SECRET>` with your API secret. api_private_key="<YOUR_API_SECRET>", # Use the development environment. host="https://api.dev.cobo.com/v2")# Enter a context with an instance of the API clientwith cobo_waas2.ApiClient(configuration) as api_client: # Create an instance of the API class wallet_api_instance = cobo_waas2.WalletsApi(api_client) try: # List token balances api_response = wallet_api_instance.list_token_balances_for_wallet( wallet_id="<YOUR_WALLET_ID>", ) print(f"The response of WalletsApi->list_token_balances_for_wallet:") print(json.dumps(api_response.to_dict(), indent=2)) except Exception as e: print("Exception when calling WalletsApi->list_token_balances_for_wallet, %s\n", e)
Sample code in Java
import com.cobo.waas2.ApiClient;import com.cobo.waas2.ApiException;import com.cobo.waas2.Configuration;import com.cobo.waas2.Env;import com.cobo.waas2.api.WalletsApi;import com.cobo.waas2.model.ListTokenBalancesForAddress200Response;import java.util.UUID;public class ListTokenBalancesExample { public static void main(String[] args) { ApiClient defaultClient = Configuration.getDefaultApiClient(); // Use the development environment defaultClient.setEnv(Env.DEV); // Replace `<YOUR_API_SECRET>` with your API secret defaultClient.setPrivKey("<YOUR_API_SECRET>"); WalletsApi apiInstance = new WalletsApi(); try { UUID wallet_id = UUID.fromString("<YOUR_WALLET_ID>"); String tokenIds = null; Integer limit = 50; String before = null; String after = null; ListTokenBalancesForAddress200Response result = apiInstance.listTokenBalancesForWallet(wallet_id, tokenIds, limit, before, after); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling WalletsApi#listTokenBalancesForWallet"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } }}