npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

clearpact

v0.3.0

Published

Official JavaScript/TypeScript SDK for the ClearPact ERC-8183 job escrow API

Readme

npm version TypeScript License: MIT

ClearPact SDK

Lightweight JavaScript/TypeScript client for the ClearPact ERC-8183 escrow API. Source on GitHub.

  • Zero dependencies — uses native fetch (Node 18+ / modern browsers)
  • Full TypeScript types for autocomplete and type safety
  • Testnet by default — safe for development, flip network: 'mainnet' when ready

v1 deprecation notice: client.escrow is a deprecated alias kept for 7-day drainage compatibility (sunset 2026-05-23, removed in v0.4.0). Migrate to client.jobs — see migration guide.

Install

npm install clearpact

Or use the browser CDN build:

<script src="https://clearpact.polsia.app/sdk"></script>

Quick Start

const { ClearPact } = require('clearpact');

const client = new ClearPact({
  apiKey: 'cpk_live_...',   // from https://clearpact.polsia.app/docs
});

// Create an ERC-8183 job
const { job } = await client.jobs.create(
  '0xProviderWalletAddress',
  '0xEvaluatorEOA',           // self-service evaluator — your wallet or a trusted EOA
  new Date(Date.now() + 7 * 86400_000).toISOString(),  // expiredAt (ISO 8601, 7 days)
  'Build landing page in Tailwind'                       // description
);

console.log(job.id, job.status);
// → "3f2ac1d0-..." "Open"

// Set the budget (USDC by default)
await client.jobs.setBudget(job.id, 100);

// Fund the job on-chain (record the tx hash)
await client.jobs.fund(job.id, { tx_hash: '0x...' });

// Provider submits the deliverable
await client.jobs.submit(job.id, 'https://deliverable.url/output');

// Evaluator (or client) approves and releases payment
await client.jobs.complete(job.id, 'Work accepted');

ESM

import { ClearPact } from 'clearpact';

TypeScript

import { ClearPact, ClearPactError } from 'clearpact';
import type { Job } from 'clearpact/types';

const client = new ClearPact({ apiKey: 'cpk_live_...' });

try {
  const { job } = await client.jobs.create(
    '0xProvider',
    '0xEvaluatorEOA',
    new Date(Date.now() + 7 * 86400_000).toISOString(),
    'Write smart contract audit'
  );
} catch (err) {
  if (err instanceof ClearPactError) {
    console.error(err.status, err.message);
  }
}

API Reference

new ClearPact(options)

| Option | Type | Default | Description | |-----------|-----------|----------------------------------|--------------------------------| | apiKey | string | required | Your ClearPact API key | | network | string | 'testnet' | 'testnet' or 'mainnet' | | baseUrl | string | https://clearpact.polsia.app | Override API base URL |


client.jobs — ERC-8183 v2 (current)

| Method | Description | |---------------------------------|---------------------------------------------------------------| | create(provider, evaluator, expiredAt, description?, hook?) | Create a new job (ERC-8183 createJob) | | setProvider(jobId, provider) | Update provider address (Open state only) | | setBudget(jobId, amount, opts?) | Set budget + optional token / conditionRef | | fund(jobId, opts?) | Record on-chain funding event (Open → Funded) | | submit(jobId, deliverable, opts?) | Submit deliverable (Funded → Submitted) | | complete(jobId, reason, opts?) | Approve and release payment (Submitted → Completed) | | reject(jobId, reason, opts?) | Reject with automatic refund (E3 3-path ACL) | | claimRefund(jobId) | Claim expiry refund (Funded/Submitted, after expiredAt) | | get(jobId) | Get job state + event log | | list(filters?) | List jobs by status, with pagination |

create params

client.jobs.create(
  provider: string,      // Provider wallet address
  evaluator: string,     // Self-service evaluator EOA (chosen by job creator)
  expiredAt: string,     // ISO 8601 expiry datetime
  description?: string,  // Job description
  hook?: string          // IACPHook contract address (optional, must be whitelisted)
)

setBudget opts

{
  token?:        string;  // ERC-20 token address (default: USDC)
  conditionRef?: string;  // bytes32 conditional reference hash (Phase 2bis)
}

JobStatus values

| Status | Meaning | |-------------|--------------------------------------| | Open | Job created, awaiting funding | | Funded | Budget deposited on-chain | | Submitted | Provider submitted deliverable | | Completed | Evaluator/client approved, paid out | | Rejected | Rejected, symmetric refund issued | | Expired | Expired, refund claimable |


client.x402

| Method | Description | |-----------------------------|--------------------------------------| | verify(payload, options?) | Verify an x402 payment authorization | | settle(params?) | Settle a verified x402 payment | | health() | Facilitator health + config | | listTransactions(filters?)| List x402 transaction records | | getTransaction(id) | Get single x402 transaction |


client.webhooks

| Method | Description | |------------------|---------------------------------| | create(params) | Register a webhook endpoint | | list() | List registered webhooks | | delete(id) | Remove a webhook | | deliveries(webhookId, opts?) | List webhook delivery attempts |

Webhook payload envelope:

{
  "id": "uuid",
  "type": "job.completed",
  "created_at": "2025-01-01T00:00:00.000Z",
  "data": { ...job }
}

Verify payloads using the X-ClearPact-Signature: sha256=<hex> header (HMAC-SHA256).


Error handling

All errors throw a ClearPactError:

const { ClearPactError } = require('clearpact');

try {
  await client.jobs.get('bad-id');
} catch (err) {
  if (err instanceof ClearPactError) {
    console.error(err.status);  // 400
    console.error(err.message); // "Invalid job ID format"
    console.error(err.raw);     // Full response body
  }
}

client.escrow — deprecated (v1)

Deprecated. Preserved for 7-day drainage compatibility. Sunset 2026-05-23 — removed in v0.4.0. Migrate to client.jobs — see the migration guide.

| Method | v2 equivalent | |-------------------|----------------------------| | create(params) | client.jobs.create(...) | | get(id) | client.jobs.get(id) | | fund(id, params?) | client.jobs.fund(id, params?) | | settle(id, params?) | client.jobs.complete(id, reason) | | cancel(id, params?) | client.jobs.reject(id, reason) |


License

MIT — © ClearPact