Tersign is the evidence layer for the agent economy, providing a neutral, countersigned, hash-chained ledger for recording agent commercial activity. tersign-js is the TypeScript SDK and MCP server for Tersign, published on npm (package name tersign).
Purpose: To provide verifiable evidence records for commercial interactions between agents. Sellers sign EIP-712 receipts, Tersign links receipts into a hash chain by seller, and countersigns each record. When a dispute occurs, the complete record is already sealed.
Main capabilities:
- Receipt issuance and verification: Sellers sign EIP-712 receipts (following the x402 offer-and-receipt extension), Tersign computes the keccak256 canonical digest, adds the digest to that seller's hash chain, and the neutral ledger performs a secp256k1 countersignature. Anyone can verify it, and a serialized evidence envelope can be obtained from any venue.
- Verification tool: npx tersign verify <receipt.json | 0xdigest> [--signer 0xaddr] [--ledger url] can verify a receipt file or digest. Receipt files are checked locally and do not touch the network unless --ledger is added. The EIP-712 signature is recovered, and --signer is used to compare against the issuer address. When --signer is not provided, the signer is reported as UNAUTHENTICATED, and the verdict is VALID (signer UNAUTHENTICATED). Receipts signed with the published test key are marked as published test key. Fields not covered by the signature are listed, and signature fields of other JSON types are rejected. The signature must be uniquely canonically encoded (0x + 130 lowercase hexadecimal digits, v 27/28, low-s). The file can be a receipt, {receipt, record}, or evidence bundle record file. Duplicate keys and non-integer numbers are rejected. The digest is looked up on the Tersign ledger unless --ledger specifies another ledger, and the verdict is VALID (ledger-reported). Exit statuses: 0 valid, 1 invalid, 2 usage error.
- Disclosure evidence: a single command generates countersigned disclosure evidence, with no account required.Text is summarized locally (only the summary is transmitted), your key signs the record, and the ledger countersigns it into a per-signer hash chain whose head is committed to a Bitcoin anchor every six hours. The first call self-configures a free signer account bound to your key. Key resolution order: TERSIGN_SELLER_KEY environment variable → macOS keychain tersign-signer → ~/.tersign/signer.key (created on first use). The free tier has quotas and rate limits.
- Refunds and disputes: a refund record references the corrected record via a digest (refundOf). Disputes are attached to a digest with an objective reason code. Party statements are structurally isolated behind an UNVERIFIED marker, and evidence remains prompt-injection resistant.
- withAssure(): wraps your x402 fetch handler. On the settlement call, it signs the receipt and compliance-field record with your key and merges both into the PAYMENT-RESPONSE header (the base64 JSON settlement response the x402 wallet already reads); the response body is unchanged. When it cannot issue (the settlement network is neither CAIP-2 nor its v1 name in its table, such as "bsc", or a ledger error), the paid response is emitted as-is as returned by the handler, with no receipt, and the error is sent to onError (default console.error); when idempotency is enabled, a retry with the same payment ID replays that response. On a 402, compliance fields are added to the PAYMENT-REQUIRED header. When Assure is built with a ledger, the ledger countersigns the receipt into your chain; the compliance-field record is not countersigned and is bound to its receipt only through your own signature.
- MCP boundary capture (tersign intercept): the agent is a pure observer; bytes arrive at the server and client as-is, in order, unmodified. Each tools/call becomes an ActionRecordV1 signed by your key and countersigned into the hash chain—summary only, so the record proves what happened without carrying parameters or results. Records are sent to the configured ledger, falling back to local ~/.tersign/intercepts-<date>.jsonl. Experimental; implements the observation semantics of the audit-mode verifier in MCP SEP-2624 (draft) as a transport-layer proxy.
- MCP server: npx tersign starts the MCP server (stdio). Official registry entry: io.github.tersignhq/evidence (active). No configuration required. Tools include: issue_receipt, verify_receipt, verify_compliance_record, record_disclosure, record_refund, open_dispute, submit_dispute_evidence, adjudicate_dispute, get_dispute.
Usage:
- Verify a receipt: npx tersign verify <receipt.json | 0xdigest> [--signer 0xaddr] [--ledger url]
- Start the MCP server: npx tersign
- Record a disclosure: call record_disclosure, then check the digest with npx tersign verify <digest> (a bare digest is checked against https://tersign.ai check)
- Issue receipt: issue_receipt also counter-signs after setting TERSIGN_LEDGER_URL, TERSIGN_LEDGER_API_KEY, and TERSIGN_LEDGER_SELLER_ID; when not set, it returns a locally signed, unanchored receipt.
- Python verifier: pip install tersign
Use cases:
- Commercial transactions between agents that require verifiable receipts and evidence.
- Scenarios that require recording agent tool calls (MCP boundary) to provide auditable evidence.
- Agent economy scenarios that require disclosure evidence, refund records, or dispute resolution.
- Sellers that need to comply with the x402 payment protocol and want to provide receipts and compliance fields.
Limitations:
- The free tier has quotas and rate limits.
- Disclosure evidence is independently verifiable evidence proving that a disclosure was attested at a specific time, but it is not a compliance certification.
- The intercept proxy is experimental and makes no conformance claims regarding the MCP SEP-2624 draft.
- The compliance field extension is under upstream review (x402-foundation/x402#2853).
- The repository is a release snapshot, not a development repository; each version overwrites src/, test/, and the packaging manifest in full from the upstream working tree, so pull requests opened here cannot be merged in any persistent way.
- License: Apache-2.0 (starting from 0.6.1; earlier versions were MIT).