Thoth lets your Midnight contract accept a fact from outside the chain, such as a value from a web API, once N of M independent attestors have checked it and signed it. You choose the M attestors and the threshold N, and the fact reaches the contract as private input.
In development. Thoth is unaudited and has known security issues. Don't use it to protect real value. The claim format may still change.
Pick your path below, or jump to the quickstart to run a 2-of-3 flow locally.
- dApp developer: Embed verification in your contract with
@txpipe/thoth-contracts, then follow the dApp guide for your source:- web APIs: the zkFetch dApp guide, with the GitHub stars and Strava policy examples;
- Cardano events: the Cardano dApp guide, with the Cardano output policy example.
- Attestor operator: Run an attestor against your own
source and share its descriptor with dApps. For zkFetch,
follow the zkFetch attestor guide
for
@txpipe/thoth-zk-tls. For Cardano, configurecardanoAttestorin@txpipe/thoth-cardano. - Kind author: Follow the
kind author guide to add a
kind for another source of evidence.
You define its law with
@txpipe/thoth-core, pair it with a signing key in@txpipe/thoth-attestor, and build its client on@txpipe/thoth-client.
Thoth is a set of Compact modules and TypeScript packages. Your Midnight contract embeds the modules, and your dApp uses the packages to collect signatures from independent attestors and hand them to the contract as private input.
Thoth fits your app if:
- your contract needs a fact from outside the chain, such as a value from a web API;
- you want several independent operators to vouch for it, not one;
- your contract should test the fact in-circuit without publishing it.
It does not fit if a single authority's signature is enough, if you need a vote or a judgment rather than an observed fact, or if you need verifiable computation. docs/DESIGN.md lists what is out of scope and why.
- Your dApp obtains evidence of a fact. With the zkFetch kind, that is a Reclaim zkFetch proof of an HTTPS response.
- Each attestor in your app's trusted set checks the evidence and signs a canonical claim derived from it.
- Your dApp submits the claim and N signatures to your contract as private witness data. The contract checks the signatures against its pinned registry, the policy, the window, the holder and replay through the nullifier (full list).
- Your contract's predicate runs over the claim values.
Attestors certify facts, not decisions: a claim states what was observed, and your app defines the predicate over it.
Claim values are private witness data and are not stored on-chain. The public nullifier hashes them with a salt. In zkFetch the salt is secret, so an outsider cannot confirm a guessed value from it; a chain-event kind's salt is public instead, since its values already sit on the chain (ADR 0014). The contracts README says what is public and who holds the salt.
| Package | Use it to |
|---|---|
@txpipe/thoth-contracts |
Embed N-of-M verification in your Midnight contract |
@txpipe/thoth-zk-tls |
Attest a web fact with zkFetch, as a dApp or as an attestor operator |
@txpipe/thoth-cardano |
Attest a Cardano chain event, as a dApp or as an attestor operator |
@txpipe/thoth-client |
Write a kind's client: the trusted set and the attestation checks |
@txpipe/thoth-attestor |
Write a kind's attestor: pair its law with a signing key |
@txpipe/thoth-core |
Write a kind's law against the shared claim types |
There is no deploy script; the closest thing to a quickstart is
packages/contracts/test/acceptance.test.ts:
it runs two zkFetch attestors, collects a 2-of-3 claim, and submits it to the
contract simulator. Run it with the dev setup in
place:
npm install
npm test -- acceptanceThe path it covers, in short:
// 1. Each operator runs an attestor that trusts its own Reclaim witness.
const attestors = [
zkFetchAttestor({ id: 'attestor-0', keyPair: keyPair0, witnessAddress: witness0 }),
zkFetchAttestor({ id: 'attestor-1', keyPair: keyPair1, witnessAddress: witness1 }),
];
// 2. You deploy your contract: its registry pins the attestors' public keys
// (seedKeys) and it seals your appId and zkFetchPolicyHashOf(policy)
// (policyHashes).
// 3. Your dApp collects 2 signatures and places each at its registry slot.
const client = zkFetchClient.init({
trusted: buildTrustedSet({
registrySize: 3,
attestors: attestors.map((a, registryIndex) => ({ attestor: descriptorOf(a), registryIndex })),
}),
transport,
verifier: jubjubVerifier,
policy,
appId,
valueSlots: 3,
byteSlots: 1,
provers,
});
const { claim, collected } = await client.collect(request, {
holder: holderCommitmentOf(holderSecret),
windowStart,
windowEnd,
expiresAt,
threshold: 2,
attestorTimeoutMs: 5_000,
});
// 4. Your contract's getAttestationWitness returns toContractClaim(claim), the
// signatures by slot and a commitment randomness; getHolderSecret returns
// holderSecret. Then you call verifyAttestation.examples/example_app.compact
is a 2-of-3 contract and the
test mocks add predicates; the
dApp guide and the
attestor guide cover each side in
full.
- Docs site: these docs rendered as a website
- docs/DESIGN.md: the architecture, the claim and its wire order
- docs/kind-author-guide.md: how to add an attestor kind
- docs/adr/: the design decisions and their reasons
- CONTEXT.md: the glossary
- CONTRIBUTING.md: dev setup, repo layout and commands
- License: Apache-2.0, except
@txpipe/thoth-zk-tls, which is AGPL-3.0-only because it links Reclaim Protocol's AGPL-licensed attestor-core