Skip to main content

Quick Start

Get your first Bitcoin-backed loan in under 5 minutes.

Prerequisites

Before you begin, ensure you have:
  • Installed the SDK (npm install @satsterminal-sdk/borrow)
  • An API key from SatsTerminal
  • A Bitcoin wallet with signing capability

Full React integration example

The official Borrow SDK Example shows how these SDK concepts fit together in a production-style Next.js application. It covers Bitcoin wallet integration, BorrowProvider, session restoration, quote selection, workflow tracking, loan history, management actions, repayment, collateral withdrawal, and platform-wallet withdrawal. The example composes the individual Borrow UI registry components. It intentionally does not use the all-in-one BorrowApp, so its source is useful when you want to understand or customize the SDK integration layer.

Step 1: Initialize the SDK

Step 2: Optional Account Setup

Use setup() when you want to preload account state for dashboards. It is optional for borrowing because executeBorrow() derives the chain from the selected quote and prepares the required wallet/session state automatically:
setup() may prompt the user to sign with their Bitcoin wallet. If you skip setup, the first executeBorrow() call may prompt for the required signatures instead.

Step 3: Preview Fees Before Borrowing

If your UI needs to show fees up front, fetch quotes first and then request the fee breakdown for the selected quote:

Step 4: Execute and Track the Borrow

After the user selects a quote, execute that quote and track the resulting borrow workflow:

Step 5: Deposit Bitcoin

When onDepositReady fires, send the required Bitcoin to the deposit address: Deposit addresses are single-use and the quote remains locked for up to 6 hours. If the deposit is not received before that window ends, request a fresh quote and deposit address.

Step 6: Loan Complete

Once the deposit is confirmed and processed, the loan will be executed automatically. The borrowed stablecoins will be available in your smart account.

Complete Example

What’s Next?