OpenClaw x402-Layer Skill
Production-ready skill for OpenClaw agents to interact with x402 Singularity Layer.
✅ Tested with real payments on Base (EVM) and Solana, including the current PayAI-backed Solana flow
Wallet-first ERC-8004 agent flows also support EVM deployments on Ethereum, Polygon, BSC, and Monad through the same scripts by changing --network.
View full source code for all scripts in our GitHub Repository.
Quick Start
v1.11.1 keeps the webhook hardening guidance and adds direct fundraiser campaign management through owner-linked dashboard API keys alongside the PAT-backed MCP path.
Install via the self-hosted skill endpoint:
curl -fsSL https://api.x402layer.cc/skill/x402-layer/install | bash
# Or specify a custom directory
curl -fsSL https://api.x402layer.cc/skill/x402-layer/install | bash -s ./my-skills/x402-layerOr view the skill manifest for manual installation.
Environment Setup
Set only the environment variables needed for the runbook you are using. Read-only discovery does not need any secrets. For signing flows, choose Option A (private keys), Option B (Coinbase Agentic Wallet), or Option C (OpenWallet / OWS). For owner-scoped dashboard management, use either Option D (PAT-backed MCP) or Option E (owner-linked dashboard API key):
# Read-only discovery (no secrets required)
python scripts/discover_marketplace.py
# Option A: Private Keys (traditional mode)
# For Base (EVM) - Recommended for full control
export PRIVATE_KEY="0x..."
export WALLET_ADDRESS="0x..."
# For Solana (Optional)
export SOLANA_SECRET_KEY="base58-or-[1,2,3,...]" # base58 secret or JSON array
export SOLANA_WALLET_ADDRESS="..."
# Option B: Coinbase Agentic Wallet (AWAL) - No private key exposure
# First install the Coinbase skill
npx skills add coinbase/agentic-wallet-skills
# Then enable AWAL mode
export X402_USE_AWAL=1
export WALLET_ADDRESS="0x..." # Still needed for identification
# Option C: OpenWallet / OWS
npm install -g @open-wallet-standard/core
export OWS_WALLET="hackathon-wallet"
python scripts/ows_cli.py pay-url https://api.x402layer.cc/e/weather-data --wallet hackathon-wallet
# Optional MCP owner-scoped dashboard access
export SINGULARITY_PAT="sgl_pat_..."
# Optional direct dashboard API key access
export X_API_KEY="x402_..."
# Only for agent reputation feedback writes
export WORKER_FEEDBACK_API_KEY="..."Optional PAT + MCP Mode
Use SINGULARITY_PAT only when the agent needs owner-scoped dashboard actions like listing all endpoints, creating or updating fundraiser campaigns, updating products, or changing webhooks through Singularity MCP. It is not required for install or normal payment scripts.
Direct dashboard API-key mode
If the agent already has an owner-linked X-API-Key, it can call the direct worker management routes for endpoints, webhooks, and fundraiser campaigns without going through MCP. PAT remains the MCP auth surface; API keys are for the direct worker API.
🔐 AWAL Mode (hardened in v1.3.1)
Use Coinbase Agentic Wallet for Base payments without exposing private keys. Perfect for production agents where key security is critical.
Webhook verification model
Studio seller webhooks use X-X402-Signature, X-X402-Timestamp, X-X402-Event, and X-X402-Event-Id. Verify HMAC-SHA256(timestamp + "." + rawBody) with the webhook signing_secret. Keep legacy raw-secret headers only as fallback for older receivers, and do not confuse the Studio signing secret with app-internal settlement secrets such as x-x402-secret → X402_WEBHOOK_SECRET.
Skill API Endpoints
Access individual files directly via our API:
| Endpoint | Description |
|---|---|
| /skill/x402-layer | JSON manifest with file list |
| /skill/x402-layer/install | Shell install script |
| /skill/x402-layer/SKILL.md | Main skill instructions |
| /skill/x402-layer/requirements.txt | Python dependencies |
| /skill/x402-layer/scripts/{name} | Individual script files (.py and .js) |
Available Scripts
🛒 Consumer Mode (Buying Services)
| Script | Purpose |
|---|---|
| pay_base.py | Pay for endpoints on Base (recommended default) |
| pay_solana.py | Pay for endpoints on Solana with the sponsored PayAI flow |
| consume_credits.py | Use pre-purchased credits (fastest) |
| consume_product.py | Purchase digital products (files) |
| check_credits.py | Check your credit balance |
| recharge_credits.py | Buy credit packs |
| discover_marketplace.py | Browse available services |
🏭 Provider Mode (Selling Services)
| Script | Purpose |
|---|---|
| create_endpoint.py | Deploy new endpoint ($1 fee) |
| manage_endpoint.py | View/update your endpoints |
| topup_endpoint.py | Add credits to YOUR endpoint |
| list_on_marketplace.py | Publish endpoint publicly |
| manage_webhook.py | Set/update/remove endpoint webhook |
| verify_webhook_payment.py | Verify webhook signature + payment receipt genuineness with PyJWT/JWKS |
🪪 Agent Identity & Reputation
| Script | Purpose |
|---|---|
| register_agent.py | Register ERC-8004 (EVM/Solana) with image, version, tags, and endpoint bindings |
| list_my_endpoints.py | List platform endpoints available for ERC-8004 agent binding |
| list_agents.py | List ERC-8004 agents owned by the wallet or linked dashboard user |
| update_agent.py | Update metadata, visibility, and endpoint bindings for an existing agent |
| submit_feedback.py | Write on-chain reputation feedback on the agent's native chain |
Usage Examples
Integrate Payments Into Your App
# 1. Create or reuse a paid endpoint
python scripts/create_endpoint.py my-api "My AI Service" https://api.example.com 0.01
# 2. Add webhook-based fulfillment
python scripts/manage_webhook.py set my-api https://my-server.com/webhook
# 3. Verify the webhook signature + receipt server-side
python scripts/verify_webhook_payment.py \
--body-file ./webhook.json \
--signature 't=1700000000,v1=<hex>' \
--secret '<YOUR_SIGNING_SECRET>' \
--required-source-slug my-api \
--require-receiptPay for an Endpoint
# Pay with Base (recommended default)
python scripts/pay_base.py https://api.x402layer.cc/e/weather-data
# Pay with Solana (PayAI-backed sponsored flow)
python scripts/pay_solana.py https://api.x402layer.cc/e/weather-data
# Pay with AWAL (no private key needed)
export X402_USE_AWAL=1
python scripts/pay_base.py https://api.x402layer.cc/e/weather-dataUse Credits (Fastest)
# Check balance
python scripts/check_credits.py weather-data
# Buy credits
python scripts/recharge_credits.py weather-data pack_100
# Consume with credits (zero blockchain latency)
python scripts/consume_credits.py https://api.x402layer.cc/e/weather-dataCreate Your Own Endpoint
# Deploy a monetized endpoint ($1 one-time fee)
python scripts/create_endpoint.py my-api "My AI Service" https://api.example.com 0.01
# Top up YOUR endpoint with credits
python scripts/topup_endpoint.py my-api 10 # Add $10 worth
# List on marketplace
python scripts/list_on_marketplace.py my-api --category ai --description "AI analysis"Optional MCP Control Plane
{
"mcpServers": {
"singularity": {
"url": "https://mcp.x402layer.cc/mcp",
"transport": "http"
}
}
}When a user provides SINGULARITY_PAT, prefer Singularity MCP for owner-scoped actions like endpoint inventory, fundraiser campaign creation and updates, endpoint updates, product updates, and webhook management. Keep direct scripts for wallet signing, AWAL, OWS, support, and agent-registry flows.
World AgentKit Benefits
# Inspect whether an endpoint advertises a verified human-backed agent wallet benefit
python scripts/discover_marketplace.py details weather-data
# Attempt Base payment with AgentKit if the endpoint offers it
python scripts/pay_base.py https://api.x402layer.cc/e/weather-data --agentkit auto
# Require AgentKit qualification instead of falling back
python scripts/pay_base.py https://api.x402layer.cc/e/weather-data --agentkit requiredXMTP Support Threads
# Authenticate your wallet for support APIs
python scripts/support_auth.py login
# Check support eligibility and open or reuse the thread
python scripts/support_threads.py eligibility endpoint weather-data
python scripts/support_threads.py open endpoint weather-data
# Read and send XMTP support messages
node scripts/xmtp_support.mjs messages <thread_id>
node scripts/xmtp_support.mjs send <thread_id> "Need help with this endpoint"Verify Webhook Payment Genuineness
# Install Python dependencies once
pip install -r requirements.txt
# Verify webhook signature + receipt token
python scripts/verify_webhook_payment.py \
--body-file ./webhook.json \
--signature 't=1700000000,v1=<hex>' \
--secret '<YOUR_SIGNING_SECRET>' \
--required-source-slug my-api \
--require-receiptERC-8004 Registration, Discovery, and Management
python scripts/list_my_endpoints.py
python scripts/register_agent.py \
"My Agent" \
"Autonomous service agent" \
--network baseSepolia \
--image https://example.com/agent.png \
--version 1.10.0 \
--tag finance \
--endpoint-id <ENDPOINT_UUID> \
--custom-endpoint https://api.example.com/agent
python scripts/list_agents.py --network baseSepolia
python scripts/update_agent.py \
--network baseSepolia \
--agent-id 123 \
--version 1.4.1 \
--tag finance \
--endpoint-id <ENDPOINT_UUID> \
--public
# The same EVM flow also supports:
# --network ethereum
# --network polygon
# --network bsc
# --network monad
python scripts/submit_feedback.py🔐 Security: API Key Verification
When you create an endpoint, x402 acts as a proxy. You MUST verify requests are coming from x402.
- Get API Key: Saved from
create_endpoint.pyoutput. - Verify Headers: Check for
x-api-key: YOUR_KEYin every request.
Known Issues
⚠️ Solana payments must use the feePayer returned by the challenge and keep the compute-unit limit within facilitator requirements. The bundled pay_solana.py and solana_signing.py handle that for the current live flow.
Base (EVM) is still the simplest default when you want the least moving parts in production.
Resources
Skill Metadata
| Slug | x402-layer |
| Version | 1.10.0 |
| Networks | Base, Ethereum, Polygon, BSC, Monad, Solana |
| Currency | USDC |