SDK

Go SDK

Full Buff SDK for Go — stdlib-only core, no CGO.

Install

$go get github.com/buff-protocol/sdk-goCopy

Quick Start

main.go
typescript
1package main
2
3import (
4 "fmt"
5 buff "github.com/buff-protocol/sdk-go"
6)
7
8func main() {
9 // Calculate round-up
10 r := buff.CalculateRoundUp(27.63, 0.50, 1.0)
11 fmt.Printf("Round-up: $%.2f\n", r.RoundUpUsd) // $0.37
12
13 // Full breakdown
14 b := buff.CalculateFees(27.63, 150.0, 0.50)
15 fmt.Printf("Investing: $%.4f\n", b.UserInvestmentUsd)
16 fmt.Printf("Buff fee: $%.4f\n", b.BuffFeeUsd)
17
18 // Derive wallet
19 sig := make([]byte, 64) // from wallet signMessage
20 _, pubkey, _ := buff.DeriveWallet(sig)
21 fmt.Printf("Buff wallet: %x\n", pubkey)
22}

Functions

FunctionPurpose
CalculateRoundUp()Fixed-point round-up calculation
CalculateFees()Full fee breakdown with SOL conversion
DeriveWallet()SHA-256 + ed25519 keypair from signature
GetBuffFeePercent()Get fee tier for a round-up increment
Note
The Go SDK uses only the standard library (crypto/sha256, crypto/ed25519) for core functionality. No external dependencies for fee calculation and wallet derivation.