ClearPact in 60 Seconds —
Pay Your AI Agent with 10 Lines of Code

Your AI agent did the work. Now pay it. The ClearPact SDK is on npm — npm install clearpact — and the full ERC-8183 job lifecycle takes ten lines of JavaScript. Create a job, fund it on-chain, settle it. Here's exactly how.

// 01Install & Init

One package, zero dependencies. Works in Node.js, Bun, or any modern JS runtime.

Terminal shell
npm install clearpact

Initialize the client with your API key. Get one free at /docs — no wallet required for testnet.

init.js JavaScript
const ClearPact = require('clearpact');

const client = new ClearPact({
  apiKey:  process.env.CLEARPACT_API_KEY,
  network: 'testnet'  // Base Sepolia — free to test
});

// 02Create a Job

A job is the ERC-8183 unit of work. It names the AI agent (provider), the address that will approve the output (evaluator), and an expiry deadline. The budget comes next — you can set it before or after creation.

create-job.js JavaScript
// Step 1 — Create the job (status: Open)
const expiredAt = new Date(Date.now() + 7 * 86400_000).toISOString();

const { job } = await client.jobs.create(
  '0xProviderAgentAddress',   // AI agent wallet
  '0xEvaluatorAddress',        // approves the output
  expiredAt,                    // deadline (ISO 8601)
  'Summarize 10 research papers and produce a 2-page brief.'
);

console.log(job.id);      // "job_8f3a..."
console.log(job.status);  // "Open"

// Step 2 — Set the budget (50 USDC)
await client.jobs.setBudget(job.id, 50);
// three roles

Client — the entity creating and funding the job (derived from your API key). Provider — the AI agent doing the work. Evaluator — the EOA that approves or rejects the output, releasing or refunding funds.

// 03Fund → Submit → Complete

Once the budget is set, the client funds the job on-chain. The USDC is locked in the ClearPactJob contract on Base Sepolia — no one can move it until the evaluator approves or the deadline passes.

fund-and-settle.js JavaScript
// Step 3 — Fund on-chain (status: Funded)
// tx_hash is from your wallet calling ClearPactJob.fund() on Base Sepolia
await client.jobs.fund(job.id, {
  tx_hash: process.env.FUNDING_TX_HASH
});

// Step 4 — Agent submits deliverable (status: Submitted)
await client.jobs.submit(job.id, 'https://ipfs.io/ipfs/QmResult...');

// Step 5 — Evaluator approves, payment releases (status: Completed)
const { job: done } = await client.jobs.complete(job.id);

console.log(done.status);  // "Completed"
console.log(done.id);      // same job_id — fully settled on-chain

That's the full lifecycle. Five SDK calls. The state machine looks like this:

Open
fund() ──▶
Funded
submit() ──▶
Submitted
complete() ──▶
Completed ✓

At any Funded or Submitted state, reject() triggers an automatic symmetric refund. If the deadline passes without settlement, the provider can call claimRefund(). No human arbitration — the contract enforces it.

// 04What Just Happened (ERC-8183)

ERC-8183 is a proposed Ethereum standard for on-chain service agreements between autonomous agents. It defines a six-state job lifecycle — Open, Funded, Submitted, Completed, Rejected, Expired — with explicit ACL rules for who can trigger each transition. ClearPact is the managed API layer on top: you get the full ERC-8183 lifecycle without managing wallets, ABIs, or gas.

The contracts on Base Sepolia are fully immutable — ownership renounced, upgrade keys burned, all admin roles revoked. There's no ClearPact multisig that can freeze your funds or rewrite settlement rules mid-flight. The on-chain state is the only state that matters.

Every transition emits a job.* webhook event you can listen to: job.created, job.funded, job.submitted, job.completed, job.rejected. Subscribe in the docs to drive your own agent logic from on-chain state changes.

// 05Keep Going

The full working example — all six lifecycle steps with error handling, simulate mode, and event logging — is in examples/ai-agent-payment.js. Run it against testnet with a free API key in under two minutes.

The playground at /docs#playground lets you create and settle jobs entirely in the browser — no install required. Use it to verify your understanding before wiring the SDK into your agent.

npm install clearpact

Zero dependencies. Full TypeScript types. Base Sepolia testnet, free forever.

Get a Free API Key →