Learn to integrate, configure, and use the JavaScript SDK with code samples for seamless app development.
Try Cobo WaaS Skill in your AI coding assistant (Claude Code, Cursor, etc.). Describe your needs in natural language to auto-generate production-ready SDK code and debug faster đ
This guide introduces how to get started with using the Cobo WaaS 2.0 JavaScript SDK, which allows you to integrate the WaaS service into your existing application using the JavaScript programming language.To learn more about the initial setup steps necessary for utilizing the WaaS API, see Send your first request.You can go to GitHub to access the source code of the SDK.
Make sure Cobo Sales has provisioned your Cobo account and organization. To request access, contact Cobo Sales. If you are joining an existing organization, ask its admin to invite you.
The directory structure after installation is as follows:
waas2-js/ââ node_modules/ââ package.jsonââ package-lock.jsonââ (to be created later) index.js
If your project already has package.json and package-lock.json, you can directly copy them to the root directory and run npm install to pull dependencies.
Create a file index.js in the root directory and paste the following code into it.
The directory structure after installation is as follows:
waas2-js/ââ node_modules/ââ package.jsonââ package-lock.jsonââ (to be created later) index.js
If your project already has package.json and package-lock.json, you can directly copy them to the root directory and run npm install to pull dependencies.
Create a file index.js in the root directory and paste the following code into it.
// Initialize the default API clientconst apiClient = CoboWaas2.ApiClient.instance// Set the API secretapiClient.setPrivateKey("<YOUR_API_SECRET_IN_HEX>");
const CoboWaas2 = require("@cobo/cobo-waas2");// Initialize the API clientconst apiClient = CoboWaas2.ApiClient.instance;// Set the environment (development: Env.DEV, production: Env.PROD)apiClient.setEnv(CoboWaas2.Env.DEV);// Configure API Secret â replace <YOUR_PRIVATE_KEY> with your API SecretapiClient.setPrivateKey("<YOUR_PRIVATE_KEY>");// Create a WalletsApi instanceconst apiInstance = new CoboWaas2.WalletsApi();// Define query parametersconst opts = { wallet_type: "Custodial", // Wallet type: Custodial wallet wallet_subtype: "Asset", // Wallet subtype: Asset wallet chain_ids: "BTC,ETH", // Chain IDs to query: BTC, ETH limit: 10, // Limit the number of results to 10 entries before: "RqeEoTkgKG5rpzqYzg2Hd3szmPoj2cE7w5jWwShz3C1vyGmk1", // For pagination, optional after: "RqeEoTkgKG5rpzqYzg2Hd3szmPoj2cE7w5jWwShz3C1vyGSAk", // For pagination, optional};// Call the API to list supported chainsapiInstance.listSupportedChains(opts).then( (data) => { console.log("API called successfully. Returned data: " + data); }, (error) => { console.error(error); },);
const CoboWaas2 = require("@cobo/cobo-waas2");// Initialize the API clientconst apiClient = CoboWaas2.ApiClient.instance;// Set the environment (development: Env.DEV, production: Env.PROD)apiClient.setEnv(CoboWaas2.Env.DEV);// Configure API Secret â replace <YOUR_PRIVATE_KEY> with your API SecretapiClient.setPrivateKey("<YOUR_PRIVATE_KEY>");// Create a WalletsApi instanceconst apiInstance = new CoboWaas2.WalletsApi();// Define parameters for wallet creationconst opts = { CreateWalletParams: CoboWaas2.CreateWalletParams.constructFromObject({ name: "My WaaS 2.0 Wallet", // Wallet name wallet_type: "Custodial", // Wallet type: Custodial Wallets wallet_subtype: "Asset", // Wallet subtype: Asset Wallets }),};// Call the API to create a walletapiInstance.createWallet(opts).then( (data) => { console.log("API called successfully. Returned data: " + data); }, (error) => { console.error(error); },);
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.