Agent SDK overview
@q3labs/pact-sdk is the agent-side SDK for Pact Network. It’s a
drop-in fetch() that routes calls through the
Pact Market proxy and gets you on-chain
refunds via settle_batch when a call
goes sideways. One import, one call, no claim form.
If you only want to record reliability data and never want refunds —
keep using the older pact-monitor-sdk. That’s a different product;
see Monitor SDK → Overview. They live side by
side on purpose. This page is about the new one.
Install
Section titled “Install”npm install @q3labs/pact-sdkThe package is ESM-only. Node ≥ 18, or a browser bundled by Vite, Webpack 5, esbuild, or Rollup. There is no CJS build.
What you get
Section titled “What you get”- A
pact.fetch()that matches thefetch()signature. Drop it in where you’d usefetch()today. - On-chain refunds for the calls the classifier labels as covered breaches — 5xx, timeouts, truncated or malformed bodies.
- One SPL approve to the SettlementAuthority delegate, once per agent, and you’re covered up to the allowance you set.
- Defaults for every host, proxy, indexer, and program ID on mainnet. You shouldn’t have to configure anything to try it.
What it isn’t
Section titled “What it isn’t”- It isn’t a payment SDK. The agent still pays the provider through
x402 or MPP (via the CLI,
pay.sh, or your own client). Pact sits underneath the payment and refunds principal + premium on a covered breach. - It isn’t a monitor-only library. If you want recording without on-chain settlement, that’s the Monitor SDK.
When to use this vs the CLI
Section titled “When to use this vs the CLI”- Building an agent in TypeScript → this SDK. One import, native
fetch()semantics. - Shell scripts, demos, one-offs → the
CLI (
pact pay curl ...). Same wire format, same refunds.
For coding agents
Section titled “For coding agents”Cross-links
Section titled “Cross-links”- Quickstart — three steps to a covered call.
- Environment & E2E — env-var conventions for live tests.
- Market → Overview — what the SDK routes through.
- Concepts → settle_batch — how refunds land on-chain.
- Concepts → Classifier & refund policy — what counts as a covered breach.