Guide
Devnet Testing
Test the full Buff flow on Solana devnet before going to mainnet.
Switch to Devnet
devnet.ts
typescript
1const buff = new Buff({2 apiKey: "your-api-key",3 network: "devnet", // ← only change needed4 plan: "sprout",5 investInto: "USDC", // only SOL + USDC on devnet6})Available Tokens on Devnet
| Asset | Available | Mint |
|---|---|---|
| SOL | Yes | So1111...1112 (native) |
| USDC | Yes | 4zMMC9...cqmJh (devnet faucet) |
| BTC | No* | Maps to SOL on devnet |
| ETH | No* | Maps to SOL on devnet |
| USDT | No* | Maps to devnet USDC |
Note
wBTC and wETH don't exist on devnet. The SDK maps them to SOL/USDC for testing. Use investInto: "USDC" or "SOL" for realistic devnet tests.
Get Devnet SOL
Visit https://faucet.solana.com and paste your wallet address to get free devnet SOL.
Full Test Script
test-devnet.ts
typescript
1import { Buff } from "buff-protocol-sdk"2import { Connection, Keypair, Transaction, SystemProgram } from "@solana/web3.js"34const conn = new Connection("https://api.devnet.solana.com")5const user = Keypair.generate()67// Fund via airdrop (or use faucet.solana.com)8await conn.requestAirdrop(user.publicKey, 2e9)910// Init Buff with API key11const buff = new Buff({12 apiKey: "your-api-key",13 network: "devnet",14 plan: "tree",15 investInto: "USDC",16 investThreshold: 1, // low threshold for testing17})1819// Derive a wallet for the agent20const wallet = await buff.deriveWallet(someSignature)21console.log("Buff wallet:", wallet.pubkey)2223// Calculate a round-up for a $5.37 transaction24const breakdown = await buff.calculateRoundUp(5.37)25console.log("Round-up: $" + breakdown.roundUpUsd)2627// Get wrap instructions28const { instructions } = await buff.getWrapInstructions(29 5.37, user.publicKey.toBase58(), wallet.pubkey30)3132// Build transaction with round-up instructions33const tx = new Transaction()34tx.add(35 SystemProgram.transfer({36 fromPubkey: user.publicKey,37 toPubkey: Keypair.generate().publicKey,38 lamports: 1000000,39 })40)41for (const ix of instructions) tx.add(ix)4243// Sign and send...4445// Check portfolio (requires address parameter)46const portfolio = await buff.getPortfolio(wallet.pubkey)47console.log("Portfolio:", portfolio)4849// Check accumulator state50const accumulator = await buff.getAccumulator(wallet.pubkey)51console.log("Threshold reached:", accumulator.thresholdReached)