SDK
App SDK
Quick Start

Coffer Apps SDK Quick Start Guide

Installation

# Install core SDK
npm install @coffer-network/apps-sdk
 
# If using React, also install React SDK
npm install @coffer-network/apps-react-sdk

Basic Setup

1. Initialize SDK

import { Coffer } from '@coffer-network/apps-sdk';
 
const initializeWallet = async () => {
  // Initialize the SDK
  const coffer = await Coffer.init({
    origin: 'https://app.coffer.network'
  });
 
  // Connect to wallet
  await coffer.connect();
 
  return coffer;
};

2. Basic Wallet Operations

async function basicWalletOperations() {
  const coffer = await initializeWallet();
 
  // Get wallet address
  const walletInfo = await coffer.getAddress();
  console.log('Wallet Address:', walletInfo.address);
 
  // Get balance
  const balance = await coffer.getBalance();
  console.log('Wallet Balance:', balance);
}

3. Send a Transaction

async function sendTransaction(recipientAddress: string, amount: number) {
  const coffer = await initializeWallet();
  
  try {
    const tx = await coffer.createTransaction({
      originAddress: (await coffer.getAddress()).address,
      destinationAddresses: [{
        address: recipientAddress,
        amount: amount // Amount in BTC
      }],
      asset: "BITCOIN",
      assetType: "btc",
      networkType: BitcoinNetwork.Mainnet,
      txFeeRate: 1 // sat/vB
    });
 
    console.log('Transaction created:', tx.id);
    return tx;
  } catch (error) {
    console.error('Transaction failed:', error);
    throw error;
  }
}