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-layerOr 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 arraySkill 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}.py | Individual Python scripts |
Available Scripts
🛒 Consumer Mode (Buying Services)
| Script | Purpose |
|---|---|
| pay_base.py | Pay for endpoints on Base (100% reliable) |
| pay_solana.py | Pay for endpoints on Solana (with retry) |
| 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 ($5 fee) |
| manage_endpoint.py | View/update your endpoints |
| topup_endpoint.py | Add credits to YOUR endpoint |
| list_on_marketplace.py | Publish 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-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 ($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.
- Get API Key: Saved from
create_endpoint.pyoutput. - Verify Headers: Check for
x-api-key: YOUR_KEYin 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
| Slug | x402-layer |
| Version | 1.0.0 |
| Networks | Base (EVM), Solana |
| Currency | USDC |