@absol-labs/shared
v0.12.1
Published
Metrik protocol hub: canonical types, EIP-712 attestation typed-data, and escrow contract ABI for the verified service marketplace and payment rail for AI agents.
Maintainers
Readme
@absol-labs/shared — Metrik protocol hub
Metrik is an infra-agnostic verified-service marketplace and payment rail for AI agents on Base. Agents discover, pay for, and verify third-party services; USDC escrowed on-chain is released to the seller only for delivery an independent verifier has confirmed, and unearned funds remain reclaimable by the buyer. Sellers run their endpoint on any backend (Akash, io.net, AWS, bare metal) — Metrik only ever sees a URL and a payout wallet — and everything settles single-chain on Base in USDC. The claim is deliberately narrow and honest: Metrik proves delivery (a service responded, correctly-shaped, within SLA, to real traffic), never correctness of the output.
"x402 proves the payment, Metrik proves the delivery."
This repository is the hub. It is the source of truth every other Metrik repo depends on,
and it does two jobs. First, it publishes @absol-labs/shared —
the TypeScript types, zod schemas, EIP-712 typed-data, and the escrow contract ABI that the
contracts, oracle, SDK, and agent repos all import, so the cross-repo wire format can never
drift. Second, it holds the canonical protocol documentation. Start with
docs/master-plan.md.
Naming. The product is Metrik. GitHub repos are
metrik-*and the deployed EIP-712 domain keeps the historical literalname: "StreamProof"— an immutable on-chain/verifier wire constant, renamed only at mainnet. Package names (@absol-labs/*) and user-facing surfaces use Metrik; the retainedstreamproofidentifiers exist for compatibility.
What @absol-labs/shared exports
The package (src/, published as ESM with types) is the machine-readable embodiment of the
protocol spec. Its surface, all re-exported from src/index.ts:
- Contract ABIs —
streamEscrowAbiandstreamEscrowV2Abi, typed (as const satisfies Abi) viem ABIs generated from their contracts and never hand-edited, plus theBASE_SEPOLIA_ESCROW_V2deployment constant. - Attestation typed-data —
attestationTypedData,attestationSchema, and the EIP-712 domain helpers (streamProofEip712Domain/metrikEip712Domain,createStreamProofEip712Domain/createMetrikEip712Domain) the oracle signs and the escrow verifies. - Service binding & descriptor —
serviceBindingTypedData/serviceDescriptorTypedDatawith their zod schemas, signers (signServiceBinding,signServiceDescriptor), recovery helpers,deriveServiceReffor canonical service references, and the optional strictcontentHashSchemadelivery-integrity commitment. A descriptor may also commit the optionalverification.modepolicy (output-probeorconsumer-attested); omission preserves every legacy v3serviceRefand meansoutput-probewithout materializing a canonical-JSON field. Gated descriptors may commitcallerAuth.accessUrl, the buyer-facing HTTPS invocation gateway;publicUrlremains the public verification origin that the oracle probes. - Verification model —
serviceCheckResultSchema,verificationModes, and the evidence schemas for output-probe, delegated-status, and consumer-attested (zkTLS) checks. - T2
DeliveryReceipt— the buyer-signed EIP-712 typed-data + zod schema that binds a Reclaim zkTLS proof of received bytes to a stream, nonce, and request context; consumed by the SDK'ssubmitDeliveryProofand assembled by the agent'sbuildT2DeliveryProofSubmission. This is what gates live T2 accrue-on-proof settlement. - Stream state & enums —
streamSchema, theStreamStatus/DeliveryStatusenums, and their Solidity<->TypeScript converters. - Reputation —
aggregateReputation,rankOperators, and the SLA-receipt record schemas that turn on-chain events into a ranked operator index.
Runtime dependencies are viem and zod only.
Canonical docs
docs/ is the deeper reference that master-plan.md links to; read it
in this order.
master-plan.md— source of truth: scope, architecture, phase fence, and issue map. Read first.product-strategy.md— what Metrik is, who it serves (two-sided), and why it is permissionless.production-flow.md— the discover → bind → verify → settle loop through a human and an AI-agent journey.verification-model.md— how the verifier proves delivery without credentials: the layered, delivery-not-correctness stack.verifying-advanced-endpoints.md— canary, challenge-response, and re-execution techniques for hard-to-probe endpoints.spec/attestation.md— the canonical v1 spec: attestation, EIP-712, lifecycle, accrual, and invariants. The contract between all repos.architecture.md— components, data model, state machine, trust model, verifier ladder, and economics.threat-model.md— assets, trust boundaries, abuse cases, and the reusable security-pass checklist.reputation-index.md— the on-chain reputation model and operator ranking.prior-art.md— external protocols and libraries Metrik builds on.whitepaper.md— the product and protocol narrative.decisions/— architecture decision records.versioning.md—@absol-labs/sharedrelease and semver policy.
Repo map
Metrik is a multi-repo protocol under the Absol-Labs org.
| Repo | Role |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------- |
| metrik-protocol (here) | Hub: @absol-labs/shared types/ABI + canonical docs |
| metrik-contracts | Metered escrow + threshold verifier on Base |
| metrik-oracle | The verifier service, adapters, and settlement submitter |
| metrik-sdk | Typed developer client (@absol-labs/sdk) |
| metrik-agent | x402 facilitator, MCP server, agent-framework tools (@absol-labs/agent) |
| metrik-site | Marketing landing |
Live surfaces: the app at app.metrik.live, docs at metrik.live, and the verifier at oracle.metrik.live.
Install
pnpm add @absol-labs/shared # or: npm i / yarn addThe package is public on the npm registry — no auth or registry config required. Peer setup and
semver policy are in docs/versioning.md. Published versions at time of
writing: @absol-labs/shared 0.11.0, @absol-labs/sdk 0.7.0, @absol-labs/agent 0.4.0.
Develop
Requires Node 20 (pinned by .node-version) and pnpm 9.15.
corepack enable && corepack prepare [email protected] --activate
pnpm install
pnpm format:check # prettier (CI-enforced)
pnpm typecheck
pnpm abi:check # ABI drift guard
pnpm test # vitest
pnpm build # tsc -> dist/CI runs the same sequence on PRs and main. See CONTRIBUTING.md.
Contract ABI sync
streamEscrowAbi and streamEscrowV2Abi are generated, never hand-edited. Their sources of
truth are the matching contracts in metrik-contracts. The committed canonical references
abi/StreamEscrow.json and abi/StreamEscrowV2.json stay in lockstep with src/abi.ts (the
typed viem module).
# Regenerate from the contract (needs Foundry + a metrik-contracts checkout)
CONTRACTS_EVM_DIR=../streamproof-contracts/evm pnpm abi:sync
# Drift guard — no Foundry needed, runs in CI
pnpm abi:checkabi:sync is deterministic (canonical ordering + Prettier), so re-running against an unchanged
contract produces no diff, and abi:check guarantees src/abi.ts cannot silently diverge.
Status
Metrik is live on Base Sepolia testnet (chainId 84532), testnet only. The production
settlement path is StreamEscrowV2, checkpoint settlement, deployed and Basescan-verified
at
0x0f09f36Ccc05A7c9882F438721C08De314dFd46C
(2-of-3 oracle signer threshold) — the oracle runs in SETTLEMENT_MODE=checkpoint, the dApp
and SDK settle against it, and T2 consumer-attested accrue-on-proof (buyer-signed
DeliveryReceipt + Reclaim zkTLS proof) gates live accrual. The original per-tick
StreamEscrow v1 at
0x21948a5E6AE8d9A3D1050791AB6138657Fb54286
is retired/orphaned.
Meta
Org front door: github.com/Absol-Labs. See
SECURITY.md, CHANGELOG.md, and
LICENSE (MIT).