agentic-x402Make x402 payments to access gated APIs and content. Fetch paid resources, check wallet balance, and create payment links. Use when encountering 402 Payment...
Install via ClawdBot CLI:
clawdbot install ya7ya/agentic-x402Pay for x402-gated APIs and content using USDC on Base. This skill enables agents to autonomously make crypto payments when accessing paid web resources.
| Command | Description |
|---------|-------------|
| x402 setup | Create or configure wallet |
| x402 balance | Check USDC and ETH balances |
| x402 pay | Pay for a gated resource |
| x402 fetch | Fetch with auto-payment |
| x402 create-link | Create payment link (seller) |
| x402 link-info | Get payment link details |
npm i -g agentic-x402
Once installed, the x402 command is available globally:
x402 --help
x402 --version
Run the interactive setup to create a new wallet:
x402 setup
This will:
~/.x402/.envImportant: Back up your private key immediately after setup!
Alternatively, set the environment variable directly:
export EVM_PRIVATE_KEY=0x...your_private_key...
Or create a config file:
mkdir -p ~/.x402
echo "EVM_PRIVATE_KEY=0x..." > ~/.x402/.env
chmod 600 ~/.x402/.env
Verify setup:
x402 balance
Use x402 pay to make the payment and access the content:
x402 pay https://api.example.com/paid-endpoint
The command will:
Use x402 fetch for seamless payment handling:
x402 fetch https://api.example.com/data --json
This wraps fetch with x402 payment handling - if the resource requires payment, it's handled automatically.
By default, payments are limited to $10 USD. Override with --max:
x402 pay https://expensive-api.com/data --max 50
Or set globally:
export X402_MAX_PAYMENT_USD=25
Preview payment without executing:
x402 pay https://api.example.com/data --dry-run
Create payment links to monetize your own content using x402-links-server:
Add to .env:
X402_LINKS_API_URL=https://your-x402-links-server.com
Gate a URL:
x402 create-link --name "Premium API" --price 1.00 --url https://api.example.com/premium
Gate text content:
x402 create-link --name "Secret" --price 0.50 --text "The secret message..."
With webhook notification:
x402 create-link --name "Guide" --price 5.00 --url https://mysite.com/guide --webhook https://mysite.com/payment-hook
x402 link-info 0x1234...5678
x402 link-info https://21.cash/pay/0x1234...5678
Check wallet balances.
x402 balance [--json] [--full]
| Flag | Description | Default |
|------|-------------|---------|
| --json | Output as JSON (address, network, chainId, balances) | — |
| --full | Show full wallet address instead of truncated | — |
| -h, --help | Show help | — |
Pay for an x402-gated resource.
x402 pay <url> [options]
| Flag | Description | Default |
|------|-------------|---------|
| | The URL of the x402-gated resource (positional) | required |
| --method | HTTP method | GET |
| --body | Request body (for POST/PUT requests) | — |
| --header | Add custom header (can be used multiple times) | — |
| --max | Maximum payment in USD (overrides config) | from config |
| --dry-run | Show payment details without paying | — |
| -h, --help | Show help | — |
Fetch with automatic payment.
x402 fetch <url> [options]
| Flag | Description | Default |
|------|-------------|---------|
| | The URL to fetch (positional) | required |
| --method | HTTP method | GET |
| --body | Request body (for POST/PUT) | — |
| --header | Add header as "Key: Value" | — |
| --json | Output as JSON only (for piping to other tools) | — |
| --raw | Output raw response body only (no headers or status) | — |
| -h, --help | Show help | — |
Create a payment link.
x402 create-link --name <name> --price <usd> [options]
| Flag | Description | Default |
|------|-------------|---------|
| --name | Name of the payment link | required |
| --price | Price in USD (e.g., "5.00" or "0.10") | required |
| --url | URL to gate behind payment | — |
| --text | Text content to gate behind payment | — |
| --desc | Description of the link | — |
| --webhook | Webhook URL for payment notifications | — |
| --json | Output as JSON | — |
| -h, --help | Show help | — |
Note: Either--urlor--textis required. The link is deployed as a smart contract on Base.
Get payment link details.
x402 link-info <router-address> [--json]
| Flag | Description | Default |
|------|-------------|---------|
| | Router contract address or full payment URL (positional) | required |
| --json | Output as JSON | — |
| -h, --help | Show help | — |
| Variable | Description | Default |
|----------|-------------|---------|
| EVM_PRIVATE_KEY | Wallet private key (0x-prefixed) | required |
| X402_NETWORK | mainnet (Base, chain 8453) or testnet (Base Sepolia, chain 84532) | mainnet |
| X402_MAX_PAYMENT_USD | Safety limit — payments exceeding this are rejected unless --max is used | 10 |
| X402_FACILITATOR_URL | Custom facilitator URL | Coinbase (mainnet) / x402.org (testnet) |
| X402_SLIPPAGE_BPS | Slippage tolerance in basis points (100 bps = 1%) | 50 |
| X402_VERBOSE | Enable verbose logging (1 = on, 0 = off) | 0 |
| X402_LINKS_API_URL | Base URL of x402-links-server (e.g., https://21.cash) | — |
| Network | Chain ID | CAIP-2 ID |
|---------|----------|-----------|
| Base Mainnet | 8453 | eip155:8453 |
| Base Sepolia | 84532 | eip155:84532 |
All payments use USDC (USD Coin) on the selected network.
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA029130x036CbD53842c5426634e7929541eC2318f3dCF7e402 Payment Required + payment detailsThe x402 protocol is gasless for buyers - the facilitator sponsors gas fees.
Set your wallet private key:
export EVM_PRIVATE_KEY=0x...
Or create a .env file in your working directory, or install globally and use ~/.x402/.env.
Increase the limit:
x402 pay https://... --max 50
Fund your wallet with:
Ensure your wallet has funds on the correct network:
X402_NETWORK=mainnet → Base mainnetX402_NETWORK=testnet → Base SepoliaYour private key is stored in ~/.x402/.env. If lost, your funds cannot be recovered.
# Encrypt with GPG
gpg -c ~/.x402/.env
# Creates ~/.x402/.env.gpg - store this backup securely
cat ~/.x402/.env | grep EVM_PRIVATE_KEY
To restore from backup:
mkdir -p ~/.x402
echo "EVM_PRIVATE_KEY=0x...your_backed_up_key..." > ~/.x402/.env
chmod 600 ~/.x402/.env
x402 balance # verify
X402_MAX_PAYMENT_USD to cap exposureX402_NETWORK=testnet with test tokens before mainnet~/.x402/.env has 600 permissions; keep it that wayGenerated Mar 1, 2026
Data aggregators can use this skill to automatically pay for and access premium APIs that require per-request payments, such as financial data feeds or real-time market analytics. The agent can handle 402 Payment Required responses on the fly, ensuring uninterrupted data collection without manual intervention. This is ideal for building automated pipelines that fetch paid content from multiple sources.
Digital creators, such as bloggers or educators, can monetize their exclusive content by creating payment links for articles, videos, or downloadable resources. The skill allows them to gate access behind crypto payments, with webhook notifications for tracking sales. This enables a decentralized revenue stream without relying on traditional payment processors.
Researchers can automate access to paid academic journals or datasets by configuring the agent to handle payments when encountering paywalls. The skill's fetch command can seamlessly retrieve content after payment, streamlining literature reviews or data acquisition. This reduces manual effort and speeds up research workflows in fields like science or social studies.
Game developers can integrate this skill to allow in-game agents to purchase virtual assets or premium features via microtransactions using USDC. The agent can pay for API calls that unlock content, such as special items or levels, directly from the game environment. This supports blockchain-based gaming economies with automated payment handling.
Businesses in regulated industries can use the agent to fetch compliance-related data from paid government or industry databases. The skill can handle payments for accessing up-to-date regulatory documents or reports, ensuring automated and timely compliance checks. This is useful for legal, financial, or healthcare sectors requiring frequent data updates.
Operate a service that proxies access to multiple paid APIs, using this skill to handle payments on behalf of clients. Charge a markup or subscription fee for the convenience of automated payment processing and unified access. This model targets developers who need to integrate various paid resources without managing crypto payments directly.
Build a platform where creators list paid content, and the skill is used to generate and manage payment links for each item. Earn revenue through transaction fees or commissions on sales. This model leverages the skill's link creation and info features to facilitate decentralized content sales.
Purchase bulk access to premium data sources using the skill's payment capabilities, then repackage and resell the data to end-users via APIs or reports. Use the fetch command to automate data retrieval and updates. This model capitalizes on arbitrage opportunities in data markets with automated payment handling.
💬 Integration Tip
Ensure the EVM_PRIVATE_KEY is securely stored and backed up, and test with dry-run payments before live deployments to avoid unexpected costs.
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Clau...
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
Search and analyze your own session logs (older/parent conversations) using jq.
Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linking related objects, enforcing constraints, planning multi-step actions as graph transformations, or when skills need to share state. Trigger on "remember", "what do I know about", "link X to Y", "show dependencies", entity CRUD, or cross-skill data access.
Ultimate AI agent memory system for Cursor, Claude, ChatGPT & Copilot. WAL protocol + vector search + git-notes + cloud backup. Never lose context again. Vibe-coding ready.
Headless browser automation CLI optimized for AI agents with accessibility tree snapshots and ref-based element selection