← Badger Clicks

Developer Docs

Badger Clicks speaks the open Solana Actions spec, so every Click works in any Blink-enabled wallet — no lock-in. Here's how ours are wired.

The shape of an Action

Each endpoint answers three methods. GET returns the UI (title, icon, buttons). POST returns an unsigned transaction for the connected account. OPTIONS handles CORS.

GET  /api/actions/buy         → { type, title, icon, description, links.actions[] }
POST /api/actions/buy?amount=1 { account } → { transaction, message, links.next? }
OPTIONS                        → CORS preflight

URL mapping (actions.json)

A public URL like badger.markets/buy is mapped to its API by /actions.json:

{ "rules": [
  { "pathPattern": "/buy",  "apiPath": "/api/actions/buy" },
  { "pathPattern": "/burn", "apiPath": "/api/actions/burn" }
] }

Chained confirm + Badger Rank

A POST can return links.next. After the tx confirms, the wallet calls that endpoint with the signature. We verify the on-chain token movement (never the client-supplied amount) and credit Badger Rank — idempotent per signature.

POST /api/actions/burn → { transaction, links: { next: { type:"post",
  href:"/api/actions/burn/confirm" } } }
POST /api/actions/burn/confirm { account, signature }
  → verify balance delta → credit Rank → terminal message

Discover every Click

The registry is API-first and CORS-open — any app or agent can list Clicks:

GET /api/clicks/registry
GET /api/clicks/registry?status=live&category=Trade&protocol=Jupiter
  → { count, categories[], protocols[], actions[] }

Test

Paste any Click URL into the Blink Inspector to preview buttons, responses, and the built transaction.

Build your own Clicks

No code: use the visual builder (with AI generate) — deploys to badger.markets/c/<id>. Programmatic: get an API key in the dashboard, then POST /api/clicks/create.

POST /api/clicks/keys { name }            → { key: "bck_…" }   // shown once
POST /api/clicks/create  (x-api-key)      { def } → { blink }
GET  /api/clicks/mine    (x-api-key)      → your Clicks + stats
POST /api/clicks/ai      { prompt }       → generated def

TypeScript SDK

A zero-dependency client lives at sdk/typescript — registry discovery, tx building, chained confirms, the agent, and authoring.

const clicks = new BadgerClicks();
const { actions } = await clicks.registry({ status: 'live' });
const { transaction } = await clicks.buildTx('/api/actions/buy?amount=0.5', wallet);