Client Package

@ckboost/client SDK

Overview

The @ckboost/client SDK provides a simple, type-safe way to integrate CKBoost acceleration services into your dApp. CKBoost reduces ckBTC conversion times from 1 hour (6 confirmations) to 7-10 minutes (1-2 confirmations) through a network of liquidity providers. We are planning to expend ckBoost and support other chain-key tokens (ckETH, in the future ckSOL, etc)

Key Features

  • πŸš€ Fast Integration: Simple API with just two main functions

  • πŸ“ TypeScript First: Full type safety and excellent developer experience

  • ⚑ Real-time Monitoring: Track boost request status changes

  • πŸ”’ Secure: Built on Internet Computer Protocol (ICP)

  • 🎯 dApp Ready: Designed specifically for frontend integration

Installation

npm install @ckboost/client
yarn add @ckboost/client
pnpm add @ckboost/client

Quick Start

API Reference

Client Initialization

ckTESTBTCClient

Creates a new client instance for ckTESTBTC (Bitcoin testnet).

Parameters:

Parameter
Type
Default
Description

config

ClientConfig

{}

Optional client configuration

ClientConfig:

Core Methods

generateDepositAddress()

Creates a new boost request and returns deposit information.

Parameters:

Returns:

getBoostRequest()

Retrieves detailed information about a specific boost request.

Parameters:

Parameter
Type
Description

requestId

string

The unique request identifier

Returns:

getPendingBoostRequests()

Retrieves all pending boost requests.

Utility Methods

getTokenConfig()

Returns the current token configuration.

Returns:

rawToTokenAmount()

Converts raw amount (satoshis) to token amount (ckTESTBTC).

tokenToRawAmount()

Converts token amount (ckTESTBTC) to raw amount (satoshis).

Types Reference

Enums

BoostStatus

SupportedToken

CKBoostErrorType

Response Types

ApiResponse<T>

All API methods return this discriminated union type:

Examples

Basic Integration

React Hook Integration

Complete dApp Integration

Error Handling

Error Types

The SDK provides specific error types to help you handle different scenarios:

Best Practices

  1. Always check the success property before accessing data

  2. Provide user-friendly error messages based on error types

  3. Implement retry logic for network errors

  4. Validate amounts before making requests

  5. Monitor request status until completion

Configuration

Canister IDs

The SDK includes the required canister IDs:

Network Configuration

For production applications, use the default configuration:

For development, you might want to use a local replica:

Monitoring and Real-time Updates

Polling Strategy

For production applications, implement efficient polling:

WebSocket Alternative

For real-time updates, consider implementing WebSocket connections to the backend canister (when available) instead of polling.

Troubleshooting

Common Issues

Import Errors

Type Errors

Make sure you have TypeScript configured properly:

Network Errors

If you're getting network errors:

  1. Check your internet connection

  2. Verify the ICP host URL is correct

  3. Ensure the canister IDs are valid

  4. Try increasing the timeout value

Support

Last updated