npm package: @pausesecure/x402-commit
Description: PAUSE Commit Scheme for x402 — two-phase non-custodial payments with cancellation and risk scoring
Author: PAUSE
Latest version: 1.0.0

# @pause/x402-commit

**PAUSE Commit Scheme for x402 — two-phase payments you can cancel.**

A new payment scheme for the [x402 protocol](https://x402.org) that gives payers full control. Sign a payment intent (zero gas), share it with the recipient, and cancel anytime before they claim. Every recipient is risk-scored before you commit.

Built on the [PAUSECommit V2 smart contract](https://etherscan.io/address/0x604152D82Fd031cCD8D27F26C5792AC2CD328bF4), live on Ethereum mainnet.

## How It Works

```
exact scheme:  Agent pays → Server maybe delivers → No recourse
pause-commit:  Agent signs intent → Server claims + delivers → Agent can cancel before claim
```

| Property | exact | pause-commit |
|---|---|---|
| Payment timing | Before delivery | After delivery |
| Cancellable | No | Yes |
| Risk scoring | None | 11 Bayesian signals |
| Payer gas cost | ~21k | Zero (off-chain) |
| Claimer gas cost | N/A | ~85k |
| Non-custodial | Yes | Yes |

## Install

```bash
npm install @pause/x402-commit viem
```

## Quick Start — Client (AI Agent)

```typescript
import { x402Client } from "@x402/core/client";
import { wrapFetchWithPayment } from "@x402/fetch";
import { privateKeyToAccount } from "viem/accounts";
import { registerPauseCommitScheme } from "@pause/x402-commit/client";

const client = new x402Client();

// Register pause-commit as a payment scheme
registerPauseCommitScheme(client, {
  signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`),
  rpcUrl: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY",
});

// Now handles servers that require scheme: "pause-commit"
const fetchWithPayment = wrapFetchWithPayment(fetch, client);
const response = await fetchWithPayment("https://api.example.com/paid");
```

## Quick Start — Server (Resource Provider)

```typescript
import express from "express";
import { createCommitSettlementMiddleware } from "@pause/x402-commit/server";

const app = express();

app.use(createCommitSettlementMiddleware("eip155:1", {
  commitContract: "0x604152D82Fd031cCD8D27F26C5792AC2CD328bF4",
  rpcUrl: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY",
  facilitatorPrivateKey: process.env.FACILITATOR_KEY as `0x${string}`,
}));

// Your x402-protected endpoints here
```

## Manual Intent Management

```typescript
import { PauseCommitClient } from "@pause/x402-commit/client";

const client = new PauseCommitClient(signer, "eip155:1", rpcUrl);

// Create intent (zero gas, funds stay in your wallet)
const intent = await client.createIntent(
  "0xRecipient",
  "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
  "1000000", // $1.00
);

// Check status
const status = await client.getIntentStatus(intent);
// "pending" | "committed" | "revoked" | "expired"

// Cancel before recipient claims
const txHash = await client.revokeIntent(intent);
```

## Smart Contract

PAUSECommit V2 is deployed and verified on Ethereum mainnet:

```
Address: 0x604152D82Fd031cCD8D27F26C5792AC2CD328bF4
Network: Ethereum Mainnet (eip155:1)
```

Core functions:
- `commit()` — Verify signature + transfer funds atomically (~85k gas)
- `revoke()` — Cancel a signed intent (~30k gas)
- `isIntentCommitted()` — Check if claimed
- `isIntentRevoked()` — Check if cancelled

## Combined with @pause/x402-risk

For maximum safety, use both packages together:

```typescript
import { registerPauseCommitScheme } from "@pause/x402-commit/client";
import { createRiskGuard, wrapFetchWithRiskGuard } from "@pause/x402-risk/client";

// Risk guard scores EVERY payTo address
const guard = createRiskGuard({ minScore: 40 });

// Commit scheme adds cancellation for pause-commit servers
registerPauseCommitScheme(client, { signer, rpcUrl });

// Double protection: risk scoring + cancellable payments
const safeFetch = wrapFetchWithRiskGuard(fetchWithPayment, guard);
```

## Links

- [PAUSE Platform](https://pausesecure.com)
- [Free Scanner](https://pausescan.com)
- [x402 Protocol](https://x402.org)
- [PAUSECommit V2 on Etherscan](https://etherscan.io/address/0x604152D82Fd031cCD8D27F26C5792AC2CD328bF4)
- [PAUSE Commit x402 Proposal](https://pausesecure.com/x402-proposal)

## License

MIT — PAUSE (Pre-Authorization Unified Security Engine)