Skip to main content
Some links in this document may not be functional until all relevant documentation for MPC Wallets (User-Controlled Wallets) has been published.

Overview

This guide introduces how to get started with using the UCW SDK (iOS), which is required to implement your own MPC Wallets (User-Controlled Wallets), and allows you to integrate the UCW SDK into your Client App to interact with the Cobo TSS Relay. You can go to GitHub to access the source code of the UCW SDK.

Install the UCW SDK

You can install the UCW SDK as a dependency in a Swift package or an Xcode project.
  • Swift package
  • Xcode project
To install UCW SDK as a dependency in a Swift package, follow these instructions:
  1. Create a Swift package with Xcode, see Creating a standalone Swift package with Xcode.
  2. Add UCW SDK to the dependencies in your Package.swift file:
    dependencies: [
        .package(url: "https://github.com/CoboGlobal/cobo-ucw-sdk-ios")
    ]
    
    
  3. Add the following to the target:
    targets: [
        .target(
            name: "<project_name>",
            dependencies: ["UCWSDK"]
        )
    ]
    
    
  4. In the source file where you want to use UCW SDK, add the following:
    import UCWSDK
    

Code samples

This section demonstrates the implementation of steps directly involving the UCW SDK when creating a Main Group. For a complete guide on creating a Main Group or implementing your own MPC Wallets (User-Controlled Wallets), see Get started with MPC Wallets (User-Controlled Wallets). For operation-specific documentation and sample code, see UCW SDK operations on Developer Hub.
1

Initialize Secrets

This step corresponds to Step 1 under Complete the initial setup > Initialize UCW SDK in Get started with MPC Wallets (User-Controlled Wallets). See Initialize Secrets for the documentation of this operation.
let secrets = "secrets.db"
let passphrase = "d3hxNyoiAP@Lm!D7Qpo_hghdpgyc_r39"

Task {
   do {
       let nodeID = try await initializeSecrets(secretsFile: secrets, passphrase: passphrase)
       print(" TSS Node ID: \(nodeID)")
   } catch {
       print("Error: \(error)")
   }
}

2

Create UCW SDK

This step corresponds to Step 1 under Complete the initial setup > Create a Main Group in Get started with MPC Wallets (User-Controlled Wallets). See Create UCW for the documentation of this operation.
let secrets = "secrets.db"
let passphrase = "d3hxNyoiAP@Lm!D7Qpo_hghdpgyc_r39"
let sdkConfig = SDKConfig(env: Env.development, timeout: 30, debug: true)
var sdkInstance: UCW?
var connCode: ConnCode = .CodeUnknown
var connMessage: String? = ""

do {
    sdkInstance = try UCW(config: sdkConfig, secretsFile: secrets, passphrase: passphrase) { code, message in
        connCode = code
        connMessage = message
        print("Connection Code: \(connCode), Message: \(connMessage ?? "No message")")
    }
} catch {
    print("Error: \(error)")
}

3

Get TSS Node ID

This step corresponds to Step 3 under Complete the initial setup > Create a Main Group in Get started with MPC Wallets (User-Controlled Wallets). See Get TSS Node ID for the documentation of this operation.
do {
    if let nodeID = try sdkInstance?.getTSSNodeID() {
        print("TSS Node ID: \(nodeID)")
    } else {
        print("Failed to get TSS Node ID")
    }
} catch {
    print("Error: \(error)")
}

4

Get TSS requests

This step corresponds to Step 22 under Complete the initial setup > Create a Main Group in Get started with MPC Wallets (User-Controlled Wallets). See Get TSS requests for the documentation of this operation.
let tssRequestIDs = ["tss_request_id_01"]
Task {
    do {
        if let requests = try await sdkInstance?.getTSSRequests(tssRequestIDs: tssRequestIDs) {
            for request in requests {
                print("\(request)\n")
            }
        } else {
            print("Get no TSS request")
        }
    } catch {
        print("Error: \(error)")
    }
}

5

Approve TSS requests

This step corresponds to Step 27 under Complete the initial setup > Create a Main Group in Get started with MPC Wallets (User-Controlled Wallets). See Approve TSS requests for the documentation of this operation.
let tssRequestIDs = ["tss_request_id_01"]
do {
    try sdkInstance?.approveTSSRequests(tssRequestIDs: tssRequestIDs)
} catch {
    print("Error: \(error)")
}

6

Get TSS requests

This step corresponds to Step 30 under Complete the initial setup > Create a Main Group in Get started with MPC Wallets (User-Controlled Wallets). See Get TSS Requests for the documentation of this operation.
let tssRequestIDs = ["tss_request_id_01"]
Task {
    do {
        if let requests = try await sdkInstance?.getTSSRequests(tssRequestIDs: tssRequestIDs) {
            for request in requests {
                print("\(request)\n")
            }
        } else {
            print("Get no TSS request")
        }
    } catch {
        print("Error: \(error)")
    }
}

Feel free to share your feedback to improve our documentation!