Guide
Vanilla JS
No framework needed. Phantom direct, Reown modal, or pure REST API.
Phantom / Solflare Direct
$
npm install buff-protocol-sdk @solana/web3.jsCopyapp.ts
typescript
1import { Buff } from 'buff-protocol-sdk'23const provider = (window as any).solana4await provider.connect()56const buff = new Buff({7 apiKey: 'your-api-key',8 plan: 'sprout',9 investInto: 'BTC',10})1112// Authenticate with wallet signature13const msg = new TextEncoder().encode('Sign in to Buff')14const { signature } = await provider.signMessage(msg, 'utf8')15buff.setWalletAuth(provider.publicKey.toBase58(), btoa(String.fromCharCode(...signature)))1617// Get round-up instructions18const { instructions, breakdown } = await buff.getWrapInstructions(19 15.42, provider.publicKey.toBase58(), buffWalletPubkey20)2122// Add instructions to your transaction and sign23for (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.