Skip to Content
TypeScript SDKCookbookCollect Donations

Collect Donations

When your users reclaim SOL through your integration, you can request that a percentage of the rebate is donated back to your project’s treasury. The donation is routed on-chain in the same transaction — your users see the split before they sign.

Donations apply to actions that produce a rebate — closing empty accounts, burning tokens/NFTs, and compressing.

Your project is determined by your API key. You don’t need to pass a project ID.

How it works

Set donationPercentage when calling buildTransactions. For each item that produces a rebate, the server splits it:

  • donationAmount = grossRebate × donationPercentage
  • netRebate = grossRebate - fees - donationAmount

Items with no rebate are unaffected. The donation lands in your project’s treasury address (configured in the Burn & Claim Dashboard).

Example

import { BurnerClient } from '@burnandclaim/sdk' const client = new BurnerClient({ sessionToken }) const { items } = await client.getWalletAssets(walletAddress) const selections = items .filter((item) => item.actions.length > 0) .map((item) => ({ type: item.type, address: item.address, action: item.actions[0], })) // Request a 10% donation from each reclaim const { transactions, totals } = await client.buildTransactions( walletAddress, { items: selections, donationPercentage: 0.1, } ) // Show the user what they'll receive vs. what goes to your project // totals.netRebate — lamports the user keeps // totals.donationAmount — lamports routed to your treasury // totals.fees — platform fee in lamports

Showing the split to your users

Use the totals from the build response to render a breakdown before the user signs:

function formatSplit(totals: { grossRebate: number netRebate: number donationAmount: number fees: number }) { const sol = (lamports: number) => (lamports / 1e9).toFixed(6) return { reclaimable: `${sol(totals.grossRebate)} SOL`, userReceives: `${sol(totals.netRebate)} SOL`, donation: `${sol(totals.donationAmount)} SOL`, platformFee: `${sol(totals.fees)} SOL`, } }

Per-transaction detail

Each BuiltTransaction includes its own donation breakdown, so you can show per-item detail if your UI needs it:

for (const tx of transactions) { const items = tx.includes .map((s) => `${s.type}:${s.address.slice(0, 8)}...`) .join(', ') // tx.grossRebate, tx.netRebate, tx.donationAmount }

Notes

  • donationPercentage is a decimal from 0 to 1 (e.g., 0.1 = 10%).
  • If omitted or set to 0, no donation is routed.
  • Your project’s treasury address must be configured in the Burn & Claim Dashboard for donations to land.
  • Donations are on-chain and verifiable — they happen in the same transaction as the reclaim.
  • Your users always see the split before signing. The SDK never moves funds without explicit wallet approval.
Last updated on