Quickstart
Sign people in first. Pay them if you like.
Sign-in is free and takes a few minutes. Paying your users is optional and comes second. Every step has the real code, and your progress stays in this browser.
Sign people inFree
- 01
Create a project
Name your app and choose how people sign in. Your orangecheck account is your developer account. You leave with a project key.
What it asks, and what you get # ochk.app/me/projects/new name: Lumen domain: lumen.example sign-in: orangecheck sign-in pay your users: off → project key: pk_test_a4f9k2x… - 02
Add the sign-in button
Give your own button the orangecheck sign-in: it keeps your look and adds the orangecheck mark. People sign in the way they already do: email, Google, GitHub or a Bitcoin wallet. Post the token it returns to a ten-line route on your server, which checks it and keeps it as an httpOnly cookie. A site on ochk.io already shares the cookie and skips the route.
In your terminal yarn add @orangecheck/me-clientIn the browser import { SignInWithOrangecheck } from '@orangecheck/me-client/react'; import '@orangecheck/me-client/button.css'; <SignInWithOrangecheck className="btn" // your own button class onSignedIn={async ({ token }) => { await fetch('/api/auth/session', { method: 'POST', headers: { Authorization: `Bearer ${token}` }, }); }} />;pages/api/auth/session.ts, on your server import type { NextApiRequest, NextApiResponse } from 'next'; import { getOcSession } from '@orangecheck/me-client/server'; const COOKIE = 'Path=/; HttpOnly; Secure; SameSite=Lax'; export default async function handler(req: NextApiRequest, res: NextApiResponse) { if (req.method !== 'POST') return res.status(405).end(); const authorization = req.headers.authorization ?? null; const session = await getOcSession( { authorization }, { audience: 'https://yourapp.example' } ); if (!session || !authorization) return res.status(401).json({ ok: false }); const token = authorization.replace(/^Bearer\s+/i, ''); const maxAge = Math.max(0, (session.exp ?? 0) - Math.floor(Date.now() / 1000)); res.setHeader('Set-Cookie', `oc_session=${token}; ${COOKIE}; Max-Age=${maxAge}`); res.status(200).json({ ok: true }); } - 03
Check the session on your server
Wrap the routes that need a signed-in person with withOcAuth, ocAuthExpress or ocAuthHono. Each reads the cookie your route set. Pass your origin as audience and your project key as projectKey; a site on ochk.io leaves audience out. Answer /api/auth/me with an account id and its did_oc, the shape a session provider on your page reads.
A Next.js API route // pages/api/auth/me.ts import { withOcAuth } from '@orangecheck/me-client/server'; export default withOcAuth(async (req, res) => { if (!req.ocSession) return res.status(401).json({ ok: false }); res.status(200).json({ ok: true, account: { id: req.ocSession.sub, did_oc: req.ocSession.did_oc }, }); }, { audience: 'https://yourapp.example', projectKey: process.env.OC_PROJECT_KEY! }); - 04
Choose who can sign in
Everyone, by default. To keep bots out, let in only accounts backed by bitcoin: a coin of at least so many sats, held so many days, that stays in its owner’s wallet. Set it on your project; projectKey enforces it within a minute. Anyone below the bar gets a 403 with a link to back their account.
What someone below the bar gets 403 { "ok": false, "reason": "bond_required", "need": { "min_sats": 100000, "min_days": 30 }, "have": null, "back_url": "https://ochk.app/me/account#backing" }
Pay your usersOptional
- 05
When you pay
Off, always, or in promos you schedule. Sign-in stays free either way.
On your project, under Paying # your project · Paying · When you pay Off people sign in, nobody is paid Always every event you price pays your user Promos only between a start and an end you set - 06
What each event earns
Say what your user earns for each event. You pay that plus the fee: 20% of the price, rounded to a whole sat and at least 1 sat, so your user gets about 80%. Earns 100, you pay 125. Your project’s Paying tab shows the exact price for each earning you set.
On your project, under Paying # your project · Paying · What each event earns session_creation user earns 40 sats · you pay 50 account_creation user earns 800 sats · you pay 1,000 note_published user earns 100 sats · you pay 125 - 07
Send events from your server
Sign each event with your project secret and name who earns with accountId. Your server never needs your users’ sessions; store their account id once.
On your server // server-side · the earner rides inside the bytes you sign import { oc } from '@orangecheck/me-client'; await oc.event.fire({ project_key: process.env.OC_PROJECT_KEY!, subtype: 'session_creation', // any subtype your project enabled signingSecret: process.env.OC_SIGNING_SECRET!, // never in a browser accountId: user.did_oc, // who earns idempotencyKey: crypto.randomUUID(), }); - 08
Send a test event
From your project page. It lands with a test receipt you can open, and goes to your webhooks too. Nobody is paid, and nothing is signed.
What a test event shows # your project · Receipts · Send a test event event: session_creation ↓ receipt: oc-me-test-tx7m4f9kq2wd webhooks sent: 0 (none added yet) → open it at ochk.app/verify/<receipt> - 09
Go live
Once your domain is verified, your balance is funded and settlement is open. Sign-in never needs the domain; going live does. Until then each event is recorded but never signed, and no real sats move.
Your project, before it can go live # your project · Paying · Go live · domain verified a DNS TXT record or a meta tag · balance funded top up under Paying · settlement open not yet: it opens for every app at once
Next, deeper.
The sandbox runs your prices against a month of traffic, and ochk.io/docs/me/sdk documents every export. Not using the SDK? The wire format, signature and all, is in ochk.io/docs/me/api.