Quickstart
Goal: a real sybil-gate decision in one command.
You need curl. Not a wallet, not an account, not an API key — checking is a
public read.
1. Ask the gate about an addressLink to this section
curl -s 'https://attest.ochk.io/api/check?addr=bc1pezn5yjxmz9nuahtqprvhfeya2nv4zdfk49u5amquhqptykx695rs60hqa2'
{
"ok": true,
"sats": 10000,
"days": 363,
"score": 120.66,
"attestation_id": "bbde80f884ae849d2cc8d4fa19687e7ec862f8b7c85a3ee8cf93739548e23658",
"address": "bc1pezn5yjxmz9nuahtqprvhfeya2nv4zdfk49u5amquhqptykx695rs60hqa2",
"identities": [
{
"protocol": "nostr",
"identifier": "npub1yfk7w33n60g05whqdmzluaftan390q89mqhht67wf4r8y90m3h9spyzpyn"
}
],
"network": "mainnet"
}
That is the whole product in one response. This address has proved control of an
unspent 10,000-sat output that has sat still for days days, and has bound a
Nostr identity to it. days and score grow each day the coin stays put, so
the numbers you see are higher than these. ok is the answer to "should I let
this one in".
score is advisory — a convenience number, not a consensus value. Gate on
sats and days, which are facts about the chain. See
Scoring for why.
2. Set your own barLink to this section
ok is computed against thresholds you pass. Nothing is hardcoded.
# a floor this address clears
curl -s '.../api/check?addr=bc1pezn…&min_sats=5000&min_days=90'
{"ok": true, "sats": 10000, "days": 363, "score": 120.66}
# a floor it does not
curl -s '.../api/check?addr=bc1pezn…&min_sats=100000000&min_days=3650'
{"ok": false, "sats": 10000, "days": 363, "score": 120.66, "reasons": ["below_min_sats", "below_min_days"]}
Note that a failing check still returns the facts, plus reasons naming the bar
it missed. You decide what to do with a 10,000-sat identity of that age — the
endpoint does not moralise about it.
An address that has never attested is a different answer — and it comes back with a 404, not a 200:
curl -s 'https://attest.ochk.io/api/check?addr=bc1qhtl83u7jsf94lp70z0tzfmws7za0hv35n5zugm'
{"ok": false, "reasons": ["not_found"]}
Read the status code, not just okLink to this section
There are four outcomes and the HTTP status separates two of them that ok
alone does not:
| meaning | status | body |
|---|---|---|
| clears your bar | 200 | ok: true plus the facts |
| attested, below your bar | 200 | ok: false plus the facts |
| no attestation exists | 404 | ok: false, reasons: ["not_ |
| malformed request | 400 | error: "bad_, issues[] |
This matters more than it looks. The obvious client is wrong:
declare const url: string; // an /api/check URL
// WRONG — throws on a perfectly normal "this address never attested"
const res = await fetch(url);
if (!res.ok) throw new Error('check failed');
const { ok } = await res.json();
declare const url: string; // an /api/check URL
// Right — 404 is an answer, not a failure.
const res = await fetch(url);
if (res.status === 400) throw new Error('bad address');
if (res.status >= 500) throw new Error('verifier unavailable');
const body = await res.json(); // 200 and 404 both carry usable JSON
const admit = body.ok === true; // 404 lands here as false, correctly
"No proof exists" and "proof exists and is too small" are different facts about a person, and a gate usually wants to treat them differently — the first is a stranger, the second is someone who showed up with too little.
3. Look up by identity instead of addressLink to this section
If what you hold is a Nostr npub rather than a Bitcoin address, ask by identity.
The value is protocol:identifier — a bare npub is rejected.
curl -s 'https://attest.ochk.io/api/check?identity=nostr:npub1yfk7w33n60g05whqdmzluaftan390q89mqhht67wf4r8y90m3h9spyzpyn'
{"ok": true, "sats": 10000, "days": 363, "address": "bc1pezn…", "identity_trust": "self_asserted"}
identity_trust: "self_asserted" comes back on every identity lookup. The
attestation proves control of the address, not of the handle bound beside it:
the binding is the address holder's claim, and the newest claim for a handle is
the one returned. Check the handle yourself before you rely on it, or gate on
addr when you need the subject pinned.
4. See everything an address has publishedLink to this section
curl -s 'https://attest.ochk.io/api/discover?addr=bc1pezn…&limit=5'
Returns every attestation whose signed message names that subject, each with its
attestation_id, scheme (bip322), and bound identities. Use it when you
want the history rather than a yes/no. If the relays do not finish the read, it
answers 503 with what came back and reasons: ["attestation_unread"]: ask
again after 30 seconds.
Then: gate your own thingLink to this section
You now have the read path. The three next steps, in the order most people want them:
- Gate an Express route — the check above as drop-in middleware, about ten lines.
- Sybil-filter a Nostr relay — a Strfry plugin that rejects events from unproofed npubs.
- Filter an airdrop — turn a candidate list into a sybil-resistant allowlist.
Verify without trusting usLink to this section
Everything above is a convenience over a pure function. /api/check is
attest.ochk.io reading a public index; if you would rather not trust that,
don't.
npm install @orangecheck/sdk@^1.7.0 @orangecheck/bip322@^1.1.2The version floor matters. In 1.3.0 and earlier, check() filtered relays on
a multi-letter #address tag, which NIP-12 relays do not index — so it answered
not_found for every real attestation. Before 1.7.0, it took the subject from
relay tags rather than the signed message, and let one bond vouch for several
identities on the same protocol.
import { check } from '@orangecheck/sdk';
const result = await check({
addr: 'bc1pezn5yjxmz9nuahtqprvhfeya2nv4zdfk49u5amquhqptykx695rs60hqa2',
minSats: 5000,
minDays: 90,
});
// { ok: true, sats: 10000, days: 363, score: 120.66, ... }
An address a person typed or scanned goes through normalizeAddress from
@orangecheck/bip322 first. QR codes carry bech32 in capitals, and verification
reads only the lowercase spelling:
import { normalizeAddress } from '@orangecheck/bip322';
import { check } from '@orangecheck/sdk';
declare const input: string; // what the person typed or scanned
const addr = normalizeAddress(input); // 'BC1Q…' becomes 'bc1q…'; null if it is not an address
if (!addr) throw new Error('Not a Bitcoin address');
const result = await check({ addr, minSats: 5000, minDays: 90 });
Same shape as the HTTP response, and no call to attest.ochk.io — check()
reads the attestations off Nostr relays and re-derives the answer locally from
the envelope plus public chain data. Pass relays to point it at your own. That
is the whole point of the protocol, and the reason the HTTP API is optional
rather than load-bearing.
verify({ msg, addr, sig }) is the lower-level primitive if you hold a raw
signed message rather than a published envelope, and createAttestation()
builds a new envelope from a message and the signature the wallet made over it.
To check an envelope you already hold without installing anything, send its address, message and signature:
curl -s -X POST https://attest.ochk.io/api/verify \
-H 'content-type: application/json' \
-d '{"addr": "bc1q…", "msg": "…", "sig": "…"}'
msg is the canonical message exactly as signed. The answer carries ok,
codes and, when ok is true, metrics (sats_bonded, days_unspent,
score). It applies no thresholds, so compare metrics with your own bar. See
Verification for the exact checks a verifier performs,
and Self-hosting the verifier to run them on your
own server with the published packages.
Get your own attestationLink to this section
Signing needs a wallet that can sign a message: UniSat, Xverse, Leather, OKX,
Phantom and Sparrow sign with BIP-322, and Electrum's legacy signmessage
signature is accepted too
(which forms). Open
attest.ochk.io (opens in a new tab), connect it, and sign one short
canonical message — your Bitcoin never moves and no private key leaves your
wallet. Use a single-key address: bc1q…, bc1p…, 3… (P2SH-P2WPKH) or 1….
The address step refuses a script (P2WSH) address, which no wallet can sign the
message for, and an address whose checksum fails.
How it works is the whole protocol on one page.
The machine-readable contractLink to this section
curl -s https://attest.ochk.io/api/openapi
OpenAPI 3.1, covering /api/check, /api/verify, /api/discover,
/api/publish-attestation and /api/stats. Generate a client from it in any
language. (/api/stats counts the newest attestations it reads off the relays,
up to 500 per relay, and caches the result for 10 minutes. window_minutes is
that cache life, not a time window.)