Documentation Index
Fetch the complete documentation index at: https://cobo.com/developers/llms.txt
Use this file to discover all available pages before exploring further.
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 🚀
Overview
This guide introduces how to get started with using the Cobo WaaS 2.0 Go SDK, which allows you to integrate the WaaS service into your existing application using the Go 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.
Prerequisites
Install the SDK
-
Create a Go project if you haven’t.
-
In the
go.mod file of your project, add the following line:
require github.com/CoboGlobal/cobo-waas2-go-sdk {VERSION}
Replace {VERSION} with the lastest version number, for example,
v1.2.0. Obtain the latest version number from the
GitHub repository.
-
Run the
go mod tidy command in a terminal or in your IDE to install the dependencies.
-
In your
main.go file, import the WaaS SDK as follows:
import (
...
coboWaas2 "github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2"
...
)
In the main function in your main.go file, configure the HTTP host by selecting the environment and provide your API secret.
The following code snippet shows the configuration for the development environment.
// Select the environment that you use and comment out the other line of code
ctx = context.WithValue(ctx, coboWaas2.ContextEnv, coboWaas2.DevEnv)
// ctx = context.WithValue(ctx, coboWaas2.ContextEnv, coboWaas2.ProdEnv)
ctx = context.WithValue(ctx, coboWaas2.ContextPortalSigner, crypto.Ed25519Signer{
// Replace `<YOUR_API_SECRET>` with your API secret.
Secret: "<YOUR_API_SECRET>",
})
Sample code
For operation-specific documentation and sample code, see the docs folder in the WaaS SDK GitHub repository.
List supported chains
package main
import (
"context"
"encoding/json"
"fmt"
"os"
coboWaas2 "github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2"
"github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2/crypto"
)
func main() {
// Specify the wallet type as Custodial Wallet.
walletType := coboWaas2.WalletType("Custodial")
// walletType, err := coboWaas2.NewWalletTypeFromValue("Custodial")
// Specify the wallet sub-type as Asset Wallet.
walletSubtype := coboWaas2.WalletSubtype("Asset")
// walletSubType, err := coboWaas2.NewWalletSubtypeFromValue("Asset")
// Use pagination parameters if needed
limit := int32(10)
before := ""
after := ""
configuration := coboWaas2.NewConfiguration()
apiClient := coboWaas2.NewAPIClient(configuration)
ctx := context.Background()
// Select the environment that you use and comment out the other line of code.
ctx = context.WithValue(ctx, coboWaas2.ContextEnv, coboWaas2.DevEnv)
// ctx = context.WithValue(ctx, coboWaas2.ContextEnv, coboWaas2.ProdEnv)
ctx = context.WithValue(ctx, coboWaas2.ContextPortalSigner, crypto.Ed25519Signer{
// Replace `<YOUR_API_SECRET>` with your own API secret.
Secret: "<YOUR_API_SECRET>",
})
// Call the List supported chains operation.
req := apiClient.WalletsAPI.ListSupportedChains(ctx).WalletType(walletType).WalletSubtype(walletSubtype)
if limit > 0 {
req = req.Limit(limit)
}
if before != "" {
req = req.Before(before)
}
if after != "" {
req = req.After(after)
}
resp, r, err := req.Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `WalletsAPI.ListSupportedChains``: %v\n", err)
if apiErr, ok := err.(*coboWaas2.GenericOpenAPIError); ok {
fmt.Fprintf(os.Stderr, "Error response: %s\n", string(apiErr.Body()))
}
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// Handle response from `ListSupportedChains`.
respJson, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `WalletsAPI.ListSupportedChains`: \n%s", string(respJson))
}
Create a wallet
package main
import (
"context"
"encoding/json"
"fmt"
"os"
coboWaas2 "github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2"
"github.com/CoboGlobal/cobo-waas2-go-sdk/cobo_waas2/crypto"
)
func main() {
// Specify the wallet type of the wallet to be created as Custodial Wallet.
walletType, err := coboWaas2.NewWalletTypeFromValue("Custodial")
if err != nil {
fmt.Fprintf(os.Stderr, "Error when new `WalletType``: %v\n", err)
return
}
// Specify the wallet sub-type of the wallet to be created as Asset Wallet.
walletSubType, err := coboWaas2.NewWalletSubtypeFromValue("Asset")
if err != nil {
fmt.Fprintf(os.Stderr, "Error when new `WalletSubType``: %v\n", err)
return
}
createWalletParams := coboWaas2.CreateWalletParams{
CreateCustodialWalletParams: coboWaas2.NewCreateCustodialWalletParams(
// Specify the name of the wallet to be created.
"My WaaS 2.0 Wallet for doc test",
*walletType,
*walletSubType,
)}
configuration := coboWaas2.NewConfiguration()
apiClient := coboWaas2.NewAPIClient(configuration)
ctx := context.Background()
// Select the environment tha you use and comment out the other line of code.
ctx = context.WithValue(ctx, coboWaas2.ContextEnv, coboWaas2.DevEnv)
// ctx = context.WithValue(ctx, coboWaas2.ContextEnv, coboWaas2.ProdEnv)
ctx = context.WithValue(ctx, coboWaas2.ContextPortalSigner, crypto.Ed25519Signer{
// Replace `<YOUR_API_SECRET>` with your own API secret.
Secret: "<YOUR_API_SECRET>",
})
// Call the Create wallet operation.
resp, r, err := apiClient.WalletsAPI.CreateWallet(ctx).CreateWalletParams(createWalletParams).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `WalletsAPI.CreateWallet``: %v\n", err)
if apiErr, ok := err.(*coboWaas2.GenericOpenAPIError); ok {
fmt.Fprintf(os.Stderr, "Error response: %s\n", string(apiErr.Body()))
}
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
return
}
// Handle response from `CreateWallet`.
respJson, _ := json.MarshalIndent(resp.GetActualInstance(), "", " ")
fmt.Fprintf(os.Stdout, "Response from `WalletsAPI.CreateWallet`: \n%s", string(respJson))
}