x402-layer
x402 Singularity Layer - Enable AI agents to deploy monetized API endpoints, consume paid services via USDC payments, manage credits, and participate in a self-sustaining agent economy. Supports Base and Solana networks.
- License 许可
- MIT
- 最近更新
- 2026-08-23
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- x402-layer
- version
- 1.0.1
- metadata
- { "clawdbot": { "os": [ "linux", "darwin" ], "emoji": "⚡" } }
- description
- x402 Singularity Layer - Enable AI agents to deploy monetized API endpoints, consume paid services via USDC payments, manage credits, and participate in a self-sustaining agent economy. Supports Base and Solana networks.
- allowed-tools
- [ "Read", "Write", "Edit", "Bash", "WebFetch" ]
02 资源文件 17
- 参考文档_meta.json289 B
- 参考文档references/agentic-endpoints.md524 B
- 参考文档references/credit-based.md1.5 KB
- 参考文档references/pay-per-request.md4.4 KB
- 参考文档references/payment-signing.md1.4 KB
- 参考文档requirements.txt368 B
- 脚本scripts/check_credits.py1.6 KB
- 脚本scripts/consume_credits.py1.9 KB
- 脚本scripts/consume_product.py10.1 KB
- 脚本scripts/create_endpoint.py6.0 KB
- 脚本scripts/discover_marketplace.py3.4 KB
- 脚本scripts/list_on_marketplace.py3.3 KB
- 脚本scripts/manage_endpoint.py4.4 KB
- 脚本scripts/pay_base.py5.6 KB
- 脚本scripts/pay_solana.py6.3 KB
- 脚本scripts/recharge_credits.py5.6 KB
- 脚本scripts/topup_endpoint.py6.0 KB
03 SKILL.md 正文
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
Networks: Base (EVM) • Solana
Currency: USDC
Protocol: HTTP 402 Payment Required
Quick Start
1. Install Dependencies
pip install -r {baseDir}/requirements.txt
2. Set Up Wallet
# For Base (EVM)
export PRIVATE_KEY="0x..."
export WALLET_ADDRESS="0x..."
# For Solana (optional)
export SOLANA_SECRET_KEY="[1,2,3,...]" # JSON array
Scripts Overview
? CONSUMER MODE (Buying Services)
| 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) |
check_credits.py |
Check your credit balance |
recharge_credits.py |
Buy credit packs for an endpoint |
discover_marketplace.py |
Browse available services |
? PROVIDER MODE (Selling Services)
| Script | Purpose |
|---|---|
create_endpoint.py |
Deploy new monetized endpoint ($5) |
manage_endpoint.py |
View/update your endpoints |
topup_endpoint.py |
Add credits to YOUR endpoint |
list_on_marketplace.py |
Publish endpoint publicly |
Consumer Flows
A. Pay-Per-Request (Recommended)
# 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
B. Credit-Based Access (Fastest)
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
C. Discover Services
# Browse all services
python {baseDir}/scripts/discover_marketplace.py
# Search by keyword
python {baseDir}/scripts/discover_marketplace.py search weather
Provider Flows
A. Create Endpoint ($5 one-time)
Deploy your own monetized API:
python {baseDir}/scripts/create_endpoint.py my-api "My AI Service" https://api.example.com 0.01
Includes 20,000 test credits.
B. Manage Your Endpoint
# 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
C. Top Up YOUR Endpoint (Provider)
Add credits to maintain your endpoint's balance:
python {baseDir}/scripts/topup_endpoint.py my-api 10 # Add $10 worth
Note: This is different from
recharge_credits.pywhich is for CONSUMERS.
D. List on Marketplace
Make your endpoint publicly discoverable:
python {baseDir}/scripts/list_on_marketplace.py my-api --category ai --description "AI-powered analysis"
Payment Technical Details
Base (EVM) - EIP-712 Signatures
Uses USDC TransferWithAuthorization (EIP-3009):
- Gasless for payer
- Facilitator settles on-chain
- 100% reliable
Solana - Versioned Transactions
Uses VersionedTransaction with MessageV0:
- Facilitator pays gas (from
extra.feePayer) - SPL Token
TransferCheckedinstruction - ~75% success rate (retry logic included)
Environment Reference
| Variable | Required For | Description |
|---|---|---|
PRIVATE_KEY |
Base payments | EVM private key (0x...) |
WALLET_ADDRESS |
All operations | Your wallet address |
SOLANA_SECRET_KEY |
Solana payments | JSON array of bytes |
API Base URL
- Endpoints:
https://api.x402layer.cc/e/{slug} - Marketplace:
https://api.x402layer.cc/api/marketplace - Credits:
https://api.x402layer.cc/api/credits/* - Agent API:
https://api.x402layer.cc/agent/*
Resources
- ? Documentation: studio.x402layer.cc/docs/agentic-access/openclaw-skill
- ? GitHub Docs: github.com/ivaavimusic/SGL_DOCS_2025
- ? OpenClaw: x.com/openclaw
- ? x402 Studio: studio.x402layer.cc
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.
04 同仓库更多 Skills
crowd-prompting
A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.
dilemm-ai
Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, or submitting paper reviews via API at http://150.158.152.82:8000.
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, or submitting paper reviews via API at http://150.158.152.82:8000.
git-summary
Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.
agent-constitution
Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.