Guide

Devnet Testing

Test the full Buff flow on Solana devnet before going to mainnet.

Switch to Devnet

devnet.ts
typescript
1const buff = await Buff.init({
2 network: "devnet", // ← only change needed
3 platformId: "test",
4 signMessage: (msg) => wallet.signMessage(msg),
5 plan: "sprout",
6 investInto: "USDC", // only SOL + USDC on devnet
7})

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/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
11const buff = await Buff.init({
12 network: "devnet",
13 platformId: "test",
14 signMessage: async (msg) => {
15 // In a real app, use wallet adapter
16 const { sign } = await import("tweetnacl")
17 return sign.detached(msg, user.secretKey)
18 },
19 plan: "tree",
20 investInto: "USDC",
21 investThreshold: 1, // low threshold for testing
22})
23
24console.log("Buff wallet:", buff.getWalletAddress())
25
26// Simulate a $5.37 transaction
27const tx = new Transaction().add(
28 SystemProgram.transfer({
29 fromPubkey: user.publicKey,
30 toPubkey: Keypair.generate().publicKey,
31 lamports: 1000000,
32 })
33)
34
35const { transaction, breakdown } = await buff.wrap(tx, user.publicKey, {
36 txValueUsd: 5.37,
37})
38
39console.log("Round-up: $" + breakdown.roundUpUsd)
40console.log("Invested: $" + breakdown.userInvestmentUsd)
41
42// Check portfolio
43const portfolio = await buff.getPortfolio()
44console.log("Pending SOL:", portfolio.pendingSol)