activepieces
AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
Xpersona Agent
This skill should be used when the user asks to "create x402 endpoint", "deploy monetized API", "pay for API with USDC", "check x402 credits", "consume API c...
clawhub skill install kn73xndw522wt8y06avyd39a8h7ztbeh:x402-layerOverall rank
#62
Adoption
1.7K downloads
Trust
Unknown
Freshness
Feb 28, 2026
Freshness
Last checked Feb 28, 2026
Best For
x402 Singularity Layer is best for general automation workflows where OpenClaw compatibility matters.
Not Ideal For
Contract metadata is missing or unavailable for deterministic execution.
Evidence Sources Checked
CLAWHUB, CLAWHUB, runtime-metrics, public facts pack
Key links, install path, reliability highlights, and the shortest practical read before diving into the crawl record.
Overview
This skill should be used when the user asks to "create x402 endpoint", "deploy monetized API", "pay for API with USDC", "check x402 credits", "consume API c... Capability contract not published. No trust telemetry is available yet. 1.7K downloads reported by the source. Last updated 4/15/2026.
Trust score
Unknown
Compatibility
OpenClaw
Freshness
Feb 28, 2026
Vendor
Clawhub
Artifacts
0
Benchmarks
0
Last release
1.2.1
Install & run
clawhub skill install kn73xndw522wt8y06avyd39a8h7ztbeh:x402-layerInstall using `clawhub skill install kn73xndw522wt8y06avyd39a8h7ztbeh:x402-layer` in an isolated environment before connecting it to live workloads.
No published capability contract is available yet, so validate auth and request/response behavior manually.
Review the upstream CLAWHUB listing at https://clawhub.ai/ivaavimusic/x402-layer before using production credentials.
Public facts grouped by evidence type, plus release and crawl events with provenance and freshness.
Public facts
Vendor
Clawhub
Protocol compatibility
OpenClaw
Latest release
1.2.1
Adoption signal
1.7K downloads
Handshake status
UNKNOWN
Parameters, dependencies, examples, extracted files, editorial overview, and the complete README when available.
Captured outputs
Extracted files
5
Examples
6
Snippets
0
Languages
Unknown
bash
pip install -r {baseDir}/requirements.txtbash
# For Base (EVM) export PRIVATE_KEY="0x..." export WALLET_ADDRESS="0x..." # For Solana (optional) export SOLANA_SECRET_KEY="[1,2,3,...]" # JSON array
bash
# First, install and set up AWAL (one-time setup) npx skills add coinbase/agentic-wallet-skills # Then enable AWAL mode for this skill export X402_USE_AWAL=1
http
x-api-key: <YOUR_API_KEY>
text
User pays $0.01 → Your wallet receives payment → 1 credit deducted from your endpoint
bash
# Pay with Base (EVM) - 100% reliable
python {baseDir}/scripts/pay_base.py https://api.x402layer.cc/e/weather-data
# Pay with Solana - includes retry logic
python {baseDir}/scripts/pay_solana.py https://api.x402layer.cc/e/weather-data
# Pay with Coinbase Agentic Wallet (AWAL)
python {baseDir}/scripts/awal_cli.py pay-url https://api.x402layer.cc/e/weather-dataSKILL.md
---
name: x402-layer
version: 1.2.1
description: |
This skill should be used when the user asks to "create x402 endpoint",
"deploy monetized API", "pay for API with USDC", "check x402 credits",
"consume API credits", "list endpoint on marketplace", "buy API credits",
"topup endpoint", "browse x402 marketplace", "set up webhook",
"receive payment notifications", "manage endpoint webhook",
use "Coinbase Agentic Wallet (AWAL)", or manage x402 Singularity Layer
operations on Base or Solana networks.
homepage: https://studio.x402layer.cc/docs/agentic-access/openclaw-skill
metadata:
clawdbot:
emoji: "⚡"
homepage: https://studio.x402layer.cc
os:
- linux
- darwin
requires:
bins:
- python3
env:
# Core credentials (required for payments)
- WALLET_ADDRESS
- PRIVATE_KEY
# Solana payments (required for Solana network)
- SOLANA_SECRET_KEY
# Provider operations (required for endpoint management)
- X_API_KEY
- API_KEY
# AWAL mode (optional - for Coinbase Agentic Wallet)
- X402_USE_AWAL
- X402_AUTH_MODE
- X402_PREFER_NETWORK
- AWAL_PACKAGE
- AWAL_BIN
- AWAL_FORCE_NPX
allowed-tools:
- Read
- Write
- Edit
- Bash
- WebFetch
---
# x402 Singularity Layer
x402 is a **Web3 payment layer** enabling AI agents to:
- 💰 **Pay** for API access using USDC
- 🚀 **Deploy** monetized endpoints
- 🔍 **Discover** services via marketplace
- 📊 **Manage** endpoints and credits
- 🔔 **Webhooks** — receive payment notifications
**Networks:** Base (EVM) • Solana
**Currency:** USDC
**Protocol:** HTTP 402 Payment Required
---
## Quick Start
### 1. Install Dependencies
```bash
pip install -r {baseDir}/requirements.txt
```
### 2. Set Up Wallet (Choose One Mode)
#### Option A: Private Keys (existing mode)
```bash
# For Base (EVM)
export PRIVATE_KEY="0x..."
export WALLET_ADDRESS="0x..."
# For Solana (optional)
export SOLANA_SECRET_KEY="[1,2,3,...]" # JSON array
```
#### Option B: Coinbase Agentic Wallet (AWAL)
For Base payments without exposing private keys, use Coinbase Agentic Wallet:
```bash
# First, install and set up AWAL (one-time setup)
npx skills add coinbase/agentic-wallet-skills
# Then enable AWAL mode for this skill
export X402_USE_AWAL=1
```
> **Note**: See [Coinbase AWAL docs](https://docs.cdp.coinbase.com/agentic-wallet/welcome) for full setup instructions. You'll need to authenticate and fund your AWAL wallet with USDC on Base.
Once AWAL is configured, all Base payment scripts will automatically use it instead of PRIVATE_KEY.
---
## ⚠️ Security Notice
> **IMPORTANT**: This skill handles private keys for signing blockchain transactions.
>
> - **Never use your primary custody wallet** - Create a dedicated wallet with limited funds
> - **Private keys are used locally only** - They sign transactions locally and are never transmitted
> - **Signed payloads are sent to _meta.json
{
"ownerId": "kn73xndw522wt8y06avyd39a8h7ztbeh",
"slug": "x402-layer",
"version": "1.2.1",
"publishedAt": 1772198367315
}references/agentic-endpoints.md
# Agentic Endpoint Creation Deploy your own monetized API endpoints programmatically. ## Endpoint POST https://api.x402layer.cc/agent/endpoints ## Pricing Create: $1 (4,000 credits included) Top-up: $1 = 500 credits ## Create Flow 1. POST with endpoint config (name, slug, origin_url, chain) 2. Get 402 challenge 3. Sign with EIP-712 4. Send X-Payment header 5. Receive gateway URL and API key ## Top-Up PUT /agent/endpoints/<slug> with topup_amount ## Check Status GET /agent/endpoints/<slug> with x-api-key header
references/credit-based.md
# Credit-Based Access
For high-frequency or latency-sensitive API calls. Pre-purchase credits, consume instantly.
## Why Use Credits?
- Zero latency (no blockchain wait)
- Zero gas fees per request
- Simple header-based access
## Usage
### Check Balance
```bash
curl "https://api.x402layer.cc/api/credits/balance?endpoint=<slug>" \
-H "x-wallet-address: 0xYourWallet..."
```
### Consume Endpoint
```bash
curl "https://api.x402layer.cc/e/<slug>" \
-H "x-wallet-address: 0xYourWallet..." \
-H "Content-Type: application/json" \
-d "{\"prompt\": \"your request\"}"
```
### Insufficient Credits Response
When out of credits, you get a 402 with purchase options:
```json
{
"error": "Insufficient credits",
"current_balance": 0,
"purchase_url": "https://studio.x402layer.cc/pay/credits/<slug>",
"credit_package": {"size": 69, "price": 0.01},
"accepts": [...]
}
```
## Purchasing Credits
Use the standard 402 flow on the `purchase_url`:
1. GET the purchase URL
2. Parse 402 challenge
3. Sign EIP-712 payment
4. Send with X-Payment header
5. Credits added to wallet
## Example Python
```python
import requests
def call_with_credits(url, wallet, data):
resp = requests.post(url,
json=data,
headers={"x-wallet-address": wallet})
if resp.status_code == 402:
print("Need credits!", resp.json()["purchase_url"])
return None
return resp.json()
```
## Scripts
- `check_credits.py` - Query balance
- `consume_with_credits.py` - Use credits
- `recharge_credits.py` - Top up via paymentreferences/marketplace.md
# Marketplace Discovery Browse, search, and consume x402 marketplace services. ## Endpoints | Endpoint | Method | Description | |----------|--------|-------------| | `/api/marketplace` | GET | List all public listings | | `/api/marketplace/search?q=<term>` | GET | Search by keyword | | `/api/marketplace/featured` | GET | Featured listings | | `/api/marketplace/<slug>` | GET | Single endpoint details | | `/api/marketplace/list` | POST | List endpoint (provider) | | `/api/marketplace/unlist` | POST | Remove from marketplace | ## Categories `ai`, `data`, `finance`, `utility`, `social`, `gaming` ## Example: Browse All ```bash python discover_marketplace.py ``` ## Example: Consume Found Service ```bash # Get details for an endpoint python discover_marketplace.py details weather-api # Pay and consume python pay_base.py https://api.x402layer.cc/e/weather-api ``` ## Scripts - `discover_marketplace.py` - Browse/search marketplace - `list_on_marketplace.py` - List/unlist your endpoint
Editorial read
Docs source
CLAWHUB
Editorial quality
thin
Skill: x402 Singularity Layer Owner: ivaavimusic Summary: This skill should be used when the user asks to "create x402 endpoint", "deploy monetized API", "pay for API with USDC", "check x402 credits", "consume API c... Tags: ERC8004:1.2.0, SGL:1.2.1, Stripe:1.2.1, agentic:1.1.3, agentic access:1.2.1, agentic webhooks:1.2.1, api:1.2.1, awal:1.1.1, base:1.2.1, coinbase:1.1.1, credits:1.2.1, latest:1.2.1, marketplace:1.
Skill: x402 Singularity Layer
Owner: ivaavimusic
Summary: This skill should be used when the user asks to "create x402 endpoint", "deploy monetized API", "pay for API with USDC", "check x402 credits", "consume API c...
Tags: ERC8004:1.2.0, SGL:1.2.1, Stripe:1.2.1, agentic:1.1.3, agentic access:1.2.1, agentic webhooks:1.2.1, api:1.2.1, awal:1.1.1, base:1.2.1, coinbase:1.1.1, credits:1.2.1, latest:1.2.1, marketplace:1.2.1, monetization:1.2.1, payments:1.2.1, solana:1.2.1, stripe:1.2.0, usdc:1.2.1, web3:1.2.1, x402:1.2.1, x402 Bazaar:1.2.0, x402 Protocol:1.2.1, x402 Singularity Layer:1.2.1
Version history:
v1.2.1 | 2026-02-27T13:19:27.315Z | user
v1.2.1 (2026-02-27)
Agentic Webhooks Expanded from 1 to 4 event types
Event Types
payment.succeeded Fires on any payment for your endpoint (unchanged)
credits.depleted Fires when endpoint.owner_credits hits 0 Signals that a top-up is required before users receive 503 errors
credits.low Fires when credits drop to 100 or below Early warning to top up proactively
credits.recharged Fires after a successful top-up Returns credits_added, previous_balance, new_balance
Technical
Documentation
v1.2.0 | 2026-02-27T09:03:06.877Z | user
NEW: Agentic Webhooks - endpoint-level payment notifications
NEW SCRIPT: manage_webhook.py
UPDATED: create_endpoint.py
Backend API:
Webhook signature verification: HMAC-SHA256 over "timestamp.body" using your signing_secret Header: X-X402-Signature: t=<ts>,v1=<hex>
Event format: { "id": "<uuid>", "type": "payment.succeeded", "created_at": "<iso8601>", "data": { "source": "endpoint", "source_slug": "my-api", "amount": 0.01, "currency": "USDC", "tx_hash": "0x...", "payer_wallet": "0x...", "network": "base", "status": "confirmed" } }
Credits note: when endpoint credits = 0, no requests go through, so no payments happen and no webhook events fire.
Backward compatible: all existing endpoints unaffected (webhook_url defaults to null, events fire only when webhook_url is set).
v1.1.3 | 2026-02-24T19:42:16.752Z | user
x402-layer 1.1.3
v1.1.2 | 2026-02-15T08:11:11.918Z | auto
x402-layer 1.1.2
v1.1.1 | 2026-02-14T19:26:08.959Z | user
[1.1.1] - 2026-02-15
Bug Fixes:
Changes:
Tested:
v1.1.0 | 2026-02-14T11:53:18.272Z | user
x402-layer v1.1.0 Release Notes Release Date: February 14, 2026
RELEASE SUMMARY
Coinbase Agentic Wallet (AWAL) Integration - AI agents can now make Base network payments without exposing private keys.
NEW FEATURES
Coinbase Agentic Wallet (AWAL) Support:
Environment Variables Added:
SCRIPTS UPDATED
SKILL.MD UPDATES
AWAL DEPENDENCY (Optional)
AWAL is optional. To use AWAL mode, users should first install the Coinbase skill:
npx skills add coinbase/agentic-wallet-skills export X402_USE_AWAL=1
BACKWARD COMPATIBILITY
NETWORK SUPPORT
Base: AWAL Supported, Private Key Supported Solana: AWAL Not supported, Private Key Required
Note: AWAL is a Coinbase CDP product and only supports EVM chains (Base, Ethereum). Solana payments continue to use private-key mode.
SECURITY NOTICE
IMPORTANT: This skill handles private keys for signing blockchain transactions.
TESTING PERFORMED
UPGRADE INSTRUCTIONS (From v1.0.0 to v1.1.0)
No action required for existing users - everything works as before
To use AWAL (optional):
npx skills add coinbase/agentic-wallet-skills npx awal auth login [email protected] export X402_USE_AWAL=1 python scripts/pay_base.py https://api.x402layer.cc/e/endpoint
Skill Slug: x402-layer Version: 1.1.0 Previous Version: 1.0.0
v1.0.1 | 2026-02-02T11:33:13.875Z | user
x402-layer 1.0.1
v1.0.0 | 2026-02-02T10:49:56.579Z | user
pay_base, pay_solana, consume_credits, check_credits, recharge_credits, consume_product, discover_marketplace, create_endpoint, manage_endpoint, topup_endpoint, list_on_marketplace
Archive index:
Archive v1.2.1: 26 files, 42328 bytes
Files: references/agentic-endpoints.md (523b), references/credit-based.md (1561b), references/marketplace.md (1001b), references/pay-per-request.md (4833b), references/payment-signing.md (1864b), requirements.txt (368b), scripts/awal_bridge.py (4378b), scripts/awal_cli.py (4063b), scripts/check_credits.py (1709b), scripts/consume_credits.py (2345b), scripts/consume_product.py (10724b), scripts/create_endpoint.py (9191b), scripts/discover_marketplace.py (3262b), scripts/list_on_marketplace.py (5596b), scripts/manage_endpoint.py (7122b), scripts/manage_webhook.py (4360b), scripts/network_selection.py (2280b), scripts/pay_base.py (2668b), scripts/pay_solana.py (2843b), scripts/recharge_credits.py (4854b), scripts/solana_signing.py (7103b), scripts/topup_endpoint.py (4024b), scripts/wallet_signing.py (5808b), SETUP_AWAL.md (1364b), SKILL.md (14760b), _meta.json (129b)
File v1.2.1:SKILL.md
name: x402-layer version: 1.2.1 description: | This skill should be used when the user asks to "create x402 endpoint", "deploy monetized API", "pay for API with USDC", "check x402 credits", "consume API credits", "list endpoint on marketplace", "buy API credits", "topup endpoint", "browse x402 marketplace", "set up webhook", "receive payment notifications", "manage endpoint webhook", use "Coinbase Agentic Wallet (AWAL)", or manage x402 Singularity Layer operations on Base or Solana networks. homepage: https://studio.x402layer.cc/docs/agentic-access/openclaw-skill metadata: clawdbot: emoji: "⚡" homepage: https://studio.x402layer.cc os: - linux - darwin requires: bins: - python3 env: # Core credentials (required for payments) - WALLET_ADDRESS - PRIVATE_KEY # Solana payments (required for Solana network) - SOLANA_SECRET_KEY # Provider operations (required for endpoint management) - X_API_KEY - API_KEY # AWAL mode (optional - for Coinbase Agentic Wallet) - X402_USE_AWAL - X402_AUTH_MODE - X402_PREFER_NETWORK - AWAL_PACKAGE - AWAL_BIN - AWAL_FORCE_NPX allowed-tools:
x402 is a Web3 payment layer enabling AI agents to:
Networks: Base (EVM) • Solana
Currency: USDC
Protocol: HTTP 402 Payment Required
pip install -r {baseDir}/requirements.txt
# For Base (EVM)
export PRIVATE_KEY="0x..."
export WALLET_ADDRESS="0x..."
# For Solana (optional)
export SOLANA_SECRET_KEY="[1,2,3,...]" # JSON array
For Base payments without exposing private keys, use Coinbase Agentic Wallet:
# First, install and set up AWAL (one-time setup)
npx skills add coinbase/agentic-wallet-skills
# Then enable AWAL mode for this skill
export X402_USE_AWAL=1
Note: See Coinbase AWAL docs for full setup instructions. You'll need to authenticate and fund your AWAL wallet with USDC on Base.
Once AWAL is configured, all Base payment scripts will automatically use it instead of PRIVATE_KEY.
IMPORTANT: This skill handles private keys for signing blockchain transactions.
- Never use your primary custody wallet - Create a dedicated wallet with limited funds
- Private keys are used locally only - They sign transactions locally and are never transmitted
- Signed payloads are sent to api.x402layer.cc - Payment signatures and wallet addresses are transmitted to settle payments
- For testing: Use a throwaway wallet with minimal USDC ($1-5 is enough for testing)
- API Keys: When you create an endpoint, store the returned API key securely
- Review the code: All scripts are auditable in the
scripts/directory
| Script | Purpose |
|--------|---------|
| pay_base.py | Pay for endpoint on Base network |
| pay_solana.py | Pay for endpoint on Solana network |
| consume_credits.py | Use pre-purchased credits (fast) |
| consume_product.py | Purchase digital products (files) |
| awal_cli.py | Run Coinbase Agentic Wallet CLI commands (auth, bazaar, pay, discover) |
| check_credits.py | Check your credit balance |
| recharge_credits.py | Buy credit packs for an endpoint |
| discover_marketplace.py | Browse available services |
| Script | Purpose |
|--------|---------|
| create_endpoint.py | Deploy new monetized endpoint ($1) |
| manage_endpoint.py | View/update your endpoints |
| topup_endpoint.py | Recharge YOUR endpoint with credits |
| list_on_marketplace.py | Update marketplace listing |
| manage_webhook.py | Set/update/remove webhook URL |
[!IMPORTANT] When you create an endpoint, x402 acts as a proxy to your origin server. You MUST verify that requests are coming from x402.
create_endpoint.py.x-api-key: <YOUR_API_KEY>
If the header is missing or incorrect, reject the request (401 Unauthorized).[!WARNING] Credits are NOT test credits! They are consumed with every API request.
User pays $0.01 → Your wallet receives payment → 1 credit deducted from your endpoint
| Item | Value | |------|-------| | Creation cost | $1 (one-time) | | Starting credits | 4,000 credits | | Recharge rate | 500 credits per $1 | | Consumption | 1 credit per API request | | Your earnings | Whatever price you set per call |
topup_endpoint.pyYour endpoint stops working and returns an error. Users cannot access it until you recharge.
# Pay with Base (EVM) - 100% reliable
python {baseDir}/scripts/pay_base.py https://api.x402layer.cc/e/weather-data
# Pay with Solana - includes retry logic
python {baseDir}/scripts/pay_solana.py https://api.x402layer.cc/e/weather-data
# Pay with Coinbase Agentic Wallet (AWAL)
python {baseDir}/scripts/awal_cli.py pay-url https://api.x402layer.cc/e/weather-data
Pre-purchase credits for instant access without blockchain latency:
# Check your balance
python {baseDir}/scripts/check_credits.py weather-data
# Buy credits (consumer purchasing credits)
python {baseDir}/scripts/recharge_credits.py weather-data pack_100
# Use credits for instant access
python {baseDir}/scripts/consume_credits.py https://api.x402layer.cc/e/weather-data
# Browse all services
python {baseDir}/scripts/discover_marketplace.py
# Search by keyword
python {baseDir}/scripts/discover_marketplace.py search weather
# AWAL bazaar discovery
python {baseDir}/scripts/awal_cli.py run bazaar list
Deploy your own monetized API:
Basic (not listed on marketplace):
python {baseDir}/scripts/create_endpoint.py my-api "My AI Service" https://api.example.com 0.01 --no-list
With marketplace listing (recommended):
python {baseDir}/scripts/create_endpoint.py my-api "My AI Service" https://api.example.com 0.01 \
--category ai \
--description "AI-powered data analysis API" \
--logo https://example.com/logo.png \
--banner https://example.com/banner.jpg
Available categories: ai, data, finance, utility, social, gaming
Note: Save the
API Keyfrom the output and use it to secure your origin server.
⚠️ IMPORTANT - How Credits Work:
- Cost: $1 one-time, includes 4,000 credits (NOT test credits!)
- Consumption: 1 credit is deducted for each API request to your endpoint
- When credits reach 0: Your endpoint stops working until you recharge
- Recharge: Use
topup_endpoint.pyto add more credits ($1 = 500 credits)- Users pay YOU: Each user payment goes to your wallet, then 1 credit is used
Includes 4,000 starting credits.
# List your endpoints
python {baseDir}/scripts/manage_endpoint.py list
# View stats
python {baseDir}/scripts/manage_endpoint.py stats my-api
# Update price
python {baseDir}/scripts/manage_endpoint.py update my-api --price 0.02
Your endpoint consumes 1 credit per request. When credits run out, it stops working. Recharge to keep it active:
# Add $10 worth of credits (5,000 credits at 500 credits/$1)
python {baseDir}/scripts/topup_endpoint.py my-api 10
# Check remaining credits first
python {baseDir}/scripts/manage_endpoint.py stats my-api
⚠️ Remember:
topup_endpoint.pyis for providers to recharge THEIR endpoint.recharge_credits.pyis for consumers to buy credits at someone else's endpoint.
Marketplace listing can be done during creation OR separately afterward:
Option 1: During Creation (Recommended)
python {baseDir}/scripts/create_endpoint.py my-api "My API" https://api.example.com 0.01 \
--category ai \
--description "AI-powered analysis" \
--logo https://example.com/logo.png \
--banner https://example.com/banner.jpg
Option 2: After Creation (Update or List Later)
# List or update marketplace listing
python {baseDir}/scripts/list_on_marketplace.py my-api \
--category ai \
--description "AI-powered analysis" \
--logo https://example.com/logo.png \
--banner https://example.com/banner.jpg
# Unlist from marketplace
python {baseDir}/scripts/list_on_marketplace.py my-api --unlist
Tip: Use
list_on_marketplace.pyto update your listing anytime - change category, description, or images without recreating the endpoint.
Receive payment.succeeded events when someone pays for your endpoint. Optional — not required for endpoints to work.
Set webhook at creation time:
python {baseDir}/scripts/create_endpoint.py my-api "My API" https://api.example.com 0.01 \
--webhook-url https://my-server.com/webhook
Add or update webhook on existing endpoint:
python {baseDir}/scripts/manage_webhook.py set my-api https://my-server.com/webhook
Check webhook status:
python {baseDir}/scripts/manage_webhook.py info my-api
Remove webhook:
python {baseDir}/scripts/manage_webhook.py remove my-api
⚠️ IMPORTANT: The
signing_secretis returned only once when you set a webhook. Save it immediately.
| Event | When | Key Fields |
|-------|------|-----------|
| payment.succeeded | Any payment for your endpoint | amount, tx_hash, payer_wallet, network |
| credits.depleted | Owner credits hit 0 | remaining_credits, topup_endpoint |
| credits.low | Credits drop to ≤100 | remaining_credits |
| credits.recharged | Top-up payment succeeds | credits_added, new_balance, amount_paid |
Your endpoint receives POST requests with:
Content-Type: application/json
X-X402-Event: <event_type>
X-X402-Signature: t=<timestamp>,v1=<hmac_sha256>
payment.succeeded example:
{
"id": "event-uuid",
"type": "payment.succeeded",
"created_at": "2026-01-01T00:00:00.000Z",
"data": {
"source": "endpoint",
"source_slug": "my-api",
"amount": 0.01,
"currency": "USDC",
"tx_hash": "0x...",
"payer_wallet": "0x...",
"network": "base",
"status": "confirmed"
}
}
credits.depleted example:
{
"type": "credits.depleted",
"data": {
"source": "endpoint",
"source_slug": "my-api",
"remaining_credits": 0,
"message": "Endpoint credits exhausted. Top up to resume service."
}
}
credits.recharged example:
{
"type": "credits.recharged",
"data": {
"source": "endpoint",
"source_slug": "my-api",
"credits_added": 5000,
"previous_balance": 0,
"new_balance": 5000,
"amount_paid": 10,
"currency": "USDC"
}
}
import hmac, hashlib
def verify(secret, timestamp, body, received_sig):
expected = hmac.new(secret.encode(), f"{timestamp}.{body}".encode(), hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, received_sig)
When credits = 0, no requests go through, so no payments happen and no webhook events fire. Self-regulating.
Uses USDC TransferWithAuthorization (EIP-3009):
Uses VersionedTransaction with MessageV0:
extra.feePayer)TransferChecked instruction| Variable | Required For | Description |
|----------|--------------|-------------|
| PRIVATE_KEY | Base payments (private-key mode) | EVM private key (0x...) |
| WALLET_ADDRESS | All operations | Your wallet address |
| SOLANA_SECRET_KEY | Solana payments | JSON array of bytes |
| X402_USE_AWAL | AWAL mode | Set 1 to enable Coinbase Agentic Wallet for Base |
| X402_AUTH_MODE | Auth selection (optional) | auto, private-key, or awal (default: auto) |
| X402_PREFER_NETWORK | Network selection (optional) | base or solana (default: base) |
| AWAL_PACKAGE | AWAL mode (optional) | NPM package/version for AWAL CLI (default: [email protected]) |
| AWAL_BIN | AWAL mode (optional) | Preinstalled awal binary path/name |
| AWAL_FORCE_NPX | AWAL mode (optional) | Set 1 to force npx even when awal binary exists |
https://api.x402layer.cc/e/{slug}https://api.x402layer.cc/api/marketplacehttps://api.x402layer.cc/api/credits/*https://api.x402layer.cc/agent/*⚠️ Solana payments have ~75% success rate due to facilitator-side fee payer infrastructure issue. Retry logic is included in pay_solana.py. Base (EVM) payments are 100% reliable and recommended for production.
File v1.2.1:_meta.json
{ "ownerId": "kn73xndw522wt8y06avyd39a8h7ztbeh", "slug": "x402-layer", "version": "1.2.1", "publishedAt": 1772198367315 }
File v1.2.1:references/agentic-endpoints.md
Deploy your own monetized API endpoints programmatically.
POST https://api.x402layer.cc/agent/endpoints
Create: $1 (4,000 credits included) Top-up: $1 = 500 credits
PUT /agent/endpoints/<slug> with topup_amount
GET /agent/endpoints/<slug> with x-api-key header
File v1.2.1:references/credit-based.md
For high-frequency or latency-sensitive API calls. Pre-purchase credits, consume instantly.
curl "https://api.x402layer.cc/api/credits/balance?endpoint=<slug>" \
-H "x-wallet-address: 0xYourWallet..."
curl "https://api.x402layer.cc/e/<slug>" \
-H "x-wallet-address: 0xYourWallet..." \
-H "Content-Type: application/json" \
-d "{\"prompt\": \"your request\"}"
When out of credits, you get a 402 with purchase options:
{
"error": "Insufficient credits",
"current_balance": 0,
"purchase_url": "https://studio.x402layer.cc/pay/credits/<slug>",
"credit_package": {"size": 69, "price": 0.01},
"accepts": [...]
}
Use the standard 402 flow on the purchase_url:
import requests
def call_with_credits(url, wallet, data):
resp = requests.post(url,
json=data,
headers={"x-wallet-address": wallet})
if resp.status_code == 402:
print("Need credits!", resp.json()["purchase_url"])
return None
return resp.json()
check_credits.py - Query balanceconsume_with_credits.py - Use creditsrecharge_credits.py - Top up via paymentFile v1.2.1:references/marketplace.md
Browse, search, and consume x402 marketplace services.
| Endpoint | Method | Description |
|----------|--------|-------------|
| /api/marketplace | GET | List all public listings |
| /api/marketplace/search?q=<term> | GET | Search by keyword |
| /api/marketplace/featured | GET | Featured listings |
| /api/marketplace/<slug> | GET | Single endpoint details |
| /api/marketplace/list | POST | List endpoint (provider) |
| /api/marketplace/unlist | POST | Remove from marketplace |
ai, data, finance, utility, social, gaming
python discover_marketplace.py
# Get details for an endpoint
python discover_marketplace.py details weather-api
# Pay and consume
python pay_base.py https://api.x402layer.cc/e/weather-api
discover_marketplace.py - Browse/search marketplacelist_on_marketplace.py - List/unlist your endpointFile v1.2.1:references/pay-per-request.md
Pay-Per-Request uses the HTTP 402 Payment Required status code to negotiate payment for each individual API call.
x402 uses EIP-712 typed data signatures, NOT raw ERC20 transfers.
The facilitator validates and broadcasts the payment. You only need to sign a permit.
If you do not want local private-key signing, use AWAL:
python {baseDir}/scripts/awal_cli.py run auth login [email protected]
python {baseDir}/scripts/awal_cli.py run auth verify <flow_id> <otp>
python {baseDir}/scripts/awal_cli.py pay-url https://api.x402layer.cc/e/my-endpoint
curl https://api.x402layer.cc/e/my-endpoint
{
"x402Version": 1,
"accepts": [
{
"scheme": "exact",
"network": "base",
"maxAmountRequired": "10000",
"payTo": "0xCD95802A4aBddD75A5750DD2d6935007eF268275",
"asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"extra": {
"name": "USD Coin",
"version": "2"
}
},
{
"scheme": "exact",
"network": "solana",
"maxAmountRequired": "10000",
"payTo": "3rcdSzTam4h5e6UN2USv5L2t9R4Ah466B4mHgxRVEqCx",
"asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"extra": {
"feePayer": "BENrLoUbndxoNMUS5JXApGMtNykLjFXXixMtpDwDR9SP"
}
}
]
}
import os
import time
import json
import base64
from eth_account import Account
from eth_account.messages import encode_typed_data
def sign_x402_payment(challenge, wallet_address, private_key):
"""Sign x402 payment using EIP-712 (NOT raw ERC20 transfer)"""
# Find Base option
base_option = next((a for a in challenge["accepts"] if a["network"] == "base"), None)
if not base_option:
raise ValueError("No Base payment option")
# Domain from extra field
extra = base_option.get("extra", {})
domain = {
"name": extra.get("name", "USD Coin"),
"version": extra.get("version", "2"),
"chainId": 8453,
"verifyingContract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
}
# EIP-712 types for TransferWithAuthorization
types = {
"TransferWithAuthorization": [
{"name": "from", "type": "address"},
{"name": "to", "type": "address"},
{"name": "value", "type": "uint256"},
{"name": "validAfter", "type": "uint256"},
{"name": "validBefore", "type": "uint256"},
{"name": "nonce", "type": "bytes32"},
]
}
# Message data
nonce = os.urandom(32)
message = {
"from": wallet_address,
"to": base_option["payTo"],
"value": int(base_option["maxAmountRequired"]),
"validAfter": 0,
"validBefore": int(time.time()) + 3600,
"nonce": nonce,
}
# Sign
encoded = encode_typed_data(domain, types, message)
signed = Account.sign_message(encoded, private_key)
# Build X-Payment payload
payment_obj = {
"x402Version": 1,
"scheme": "exact",
"network": "base",
"payload": {
"signature": signed.signature.hex(),
"from": wallet_address,
"to": base_option["payTo"],
"value": str(message["value"]),
"validAfter": str(message["validAfter"]),
"validBefore": str(message["validBefore"]),
"nonce": "0x" + nonce.hex(),
}
}
return base64.b64encode(json.dumps(payment_obj).encode()).decode()
import requests
x_payment = sign_x402_payment(challenge, wallet, key)
response = requests.get(url, headers={"X-Payment": x_payment})
print(response.json())
Even if amount is 0, you MUST still send a signed payload. This authenticates the caller.
Solana uses SPL Token transfers (not EIP-712). The transaction must include the feePayer from challenge.
from solders.keypair import Keypair
from solders.transaction import Transaction
from solders.pubkey import Pubkey
from spl.token.instructions import transfer_checked
import base64
# Build SPL transfer transaction
# Include feePayer from challenge extra
# Serialize and base64 encode
| Error | Cause | Fix | |-------|-------|-----| | "Invalid signature" | Using raw transfer() | Use EIP-712 signing | | "Nonce already used" | Replay attack | Generate fresh random nonce | | "validBefore expired" | Timeout | Set validBefore = now + 3600 | | "Wrong domain" | Bad name/version | Use "USD Coin" v2 for Base USDC |
File v1.2.1:references/payment-signing.md
x402 uses EIP-712 typed data signatures for TransferWithAuthorization. The facilitator verifies signatures and settles the payment.
domain = {
"name": "USD Coin",
"version": "2",
"chainId": 8453,
"verifyingContract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
}
types = {
"TransferWithAuthorization": [
{"name": "from", "type": "address"},
{"name": "to", "type": "address"},
{"name": "value", "type": "uint256"},
{"name": "validAfter", "type": "uint256"},
{"name": "validBefore", "type": "uint256"},
{"name": "nonce", "type": "bytes32"},
]
}
from eth_account import Account
from eth_account.messages import encode_typed_data
import os, time
message = {
"from": wallet,
"to": challenge["payTo"],
"value": int(challenge["maxAmountRequired"]),
"validAfter": 0,
"validBefore": int(time.time()) + 3600,
"nonce": os.urandom(32),
}
encoded = encode_typed_data(domain, types, message)
signed = Account.sign_message(encoded, private_key)
Solana uses SPL Token transfers with base64 encoding.
You can avoid direct key management by using AWAL:
python {baseDir}/scripts/awal_cli.py run auth login [email protected]
python {baseDir}/scripts/awal_cli.py run auth verify <flow_id> <otp>
python {baseDir}/scripts/awal_cli.py pay-url https://api.x402layer.cc/e/weather-data
AWAL package version can be pinned:
export AWAL_PACKAGE="[email protected]"
Base64 encode the payment JSON:
import json, base64
x_payment = base64.b64encode(json.dumps(payload).encode()).decode()
File v1.2.1:SETUP_AWAL.md
To use the x402-layer skill with Coinbase Agentic Wallet (AWAL) for Base payments, you need to install the awal CLI tool.
Installing globally allows you to run awal commands directly from any directory.
npm install -g awal
Verify installation:
awal --version
You can run commands without installing awal globally by prefixing with npx.
npx awal --version
Login: Start the authentication process. You will receive an email with an OTP.
# If installed globally:
awal auth login [email protected]
# If using npx:
npx awal auth login [email protected]
Verify: Check your email for the OTP and complete the login.
# Replace <flow-id> and <otp-code> with values from the login step and email.
awal auth verify <flow-id> <otp-code>
Check Status: Confirm you are logged in.
awal status
Once setup, ensure you export the necessary environment variable to enable AWAL mode in the scripts:
export X402_USE_AWAL=1
File v1.2.1:requirements.txt
eth-account>=0.10.0 web3>=6.0.0
requests>=2.28.0
python-dotenv>=1.0.0
Archive v1.2.0: 26 files, 42062 bytes
Files: references/agentic-endpoints.md (523b), references/credit-based.md (1561b), references/marketplace.md (1001b), references/pay-per-request.md (4833b), references/payment-signing.md (1864b), requirements.txt (368b), scripts/awal_bridge.py (4378b), scripts/awal_cli.py (4063b), scripts/check_credits.py (1709b), scripts/consume_credits.py (2345b), scripts/consume_product.py (10724b), scripts/create_endpoint.py (9191b), scripts/discover_marketplace.py (3262b), scripts/list_on_marketplace.py (5596b), scripts/manage_endpoint.py (7122b), scripts/manage_webhook.py (4360b), scripts/network_selection.py (2280b), scripts/pay_base.py (2668b), scripts/pay_solana.py (2843b), scripts/recharge_credits.py (4854b), scripts/solana_signing.py (7103b), scripts/topup_endpoint.py (4024b), scripts/wallet_signing.py (5808b), SETUP_AWAL.md (1364b), SKILL.md (13800b), _meta.json (129b)
File v1.2.0:SKILL.md
name: x402-layer version: 1.2.0 description: | This skill should be used when the user asks to "create x402 endpoint", "deploy monetized API", "pay for API with USDC", "check x402 credits", "consume API credits", "list endpoint on marketplace", "buy API credits", "topup endpoint", "browse x402 marketplace", "set up webhook", "receive payment notifications", "manage endpoint webhook", use "Coinbase Agentic Wallet (AWAL)", or manage x402 Singularity Layer operations on Base or Solana networks. homepage: https://studio.x402layer.cc/docs/agentic-access/openclaw-skill metadata: clawdbot: emoji: "⚡" homepage: https://studio.x402layer.cc os: - linux - darwin requires: bins: - python3 env: # Core credentials (required for payments) - WALLET_ADDRESS - PRIVATE_KEY # Solana payments (required for Solana network) - SOLANA_SECRET_KEY # Provider operations (required for endpoint management) - X_API_KEY - API_KEY # AWAL mode (optional - for Coinbase Agentic Wallet) - X402_USE_AWAL - X402_AUTH_MODE - X402_PREFER_NETWORK - AWAL_PACKAGE - AWAL_BIN - AWAL_FORCE_NPX allowed-tools:
x402 is a Web3 payment layer enabling AI agents to:
Networks: Base (EVM) • Solana
Currency: USDC
Protocol: HTTP 402 Payment Required
pip install -r {baseDir}/requirements.txt
# For Base (EVM)
export PRIVATE_KEY="0x..."
export WALLET_ADDRESS="0x..."
# For Solana (optional)
export SOLANA_SECRET_KEY="[1,2,3,...]" # JSON array
For Base payments without exposing private keys, use Coinbase Agentic Wallet:
# First, install and set up AWAL (one-time setup)
npx skills add coinbase/agentic-wallet-skills
# Then enable AWAL mode for this skill
export X402_USE_AWAL=1
Note: See Coinbase AWAL docs for full setup instructions. You'll need to authenticate and fund your AWAL wallet with USDC on Base.
Once AWAL is configured, all Base payment scripts will automatically use it instead of PRIVATE_KEY.
IMPORTANT: This skill handles private keys for signing blockchain transactions.
- Never use your primary custody wallet - Create a dedicated wallet with limited funds
- Private keys are used locally only - They sign transactions locally and are never transmitted
- Signed payloads are sent to api.x402layer.cc - Payment signatures and wallet addresses are transmitted to settle payments
- For testing: Use a throwaway wallet with minimal USDC ($1-5 is enough for testing)
- API Keys: When you create an endpoint, store the returned API key securely
- Review the code: All scripts are auditable in the
scripts/directory
| Script | Purpose |
|--------|---------|
| pay_base.py | Pay for endpoint on Base network |
| pay_solana.py | Pay for endpoint on Solana network |
| consume_credits.py | Use pre-purchased credits (fast) |
| consume_product.py | Purchase digital products (files) |
| awal_cli.py | Run Coinbase Agentic Wallet CLI commands (auth, bazaar, pay, discover) |
| check_credits.py | Check your credit balance |
| recharge_credits.py | Buy credit packs for an endpoint |
| discover_marketplace.py | Browse available services |
| Script | Purpose |
|--------|---------|
| create_endpoint.py | Deploy new monetized endpoint ($1) |
| manage_endpoint.py | View/update your endpoints |
| topup_endpoint.py | Recharge YOUR endpoint with credits |
| list_on_marketplace.py | Update marketplace listing |
| manage_webhook.py | Set/update/remove webhook URL |
[!IMPORTANT] When you create an endpoint, x402 acts as a proxy to your origin server. You MUST verify that requests are coming from x402.
create_endpoint.py.x-api-key: <YOUR_API_KEY>
If the header is missing or incorrect, reject the request (401 Unauthorized).[!WARNING] Credits are NOT test credits! They are consumed with every API request.
User pays $0.01 → Your wallet receives payment → 1 credit deducted from your endpoint
| Item | Value | |------|-------| | Creation cost | $1 (one-time) | | Starting credits | 4,000 credits | | Recharge rate | 500 credits per $1 | | Consumption | 1 credit per API request | | Your earnings | Whatever price you set per call |
topup_endpoint.pyYour endpoint stops working and returns an error. Users cannot access it until you recharge.
# Pay with Base (EVM) - 100% reliable
python {baseDir}/scripts/pay_base.py https://api.x402layer.cc/e/weather-data
# Pay with Solana - includes retry logic
python {baseDir}/scripts/pay_solana.py https://api.x402layer.cc/e/weather-data
# Pay with Coinbase Agentic Wallet (AWAL)
python {baseDir}/scripts/awal_cli.py pay-url https://api.x402layer.cc/e/weather-data
Pre-purchase credits for instant access without blockchain latency:
# Check your balance
python {baseDir}/scripts/check_credits.py weather-data
# Buy credits (consumer purchasing credits)
python {baseDir}/scripts/recharge_credits.py weather-data pack_100
# Use credits for instant access
python {baseDir}/scripts/consume_credits.py https://api.x402layer.cc/e/weather-data
# Browse all services
python {baseDir}/scripts/discover_marketplace.py
# Search by keyword
python {baseDir}/scripts/discover_marketplace.py search weather
# AWAL bazaar discovery
python {baseDir}/scripts/awal_cli.py run bazaar list
Deploy your own monetized API:
Basic (not listed on marketplace):
python {baseDir}/scripts/create_endpoint.py my-api "My AI Service" https://api.example.com 0.01 --no-list
With marketplace listing (recommended):
python {baseDir}/scripts/create_endpoint.py my-api "My AI Service" https://api.example.com 0.01 \
--category ai \
--description "AI-powered data analysis API" \
--logo https://example.com/logo.png \
--banner https://example.com/banner.jpg
Available categories: ai, data, finance, utility, social, gaming
Note: Save the
API Keyfrom the output and use it to secure your origin server.
⚠️ IMPORTANT - How Credits Work:
- Cost: $1 one-time, includes 4,000 credits (NOT test credits!)
- Consumption: 1 credit is deducted for each API request to your endpoint
- When credits reach 0: Your endpoint stops working until you recharge
- Recharge: Use
topup_endpoint.pyto add more credits ($1 = 500 credits)- Users pay YOU: Each user payment goes to your wallet, then 1 credit is used
Includes 4,000 starting credits.
# List your endpoints
python {baseDir}/scripts/manage_endpoint.py list
# View stats
python {baseDir}/scripts/manage_endpoint.py stats my-api
# Update price
python {baseDir}/scripts/manage_endpoint.py update my-api --price 0.02
Your endpoint consumes 1 credit per request. When credits run out, it stops working. Recharge to keep it active:
# Add $10 worth of credits (5,000 credits at 500 credits/$1)
python {baseDir}/scripts/topup_endpoint.py my-api 10
# Check remaining credits first
python {baseDir}/scripts/manage_endpoint.py stats my-api
⚠️ Remember:
topup_endpoint.pyis for providers to recharge THEIR endpoint.recharge_credits.pyis for consumers to buy credits at someone else's endpoint.
Marketplace listing can be done during creation OR separately afterward:
Option 1: During Creation (Recommended)
python {baseDir}/scripts/create_endpoint.py my-api "My API" https://api.example.com 0.01 \
--category ai \
--description "AI-powered analysis" \
--logo https://example.com/logo.png \
--banner https://example.com/banner.jpg
Option 2: After Creation (Update or List Later)
# List or update marketplace listing
python {baseDir}/scripts/list_on_marketplace.py my-api \
--category ai \
--description "AI-powered analysis" \
--logo https://example.com/logo.png \
--banner https://example.com/banner.jpg
# Unlist from marketplace
python {baseDir}/scripts/list_on_marketplace.py my-api --unlist
Tip: Use
list_on_marketplace.pyto update your listing anytime - change category, description, or images without recreating the endpoint.
Receive payment.succeeded events when someone pays for your endpoint. Optional — not required for endpoints to work.
Set webhook at creation time:
python {baseDir}/scripts/create_endpoint.py my-api "My API" https://api.example.com 0.01 \
--webhook-url https://my-server.com/webhook
Add or update webhook on existing endpoint:
python {baseDir}/scripts/manage_webhook.py set my-api https://my-server.com/webhook
Check webhook status:
python {baseDir}/scripts/manage_webhook.py info my-api
Remove webhook:
python {baseDir}/scripts/manage_webhook.py remove my-api
⚠️ IMPORTANT: The
signing_secretis returned only once when you set a webhook. Save it immediately.
Your endpoint receives POST requests with:
Content-Type: application/json
X-X402-Event: payment.succeeded
X-X402-Signature: t=<timestamp>,v1=<hmac_sha256>
{
"id": "event-uuid",
"type": "payment.succeeded",
"created_at": "2026-01-01T00:00:00.000Z",
"data": {
"source": "endpoint",
"source_slug": "my-api",
"amount": 0.01,
"currency": "USDC",
"tx_hash": "0x...",
"payer_wallet": "0x...",
"network": "base",
"status": "confirmed"
}
}
import hmac, hashlib
def verify(secret, timestamp, body, received_sig):
expected = hmac.new(secret.encode(), f"{timestamp}.{body}".encode(), hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, received_sig)
When credits = 0, no requests go through, so no payments happen and no webhook events fire. Self-regulating.
Uses USDC TransferWithAuthorization (EIP-3009):
Uses VersionedTransaction with MessageV0:
extra.feePayer)TransferChecked instruction| Variable | Required For | Description |
|----------|--------------|-------------|
| PRIVATE_KEY | Base payments (private-key mode) | EVM private key (0x...) |
| WALLET_ADDRESS | All operations | Your wallet address |
| SOLANA_SECRET_KEY | Solana payments | JSON array of bytes |
| X402_USE_AWAL | AWAL mode | Set 1 to enable Coinbase Agentic Wallet for Base |
| X402_AUTH_MODE | Auth selection (optional) | auto, private-key, or awal (default: auto) |
| X402_PREFER_NETWORK | Network selection (optional) | base or solana (default: base) |
| AWAL_PACKAGE | AWAL mode (optional) | NPM package/version for AWAL CLI (default: [email protected]) |
| AWAL_BIN | AWAL mode (optional) | Preinstalled awal binary path/name |
| AWAL_FORCE_NPX | AWAL mode (optional) | Set 1 to force npx even when awal binary exists |
https://api.x402layer.cc/e/{slug}https://api.x402layer.cc/api/marketplacehttps://api.x402layer.cc/api/credits/*https://api.x402layer.cc/agent/*⚠️ Solana payments have ~75% success rate due to facilitator-side fee payer infrastructure issue. Retry logic is included in pay_solana.py. Base (EVM) payments are 100% reliable and recommended for production.
File v1.2.0:_meta.json
{ "ownerId": "kn73xndw522wt8y06avyd39a8h7ztbeh", "slug": "x402-layer", "version": "1.2.0", "publishedAt": 1772182986877 }
File v1.2.0:references/agentic-endpoints.md
Deploy your own monetized API endpoints programmatically.
POST https://api.x402layer.cc/agent/endpoints
Create: $1 (4,000 credits included) Top-up: $1 = 500 credits
PUT /agent/endpoints/<slug> with topup_amount
GET /agent/endpoints/<slug> with x-api-key header
File v1.2.0:references/credit-based.md
For high-frequency or latency-sensitive API calls. Pre-purchase credits, consume instantly.
curl "https://api.x402layer.cc/api/credits/balance?endpoint=<slug>" \
-H "x-wallet-address: 0xYourWallet..."
curl "https://api.x402layer.cc/e/<slug>" \
-H "x-wallet-address: 0xYourWallet..." \
-H "Content-Type: application/json" \
-d "{\"prompt\": \"your request\"}"
When out of credits, you get a 402 with purchase options:
{
"error": "Insufficient credits",
"current_balance": 0,
"purchase_url": "https://studio.x402layer.cc/pay/credits/<slug>",
"credit_package": {"size": 69, "price": 0.01},
"accepts": [...]
}
Use the standard 402 flow on the purchase_url:
import requests
def call_with_credits(url, wallet, data):
resp = requests.post(url,
json=data,
headers={"x-wallet-address": wallet})
if resp.status_code == 402:
print("Need credits!", resp.json()["purchase_url"])
return None
return resp.json()
check_credits.py - Query balanceconsume_with_credits.py - Use creditsrecharge_credits.py - Top up via paymentFile v1.2.0:references/marketplace.md
Browse, search, and consume x402 marketplace services.
| Endpoint | Method | Description |
|----------|--------|-------------|
| /api/marketplace | GET | List all public listings |
| /api/marketplace/search?q=<term> | GET | Search by keyword |
| /api/marketplace/featured | GET | Featured listings |
| /api/marketplace/<slug> | GET | Single endpoint details |
| /api/marketplace/list | POST | List endpoint (provider) |
| /api/marketplace/unlist | POST | Remove from marketplace |
ai, data, finance, utility, social, gaming
python discover_marketplace.py
# Get details for an endpoint
python discover_marketplace.py details weather-api
# Pay and consume
python pay_base.py https://api.x402layer.cc/e/weather-api
discover_marketplace.py - Browse/search marketplacelist_on_marketplace.py - List/unlist your endpointFile v1.2.0:references/pay-per-request.md
Pay-Per-Request uses the HTTP 402 Payment Required status code to negotiate payment for each individual API call.
x402 uses EIP-712 typed data signatures, NOT raw ERC20 transfers.
The facilitator validates and broadcasts the payment. You only need to sign a permit.
If you do not want local private-key signing, use AWAL:
python {baseDir}/scripts/awal_cli.py run auth login [email protected]
python {baseDir}/scripts/awal_cli.py run auth verify <flow_id> <otp>
python {baseDir}/scripts/awal_cli.py pay-url https://api.x402layer.cc/e/my-endpoint
curl https://api.x402layer.cc/e/my-endpoint
{
"x402Version": 1,
"accepts": [
{
"scheme": "exact",
"network": "base",
"maxAmountRequired": "10000",
"payTo": "0xCD95802A4aBddD75A5750DD2d6935007eF268275",
"asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"extra": {
"name": "USD Coin",
"version": "2"
}
},
{
"scheme": "exact",
"network": "solana",
"maxAmountRequired": "10000",
"payTo": "3rcdSzTam4h5e6UN2USv5L2t9R4Ah466B4mHgxRVEqCx",
"asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"extra": {
"feePayer": "BENrLoUbndxoNMUS5JXApGMtNykLjFXXixMtpDwDR9SP"
}
}
]
}
import os
import time
import json
import base64
from eth_account import Account
from eth_account.messages import encode_typed_data
def sign_x402_payment(challenge, wallet_address, private_key):
"""Sign x402 payment using EIP-712 (NOT raw ERC20 transfer)"""
# Find Base option
base_option = next((a for a in challenge["accepts"] if a["network"] == "base"), None)
if not base_option:
raise ValueError("No Base payment option")
# Domain from extra field
extra = base_option.get("extra", {})
domain = {
"name": extra.get("name", "USD Coin"),
"version": extra.get("version", "2"),
"chainId": 8453,
"verifyingContract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
}
# EIP-712 types for TransferWithAuthorization
types = {
"TransferWithAuthorization": [
{"name": "from", "type": "address"},
{"name": "to", "type": "address"},
{"name": "value", "type": "uint256"},
{"name": "validAfter", "type": "uint256"},
{"name": "validBefore", "type": "uint256"},
{"name": "nonce", "type": "bytes32"},
]
}
# Message data
nonce = os.urandom(32)
message = {
"from": wallet_address,
"to": base_option["payTo"],
"value": int(base_option["maxAmountRequired"]),
"validAfter": 0,
"validBefore": int(time.time()) + 3600,
"nonce": nonce,
}
# Sign
encoded = encode_typed_data(domain, types, message)
signed = Account.sign_message(encoded, private_key)
# Build X-Payment payload
payment_obj = {
"x402Version": 1,
"scheme": "exact",
"network": "base",
"payload": {
"signature": signed.signature.hex(),
"from": wallet_address,
"to": base_option["payTo"],
"value": str(message["value"]),
"validAfter": str(message["validAfter"]),
"validBefore": str(message["validBefore"]),
"nonce": "0x" + nonce.hex(),
}
}
return base64.b64encode(json.dumps(payment_obj).encode()).decode()
import requests
x_payment = sign_x402_payment(challenge, wallet, key)
response = requests.get(url, headers={"X-Payment": x_payment})
print(response.json())
Even if amount is 0, you MUST still send a signed payload. This authenticates the caller.
Solana uses SPL Token transfers (not EIP-712). The transaction must include the feePayer from challenge.
from solders.keypair import Keypair
from solders.transaction import Transaction
from solders.pubkey import Pubkey
from spl.token.instructions import transfer_checked
import base64
# Build SPL transfer transaction
# Include feePayer from challenge extra
# Serialize and base64 encode
| Error | Cause | Fix | |-------|-------|-----| | "Invalid signature" | Using raw transfer() | Use EIP-712 signing | | "Nonce already used" | Replay attack | Generate fresh random nonce | | "validBefore expired" | Timeout | Set validBefore = now + 3600 | | "Wrong domain" | Bad name/version | Use "USD Coin" v2 for Base USDC |
File v1.2.0:references/payment-signing.md
x402 uses EIP-712 typed data signatures for TransferWithAuthorization. The facilitator verifies signatures and settles the payment.
domain = {
"name": "USD Coin",
"version": "2",
"chainId": 8453,
"verifyingContract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
}
types = {
"TransferWithAuthorization": [
{"name": "from", "type": "address"},
{"name": "to", "type": "address"},
{"name": "value", "type": "uint256"},
{"name": "validAfter", "type": "uint256"},
{"name": "validBefore", "type": "uint256"},
{"name": "nonce", "type": "bytes32"},
]
}
from eth_account import Account
from eth_account.messages import encode_typed_data
import os, time
message = {
"from": wallet,
"to": challenge["payTo"],
"value": int(challenge["maxAmountRequired"]),
"validAfter": 0,
"validBefore": int(time.time()) + 3600,
"nonce": os.urandom(32),
}
encoded = encode_typed_data(domain, types, message)
signed = Account.sign_message(encoded, private_key)
Solana uses SPL Token transfers with base64 encoding.
You can avoid direct key management by using AWAL:
python {baseDir}/scripts/awal_cli.py run auth login [email protected]
python {baseDir}/scripts/awal_cli.py run auth verify <flow_id> <otp>
python {baseDir}/scripts/awal_cli.py pay-url https://api.x402layer.cc/e/weather-data
AWAL package version can be pinned:
export AWAL_PACKAGE="[email protected]"
Base64 encode the payment JSON:
import json, base64
x_payment = base64.b64encode(json.dumps(payload).encode()).decode()
File v1.2.0:SETUP_AWAL.md
To use the x402-layer skill with Coinbase Agentic Wallet (AWAL) for Base payments, you need to install the awal CLI tool.
Installing globally allows you to run awal commands directly from any directory.
npm install -g awal
Verify installation:
awal --version
You can run commands without installing awal globally by prefixing with npx.
npx awal --version
Login: Start the authentication process. You will receive an email with an OTP.
# If installed globally:
awal auth login [email protected]
# If using npx:
npx awal auth login [email protected]
Verify: Check your email for the OTP and complete the login.
# Replace <flow-id> and <otp-code> with values from the login step and email.
awal auth verify <flow-id> <otp-code>
Check Status: Confirm you are logged in.
awal status
Once setup, ensure you export the necessary environment variable to enable AWAL mode in the scripts:
export X402_USE_AWAL=1
File v1.2.0:requirements.txt
eth-account>=0.10.0 web3>=6.0.0
requests>=2.28.0
python-dotenv>=1.0.0
Machine endpoints, contract coverage, trust signals, runtime metrics, benchmarks, and guardrails for agent-to-agent use.
Machine interfaces
Contract coverage
Status
missing
Auth
None
Streaming
No
Data region
Unspecified
Protocol support
Requires: none
Forbidden: none
Guardrails
Operational confidence: low
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/snapshot"
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/contract"
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/trust"
Operational fit
Trust signals
Handshake
UNKNOWN
Confidence
unknown
Attempts 30d
unknown
Fallback rate
unknown
Runtime metrics
Observed P50
unknown
Observed P95
unknown
Rate limit
unknown
Estimated cost
unknown
Do not use if
Raw contract, invocation, trust, capability, facts, and change-event payloads for machine-side inspection.
Contract JSON
{
"contractStatus": "missing",
"authModes": [],
"requires": [],
"forbidden": [],
"supportsMcp": false,
"supportsA2a": false,
"supportsStreaming": false,
"inputSchemaRef": null,
"outputSchemaRef": null,
"dataRegion": null,
"contractUpdatedAt": null,
"sourceUpdatedAt": null,
"freshnessSeconds": null
}Invocation Guide
{
"preferredApi": {
"snapshotUrl": "https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/snapshot",
"contractUrl": "https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/contract",
"trustUrl": "https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/trust"
},
"curlExamples": [
"curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/snapshot\"",
"curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/contract\"",
"curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/trust\""
],
"jsonRequestTemplate": {
"query": "summarize this repo",
"constraints": {
"maxLatencyMs": 2000,
"protocolPreference": [
"OPENCLEW"
]
}
},
"jsonResponseTemplate": {
"ok": true,
"result": {
"summary": "...",
"confidence": 0.9
},
"meta": {
"source": "CLAWHUB",
"generatedAt": "2026-10-09T03:31:33.049Z"
}
},
"retryPolicy": {
"maxAttempts": 3,
"backoffMs": [
500,
1500,
3500
],
"retryableConditions": [
"HTTP_429",
"HTTP_503",
"NETWORK_TIMEOUT"
]
}
}Trust JSON
{
"status": "unavailable",
"handshakeStatus": "UNKNOWN",
"verificationFreshnessHours": null,
"reputationScore": null,
"p95LatencyMs": null,
"successRate30d": null,
"fallbackRate": null,
"attempts30d": null,
"trustUpdatedAt": null,
"trustConfidence": "unknown",
"sourceUpdatedAt": null,
"freshnessSeconds": null
}Capability Matrix
{
"rows": [
{
"key": "OPENCLEW",
"type": "protocol",
"support": "unknown",
"confidenceSource": "profile",
"notes": "Listed on profile"
}
],
"flattenedTokens": "protocol:OPENCLEW|unknown|profile"
}Facts JSON
[
{
"factKey": "vendor",
"category": "vendor",
"label": "Vendor",
"value": "Clawhub",
"href": "https://clawhub.ai/ivaavimusic/x402-layer",
"sourceUrl": "https://clawhub.ai/ivaavimusic/x402-layer",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-04-15T00:45:39.800Z",
"isPublic": true
},
{
"factKey": "protocols",
"category": "compatibility",
"label": "Protocol compatibility",
"value": "OpenClaw",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/contract",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/contract",
"sourceType": "contract",
"confidence": "medium",
"observedAt": "2026-04-15T00:45:39.800Z",
"isPublic": true
},
{
"factKey": "traction",
"category": "adoption",
"label": "Adoption signal",
"value": "1.7K downloads",
"href": "https://clawhub.ai/ivaavimusic/x402-layer",
"sourceUrl": "https://clawhub.ai/ivaavimusic/x402-layer",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-04-15T00:45:39.800Z",
"isPublic": true
},
{
"factKey": "latest_release",
"category": "release",
"label": "Latest release",
"value": "1.2.1",
"href": "https://clawhub.ai/ivaavimusic/x402-layer",
"sourceUrl": "https://clawhub.ai/ivaavimusic/x402-layer",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-02-27T13:19:27.315Z",
"isPublic": true
},
{
"factKey": "handshake_status",
"category": "security",
"label": "Handshake status",
"value": "UNKNOWN",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/trust",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-ivaavimusic-x402-layer/trust",
"sourceType": "trust",
"confidence": "medium",
"observedAt": null,
"isPublic": true
}
]Change Events JSON
[
{
"eventType": "release",
"title": "Release 1.2.1",
"description": "v1.2.1 (2026-02-27) Agentic Webhooks Expanded from 1 to 4 event types Event Types - payment.succeeded Fires on any payment for your endpoint (unchanged) - credits.depleted Fires when endpoint.owner_credits hits 0 Signals that a top-up is required before users receive 503 errors - credits.low Fires when credits drop to 100 or below Early warning to top up proactively - credits.recharged Fires after a successful top-up Returns credits_added, previous_balance, new_balance Technical - Refactored dispatchEndpointWebhook to a generic (eventType, data) signature - credits.depleted and credits.low fire at the per-request deduction site (post-RPC) - credits.recharged fires alongside payment.succeeded on the top-up path - All events use the same HMAC-SHA256 signing as payment.succeeded Documentation - SKILL.md updated with an event type table and example payloads",
"href": "https://clawhub.ai/ivaavimusic/x402-layer",
"sourceUrl": "https://clawhub.ai/ivaavimusic/x402-layer",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-02-27T13:19:27.315Z",
"isPublic": true
}
]Sponsored
Ads related to x402 Singularity Layer and adjacent AI workflows.