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 needed
4 plan: "sprout",
5 investInto: "USDC", // only SOL + USDC on devnet
6})

Available Tokens on Devnet

AssetAvailableMint
SOLYesSo1111...1112 (native)
USDCYes4zMMC9...cqmJh (devnet faucet)
BTCNo*Maps to SOL on devnet
ETHNo*Maps to SOL on devnet
USDTNo*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"
3
4const conn = new Connection("https://api.devnet.solana.com")
5const user = Keypair.generate()
6
7// Fund via airdrop (or use faucet.solana.com)
8await conn.requestAirdrop(user.publicKey, 2e9)
9
10// Init Buff with API key
11const buff = new Buff({
12 apiKey: "your-api-key",
13 network: "devnet",
14 plan: "tree",
15 investInto: "USDC",
16 investThreshold: 1, // low threshold for testing
17})
18
19// Derive a wallet for the agent
20const wallet = await buff.deriveWallet(someSignature)
21console.log("Buff wallet:", wallet.pubkey)
22
23// Calculate a round-up for a $5.37 transaction
24const breakdown = await buff.calculateRoundUp(5.37)
25console.log("Round-up: $" + breakdown.roundUpUsd)
26
27// Get wrap instructions
28const { instructions } = await buff.getWrapInstructions(
29 5.37, user.publicKey.toBase58(), wallet.pubkey
30)
31
32// Build transaction with round-up instructions
33const 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)
42
43// Sign and send...
44
45// Check portfolio (requires address parameter)
46const portfolio = await buff.getPortfolio(wallet.pubkey)
47console.log("Portfolio:", portfolio)
48
49// Check accumulator state
50const accumulator = await buff.getAccumulator(wallet.pubkey)
51console.log("Threshold reached:", accumulator.thresholdReached)