@pausesecure/x402-commit
v1.0.0
Published
PAUSE Commit Scheme for x402 — two-phase non-custodial payments with cancellation and risk scoring
Maintainers
Readme
@pause/x402-commit
PAUSE Commit Scheme for x402 — two-phase payments you can cancel.
A new payment scheme for the x402 protocol 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, 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
npm install @pause/x402-commit viemQuick Start — Client (AI Agent)
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)
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 hereManual Intent Management
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 claimedisIntentRevoked()— Check if cancelled
Combined with @pause/x402-risk
For maximum safety, use both packages together:
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
License
MIT — PAUSE (Pre-Authorization Unified Security Engine)
