Guide

Svelte / SvelteKit

Integrate Buff with a wallet adapter or Reown.

Install

$npm install buff-protocol-sdkCopy

Store

buffStore.ts
typescript
1import { writable } from 'svelte/store'
2import { Buff } from 'buff-protocol-sdk'
3
4export const buffInstance = writable<Buff | null>(null)
5
6export async function initBuff(
7 pubkey: string,
8 signMessage: (msg: Uint8Array) => Promise<Uint8Array>,
9 apiKey: string
10) {
11 const buff = new Buff({
12 apiKey,
13 plan: 'sprout',
14 investInto: 'BTC',
15 })
16
17 // Authenticate with wallet signature
18 const msg = new TextEncoder().encode('Sign in to Buff')
19 const sig = await signMessage(msg)
20 buff.setWalletAuth(pubkey, Buffer.from(sig).toString('base64'))
21
22 buffInstance.set(buff)
23}
Note
Call initBuff() in onMount for client-side only initialization.