Wire BOLD Scale into your platform
For client engineers: report qualified users, linked wallets and purchases to BOLD Scale from your server, with payloads, safe retries, testing and a TypeScript example.
Before you start
Your platform reports three things from its own server: a referred user who has qualified, a wallet the user links, and a purchase. BOLD Scale works out who referred whom, freezes the rate, holds the reward until it is safe and works out what each partner is owed.
Every call is a POST to https://fdyhcokgnymevgtixwuf.supabase.co/functions/v1/bold-refer with Content-Type: application/json, the header x-refer-key set to your property key, and a JSON body naming an action. The key is issued by BOLD with your program. Keep it on your server: anyone holding it can report conversions for your program.
Send {"action": "ping"} first. It answers with your property and whether every part of the reward engine is ready.
- Who referred them
- A shared link (boldstudios.io/refer/r/CODE) lands on your site with ?bvt= added. Keep that visit token with the new account, or the partner code the user typed, and send it as visit_token or code. A subject_ref BOLD has already seen is matched on its own.
- subject_ref
- Your own stable id for the referred user. Use the same value in every call about that person.
- Errors
- A refused call answers 400 or 409 with an error and, where useful, a message. A 503 with database_update_pending or rpc_unavailable is safe to retry a minute later.
1. A referred user qualifies
Report a user when they have qualified under your program rules, for example verified and active on several days. Never report a bare signup.
- action
- qualified
- Required
- program and subject_ref.
- Optional
- visit_token, code or partner_ref (who referred them), email (used to match the person and to check for self-referral), external_ref (defaults to qualified: plus the subject_ref), meta.
- Once per person
- A person earns one qualified reward ever. A repeat report records nothing new.
2. The user links a wallet
A wallet is linked only with the owner’s signature, so a copied address cannot claim someone else’s purchases. One wallet per user and one user per wallet within a program.
- Your server sends wallet.challenge with program, subject_ref and wallet (a Solana address). The answer has a nonce and a message, valid for 5 minutes.
- Your app asks the person’s wallet to sign that exact message. Phantom and Solflare return base58; base64 is accepted too.
- Your server sends wallet.link with the nonce and the signature. Each challenge links once. A used one answers challenge_used, a late one challenge_expired.
3. A referred user buys
- On-chain buy
- Send purchase.onchain with program and the transaction signature. BOLD reads the transaction from the chain itself, credits only the program token bought into a linked wallet, and ignores transfers between members. A transaction that is not final yet answers not_finalized; send it again a minute later.
- From an indexer
- Instead of calling per purchase, point a Solana indexer webhook (Helius or your own) at /functions/v1/bold-refer/webhook/solana?program=YOUR_PROGRAM with the webhook secret BOLD gives you. Every signature in it is re-read from the chain before anything is recorded.
- Off-chain buy
- Send purchase with program, subject_ref, external_ref (your order id) and amount_cents.
- Holds
- Purchase rewards wait out the program hold. Where the held-balance check is on, a sale of the bought tokens during the hold reduces the reward.
Safe retries
Retry freely. A purchase is keyed by program, kind and external_ref (the transaction signature for on-chain buys): the same report again answers replayed: true and records nothing. To take back a report, for a refund or a test, send reject with program, external_ref and kind.
Testing before launch
- Ask BOLD for a separate test program for your staging server, and use its name in program.
- Send ping, then one call of each kind with a test user, and check them in the BOLD Scale dashboard.
- Reject each test purchase by its external_ref when you are done, so nothing test-made is paid.
A TypeScript example
// Server side only. Never ship the property key to a browser or an app.
const BOLD_REFER = 'https://fdyhcokgnymevgtixwuf.supabase.co/functions/v1/bold-refer';
async function refer(body: Record<string, unknown>) {
const res = await fetch(BOLD_REFER, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-refer-key': process.env.BOLD_REFER_KEY ?? '' },
body: JSON.stringify(body),
});
const data = await res.json();
if (!res.ok || data.ok === false) throw new Error(data.message ?? data.error ?? 'BOLD Refer ' + res.status);
return data;
}
// 1. The referred account has qualified. Never on a bare signup.
await refer({ action: 'qualified', program: 'your-program', subject_ref: user.id, visit_token: user.boldVisitToken });
// 2. Link a wallet: get a challenge, have the wallet sign it in your app, then link.
const { nonce, message } = await refer({ action: 'wallet.challenge', program: 'your-program', subject_ref: user.id, wallet: walletAddress });
const signature = await signWithWallet(message); // your app, the person’s wallet
await refer({ action: 'wallet.link', nonce, signature });
// 3a. An on-chain buy: BOLD reads the transaction itself.
await refer({ action: 'purchase.onchain', program: 'your-program', signature: txSignature });
// 3b. An off-chain buy: your order id makes a retry safe.
await refer({ action: 'purchase', program: 'your-program', subject_ref: user.id, external_ref: order.id, amount_cents: order.totalCents });