Guide
Svelte / SvelteKit
Integrate Buff with a wallet adapter or Reown.
Install
$
npm install buff-protocol-sdkCopyStore
buffStore.ts
typescript
1import { writable } from 'svelte/store'2import { Buff } from 'buff-protocol-sdk'34export const buffInstance = writable<Buff | null>(null)56export async function initBuff(7 pubkey: string,8 signMessage: (msg: Uint8Array) => Promise<Uint8Array>,9 apiKey: string10) {11 const buff = new Buff({12 apiKey,13 plan: 'sprout',14 investInto: 'BTC',15 })1617 // Authenticate with wallet signature18 const msg = new TextEncoder().encode('Sign in to Buff')19 const sig = await signMessage(msg)20 buff.setWalletAuth(pubkey, Buffer.from(sig).toString('base64'))2122 buffInstance.set(buff)23}Note
Call initBuff() in onMount for client-side only initialization.