docs / quickstart

Quickstart

Pick a protocol. Pick a task. Ship.

Every quickstart below uses only shipped, MIT-licensed packages — no hosted API dependency, no signup, no key material leaves your machine.

OC Attest — gate an HTTP route

npm i @orangecheck/gate
import { ocGate } from '@orangecheck/gate';
import express from 'express';

const app = express();

app.post(
    '/post',
    ocGate({
        minSats: 10_000,
        minDays: 30,
        address: { from: (req) => req.get('x-bitcoin-address') ?? '' },
    }),
    (_req, res) => res.json({ ok: true })
);

app.listen(3000);

The gate fetches the most recent attestation for the address, verifies the BIP-322 signature, recomputes sats_bonded and days_unspent from live chain state, and passes or rejects. If you pair it with Sign-in-with-Bitcoin you don't need the caller to provide the address at all — the session cookie carries it.

See the full Attest guide.


OC Lock — encrypt a message to a Bitcoin address

npm i @orangecheck/lock-core
import { seal, unseal } from '@orangecheck/lock-core';

// Sender: encrypt a payload addressed to bc1qbob…
const envelope = await seal({
    payload: new TextEncoder().encode('hello'),
    sender: {
        address: 'bc1qalice…',
        signMessage: async (m) => walletSignBIP322(m),
    },
    recipients: [{ address: 'bc1qbob…', device_id: '…', device_pk: '…' }],
});

// Recipient: decrypt once you have the right device secret
const { payload } = await unseal({
    envelope,
    device: { device_id: '…', secretKey: deviceSecret },
    verifyBip322: async (msg, sig, addr) => {
        /* your verifier */
    },
});

The envelope is a JSON blob. Send it over any transport. See the full Lock guide.


OC Stamp — sign and anchor a statement to a Bitcoin block

npm i @orangecheck/stamp-core @orangecheck/stamp-ots
import { stamp, verify } from '@orangecheck/stamp-core';
import { submitToCalendars, upgradeProof } from '@orangecheck/stamp-ots';

// Produce a signed envelope
const env = await stamp({
    content: new TextEncoder().encode('v1.2.3 release notes…'),
    mime: 'text/plain',
    signer: {
        address: 'bc1qalice…',
        signMessage: async (m) => walletSignBIP322(m),
    },
});

// Anchor it to Bitcoin via OpenTimestamps
env.ots = await submitToCalendars(env.id);

// Later, once OTS upgrades the proof:
env.ots = await upgradeProof(env.ots, env.id);

See the full Stamp guide.


OC Vote — tally a poll

npm i -g @orangecheck/vote-cli
# Pull a poll + ballots from any transport (Nostr, HTTP, file),
# then compute the deterministic tally.
oc-vote tally ./poll.json --ballots ./ballots.ndjson

See the full Vote guide.


OC Agent

Design-state. Check the Agent overview for current status.


Next steps