Guide

Vanilla JS

No framework needed. Phantom direct, Reown modal, or pure REST API.

Phantom / Solflare Direct

$npm install buff-protocol-sdk @solana/web3.jsCopy
app.ts
typescript
1import { Buff } from 'buff-protocol-sdk'
2
3const provider = (window as any).solana
4await provider.connect()
5
6const buff = new Buff({
7 apiKey: 'your-api-key',
8 plan: 'sprout',
9 investInto: 'BTC',
10})
11
12// Authenticate with wallet signature
13const msg = new TextEncoder().encode('Sign in to Buff')
14const { signature } = await provider.signMessage(msg, 'utf8')
15buff.setWalletAuth(provider.publicKey.toBase58(), btoa(String.fromCharCode(...signature)))
16
17// Get round-up instructions
18const { instructions, breakdown } = await buff.getWrapInstructions(
19 15.42, provider.publicKey.toBase58(), buffWalletPubkey
20)
21
22// Add instructions to your transaction and sign
23for (const ix of instructions) tx.add(ix)
24const signed = await provider.signTransaction(tx)
25// send signed transaction...
Note
All approaches produce identical results. The SDK is just an HTTP client for the buff.finance API. Choose based on your environment.