Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Agent Payment X402

ASecurity

Use when adding x402 payment execution to AI agents - paying 402-gated APIs, enforcing per-task spending budgets, or charging agents for an API. Covers the agentwallet-sdk MCP server (Base), OKX Agent Payments Protocol (X Layer, eip155:196), seller SDK doc locations per language, and fail-closed budget enforcement.

2 stars
0 votes
0 copies
0 views
Added 9/19/2026
ai-agentstypescriptpythonrustgojavanextjsexpressrailsspringgit

Works with

cliapimcp

Security Analysis

A92/100
mediumInstalls packages at runtime which could introduce malicious dependencies

Scanned 9/19/2026

Install to Claude Code

$npx -y skills add Mixard/fable-pack --skill agent-payment-x402 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Agent Payment X402?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Agent Payment X402
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mixard-agent-payment-x402/badge)](https://www.skillsdirectory.com/skills/mixard-agent-payment-x402)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: agent-payment-x402
description: Use when adding x402 payment execution to AI agents - paying 402-gated APIs, enforcing per-task spending budgets, or charging agents for an API. Covers the agentwallet-sdk MCP server (Base), OKX Agent Payments Protocol (X Layer, eip155:196), seller SDK doc locations per language, and fail-closed budget enforcement.
---

# Agent Payment Execution (x402)

x402 extends HTTP 402 (Payment Required) into a machine-negotiable flow: when a server returns `402`, the agent's payment tool negotiates price, checks budget, signs a transaction, and retries - all inside a policy boundary set by the orchestrator. Agents may hold their own keys via ERC-4337 smart accounts (non-custodial), though x402 payments commonly use plain EOA signatures (EIP-712/EIP-3009) instead.

Protocol spec: x402.org

## Integration Decision Tree

| Need | Path |
|------|------|
| Agent pays a 402-gated API on Base (or other agentwallet-supported chain) | `agentwallet-sdk` as an MCP payment server with strict spending policy |
| Agent pays a 402-gated API on X Layer | OKX Agent Payments Protocol from `okx/onchainos-skills`; `okx-x402-payment` is a deprecated legacy alias |
| Your TypeScript API charges agents | OKX Payments TypeScript seller SDK (Express, Hono, Fastify, Next.js) |
| Your Go API charges agents | OKX Payments Go seller SDK (Gin, Echo, `net/http`) |
| Your Rust API charges agents | OKX Payments Rust seller SDK (Axum) |
| Your Java API charges agents | OKX Payments Java seller SDK (Spring Boot 2/3, Java EE, Jakarta) |
| Your Python API charges agents | Check the current `okx/payments` repo first; a Python seller guide may not exist |

Networks:
- `agentwallet-sdk`: Base Sepolia is the safest development default; Base mainnet for production. Confirm current network coverage in the package docs.
- OKX Payments / X Layer: seller docs target X Layer (`eip155:196`) with USDT0 settlement. Fetch current SDK docs before generating production code - packages and facilitator behavior change quickly.

## MCP Setup: agentwallet-sdk

Pin the version - this tool manages private keys, and unpinned `npx` installs are a supply-chain risk. Install globally first (`npm install -g agentwallet-sdk@6.2.1`), because `npx` without `-y` prompts for confirmation and hangs in non-interactive environments.

```json
{
  "mcpServers": {
    "agentpay": {
      "command": "npx",
      "args": ["agentwallet-sdk@6.2.1"]
    }
  }
}
```

Agent-callable tools:

| Tool | Purpose |
|------|---------|
| `get_balance` | Check agent wallet balance |
| `send_payment` | Send payment to address or ENS |
| `check_spending` | Query remaining budget |
| `list_transactions` | Audit trail of all payments |

`set_policy` is orchestrator-only: spending policy must be set by the orchestration layer before delegating, never exposed as an agent-callable tool, or the agent could escalate its own limits.

A `SpendingPolicy` enforces: per-task budget, per-session budget, allowlisted recipients, and rate limits (max transactions per minute/hour).

## OKX Agent Payments Protocol (X Layer)

Buyer-side agent flows:
1. Reference the current `okx/onchainos-skills` repository.
2. Use `skills/okx-agent-payments-protocol/SKILL.md` as the dispatcher; treat `skills/okx-x402-payment/SKILL.md` as a deprecated compatibility alias.
3. Require explicit user confirmation before wallet status checks or payment actions.

Seller-side guides (fetch current versions, do not copy from older docs):

| Runtime | Guide |
|---------|-------|
| TypeScript | `https://raw.githubusercontent.com/okx/payments/main/typescript/SELLER.md` |
| Go | `https://raw.githubusercontent.com/okx/payments/main/go/x402/SELLER.md` |
| Rust | `https://raw.githubusercontent.com/okx/payments/main/rust/x402/SELLER.md` |
| Java | `https://raw.githubusercontent.com/okx/payments/main/java/SELLER.md` |

## Fail-Closed Budget Enforcement (orchestrator side)

```typescript
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";

const walletKey = process.env.WALLET_PRIVATE_KEY;
if (!walletKey) throw new Error("WALLET_PRIVATE_KEY not set - refusing to start payment server");

// Whitelist env vars - never forward all of process.env to a subprocess holding keys
const transport = new StdioClientTransport({
  command: "npx",
  args: ["agentwallet-sdk@6.2.1"],
  env: { PATH: process.env.PATH ?? "", WALLET_PRIVATE_KEY: walletKey },
});
const agentpay = new Client({ name: "orchestrator", version: "1.0.0" });
await agentpay.connect(transport);

// Set policy BEFORE delegating; verify success - silent failure means no controls
const policyResult = await agentpay.callTool({
  name: "set_policy",
  arguments: {
    per_task_budget: 0.50,
    per_session_budget: 5.00,
    allowlisted_recipients: ["api.example.com"],
  },
});
if (policyResult.isError) throw new Error("Failed to set spending policy - do not delegate");

// Pre-tool budget check: every failure path blocks the paid action
async function preToolCheck(apiCost: number): Promise<void> {
  // NaN/Infinity would bypass a < comparison
  if (!Number.isFinite(apiCost) || apiCost < 0) throw new Error(`Invalid apiCost: ${apiCost}`);

  let result;
  try {
    result = await agentpay.callTool({ name: "check_spending" });
  } catch (err) {
    throw new Error(`Payment service unreachable - action blocked: ${err}`);
  }
  if (result.isError) throw new Error("check_spending failed - action blocked");

  const parsed = JSON.parse((result.content as Array<{ text: string }>)[0].text);
  if (!Number.isFinite(parsed?.remaining)) throw new Error("check_spending returned unexpected format - action blocked");
  if (parsed.remaining < apiCost) {
    throw new Error(`Budget exceeded: need $${apiCost}, only $${parsed.remaining} remaining`);
  }
}
```

## Rules

- Set budgets before delegation; never give an agent unlimited spend.
- Fail closed: if the payment tool is unreachable, block the paid action - never fall back to unmetered access.
- Use `list_transactions` in post-task hooks for audit trails.
- Test on Base Sepolia first; switch to mainnet for production.
- Pin exact package versions in MCP configs and verify package integrity before production.

Attribution

MixardMixard
View sourceMore from Mixard →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Ultra-compressed communication mode. Cuts token usage ~75% by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens", "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested.

1023331 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

686011 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3331 votes

catchup

Recovers prior coding-agent session context by running `catchup <agent> --since-compact`, which extracts a clean summary of a previous Codex, Claude Code, Antigravity, OpenCode, or Pi Agent session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", or asks to recover/summarize a previous session before continuing. Do NOT use for the current conversation, git history, or any non-agent log.

611 votes

math-skill

A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling

381 votes
View all in ai-agents →