Skip to content
On this page

Self-hosting the verifier

The site behind attest.ochk.io is not public, so you cannot clone or deploy it. Everything that decides a verdict is published under MIT: @orangecheck/sdk (opens in a new tab), @orangecheck/gate (opens in a new tab) and @orangecheck/bip322 (opens in a new tab). attest.ochk.io's /api/check calls the same check() you can run inside your own server. This page shows how.

What you're standing upLink to this section

Each hosted endpoint has a published counterpart you call in-process:

Hosted endpointIn your own code
GET /api/checkcheck() from @orangecheck/sdk, or @orangecheck/gate in front of a route
POST /api/verifyverify({ addr, msg, sig }) from @orangecheck/sdk
GET /api/discoverreadAttestations() from @orangecheck/sdk, which says when the relays did not finish (unread)
/api/challengeissueChallenge() and verifyChallenge() from @orangecheck/sdk; see Sign in with Bitcoin

None of these needs a database. They read attestations from Nostr relays and coins from an Esplora API.

PrerequisitesLink to this section

Pointing the SDK at your own relays + explorerLink to this section

@orangecheck/sdk doesn't call /api/check at all. The SDK is a full local verifier — check() queries Nostr for the attestation, runs BIP-322 verification in-process, and fetches UTXOs directly from Esplora. It never round-trips through attest.ochk.io. So "self-hosting" means pointing it at your own relays and your own Esplora node, not at a replacement API.

TypeScript
import { check } from '@orangecheck/sdk';

await check({
    addr: 'bc1q...',
    minSats: 100_000,
    // Query YOUR relays instead of the defaults.
    relays: ['wss://relay.internal.example', 'wss://relay-2.internal.example'],
    // Point verification at your own Bitcoin node + Esplora frontend.
    verifyOptions: {
        esploraMainnetBase: 'https://esplora.internal.example/api',
    },
});

To gate HTTP routes, @orangecheck/gate wraps the same check(): Gate an Express route shows ocGate, and the package also exports ocGateFastify, ocGateHono and ocGateFetch. Its relays option sets the relays; it takes no Esplora option.

The Python SDK (orangecheck on PyPI) is a client for the hosted HTTP API (https://ochk.io by default). It takes no relay or Esplora options, so it cannot run check() on its own.

What stays hosted. Two things have no published counterpart:

  1. Family sign-in on ochk.io (/api/auth/* and its oc_session cookie). For sessions on your own site, Sign in with Bitcoin runs the challenge flow on your server.
  2. The attest.ochk.io pages: create, verify, dashboard and the share links.

Operational notesLink to this section

  • Rate limiting. attest.ochk.io's limits do not apply to code you run. If you expose your own endpoint, put a limiter in front of it (a WAF, Cloudflare, reverse-proxy rules or a Redis-backed limiter): each check() costs relay queries and an Esplora lookup. See Security implications for context.
  • Chain-state caching. attest.ochk.io caches /api/check answers for 60 s. @orangecheck/gate caches each lookup in process (cacheTtlMs, 60 s by default). With bare check(), cache as your traffic needs.
  • Multi-relay Nostr queries. Pass relays to check() or the gate. Always query ≥ 3 relays so one partition doesn't break discovery.
  • Esplora fallback. mempool.space is tried first, blockstream.info is the fallback. Both are public — no API key needed. esploraMainnetBase replaces the first; the blockstream.info fallback stays.

Security hardening checklistLink to this section

  • Rate limiting in front of any endpoint you expose.
  • Multi-relay Nostr discovery (at least three distinct operators).
  • Challenges carry your own audience and purpose, and you pass them to verifyChallenge() as expectedAudience and expectedPurpose, preventing replay against a different host.
  • @orangecheck/sdk and @orangecheck/bip322 kept up to date (bip322 depends only on @noble/curves, @noble/hashes and @scure/base).
  • Read Security implications end to end before going live.

What you get by self-hostingLink to this section

  • No dependency on attest.ochk.io — check() talks to relays and an Esplora API, never to attest.ochk.io.
  • No attest.ochk.io rate limits — the relays and Esplora API you use may have their own.
  • Pin the relays you trust, or query your own.
  • Your own chain source — point esploraMainnetBase at your own node.

The verdict logic is the same code: attest.ochk.io's /api/check calls this check(). Given the same relays and chain state, your answer matches the hosted one. attest.ochk.io reads wss://nos.lol, wss://relay.primal.net, wss://nostr.oxtr.dev and wss://relay.ochk.io; pass those as relays to see what it sees.

FurtherLink to this section