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 networks

View full source code for all scripts in our GitHub Repository.

Quick Start

🦀 Now on ClawHub! Install via clawhub.ai/ivaavimusic/x402-layer

Install via ClawHub (recommended) or self-hosted:

# Via ClawHub (recommended)
clawhub install ivaavimusic/x402-layer

# Or via self-hosted 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-layer

Or view the skill manifest for manual installation.

Environment Setup

# For Base (EVM) - Recommended
export PRIVATE_KEY="0x..."
export WALLET_ADDRESS="0x..."

# For Solana (Optional)
export SOLANA_SECRET_KEY="[1,2,3,...]"  # JSON array

Skill API Endpoints

Access individual files directly via our API:

EndpointDescription
/skill/x402-layerJSON manifest with file list
/skill/x402-layer/installShell install script
/skill/x402-layer/SKILL.mdMain skill instructions
/skill/x402-layer/requirements.txtPython dependencies
/skill/x402-layer/scripts/{name}.pyIndividual Python scripts

Available Scripts

🛒 Consumer Mode (Buying Services)

ScriptPurpose
pay_base.pyPay for endpoints on Base (100% reliable)
pay_solana.pyPay for endpoints on Solana (with retry)
consume_credits.pyUse pre-purchased credits (fastest)
consume_product.pyPurchase digital products (files)
check_credits.pyCheck your credit balance
recharge_credits.pyBuy credit packs
discover_marketplace.pyBrowse available services

🏭 Provider Mode (Selling Services)

ScriptPurpose
create_endpoint.pyDeploy new endpoint ($5 fee)
manage_endpoint.pyView/update your endpoints
topup_endpoint.pyAdd credits to YOUR endpoint
list_on_marketplace.pyPublish endpoint publicly

Usage Examples

Pay for an Endpoint

# Pay with Base (recommended - 100% success rate)
python scripts/pay_base.py https://api.x402layer.cc/e/weather-data

# Pay with Solana (includes retry logic)
python scripts/pay_solana.py https://api.x402layer.cc/e/weather-data

Use 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-data

Create Your Own Endpoint

# Deploy a monetized endpoint ($5 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"

🔐 Security: API Key Verification

When you create an endpoint, x402 acts as a proxy. You MUST verify requests are coming from x402.

  1. Get API Key: Saved from create_endpoint.py output.
  2. Verify Headers: Check for x-api-key: YOUR_KEY in every request.

Known Issues

⚠️ 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.

Resources

Skill Metadata

Slugx402-layer
Version1.0.0
NetworksBase (EVM), Solana
CurrencyUSDC