Назад към всички

x402-layer

// 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 not

$ git log --oneline --stat
stars:1,933
forks:367
updated:March 4, 2026
SKILL.mdreadonly
SKILL.md Frontmatter
namex402-layer
version1.4.0
descriptionx402-layer helps agents pay for APIs with USDC, deploy monetized endpoints, manage credits/webhooks/marketplace listings, and handle wallet-first ERC-8004 registration/discovery/management/reputation on Base, Ethereum, Polygon, BSC, Monad, and Solana. Use this skill 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", "verify webhook payment", "verify payment genuineness", "register ERC-8004 agent", "register Solana 8004 agent", "submit on-chain reputation feedback", "rate ERC-8004 agent", use "Coinbase Agentic Wallet (AWAL)", or manage x402 Singularity Layer operations on Base, Ethereum, Polygon, BSC, Monad, or Solana networks.
homepagehttps://studio.x402layer.cc/docs/agentic-access/openclaw-skill
metadata[object Object]
allowed-toolsRead,Write,Edit,Bash,WebFetch

x402 Singularity Layer

x402 is a Web3 payment layer where humans and agents can sell/consume APIs and products. This skill covers the full Singularity Layer lifecycle:

  • pay/consume services
  • create/manage/list endpoints
  • receive and verify webhook payment events
  • register agents and submit on-chain reputation feedback

Networks: Base, Ethereum, Polygon, BSC, Monad, Solana
Currency: USDC
Protocol: HTTP 402 Payment Required


Intent Router

Use this routing first, then load the relevant reference doc.

User intentPrimary scriptsReference
Pay/consume endpoint or productpay_base.py, pay_solana.py, consume_credits.py, consume_product.pyreferences/pay-per-request.md, references/credit-based.md
Discover/search marketplacediscover_marketplace.pyreferences/marketplace.md
Create/edit/list endpointcreate_endpoint.py, manage_endpoint.py, list_on_marketplace.py, topup_endpoint.pyreferences/agentic-endpoints.md, references/marketplace.md
Configure/verify webhooksmanage_webhook.py, verify_webhook_payment.pyreferences/webhooks-verification.md
Register/discover/manage/rate agents (ERC-8004/Solana-8004)register_agent.py, list_agents.py, list_my_endpoints.py, update_agent.py, submit_feedback.pyreferences/agent-registry-reputation.md

Quick Start

1) Install Skill Dependencies

pip install -r {baseDir}/requirements.txt

2) Choose Wallet Mode

Option A: private keys

export PRIVATE_KEY="0x..."
export WALLET_ADDRESS="0x..."
# Solana optional
export SOLANA_SECRET_KEY="base58-or-[1,2,3,...]"

Option B: Coinbase AWAL

# Install Coinbase AWAL skill (shortcut)
npx skills add coinbase/agentic-wallet-skills
export X402_USE_AWAL=1

Use private-key mode for ERC-8004 wallet-first registration. AWAL remains useful for x402 payment flows.

Security note: scripts read only explicit process environment variables. .env files are not auto-loaded.


Script Inventory

Consumer

ScriptPurpose
pay_base.pyPay endpoint on Base
pay_solana.pyPay endpoint on Solana
consume_credits.pyConsume using credits
consume_product.pyPurchase digital products/files
check_credits.pyCheck credit balance
recharge_credits.pyBuy endpoint credit packs
discover_marketplace.pyBrowse/search marketplace
awal_cli.pyRun AWAL auth/pay/discover commands

Provider

ScriptPurpose
create_endpoint.pyDeploy endpoint ($1 one-time, includes 4,000 credits)
manage_endpoint.pyList/update endpoint settings
topup_endpoint.pyRecharge provider endpoint credits
list_on_marketplace.pyList/unlist/update marketplace listing
manage_webhook.pySet/remove/check endpoint webhook URL
verify_webhook_payment.pyVerify webhook signature + receipt genuineness (PyJWT/JWKS)

Agent Registry + Reputation

ScriptPurpose
register_agent.pyRegister ERC-8004/Solana-8004 agent with image/version/tags and endpoint binding support
list_agents.pyList ERC-8004 agents owned by the configured wallet or linked dashboard user
list_my_endpoints.pyList platform endpoints that can be linked to ERC-8004 agents
update_agent.pyUpdate existing ERC-8004/Solana-8004 agent metadata, visibility, and endpoint bindings
submit_feedback.pySubmit on-chain reputation feedback

Core Security Requirements

API Key Verification at Origin (mandatory)

When x402 proxies traffic to your origin, verify:

x-api-key: <YOUR_API_KEY>

Reject requests when missing/invalid.

Credit Economics (provider side)

  • Endpoint creation: $1 one-time
  • Starting credits: 4,000
  • Top-up rate: 500 credits per $1
  • Consumption: 1 credit per request
  • If credits hit 0, endpoint stops serving until recharged

Fast Runbooks

A) Pay and Consume

python {baseDir}/scripts/pay_base.py https://api.x402layer.cc/e/weather-data
python {baseDir}/scripts/pay_solana.py https://api.x402layer.cc/e/weather-data
python {baseDir}/scripts/consume_credits.py https://api.x402layer.cc/e/weather-data

B) Discover/Search Marketplace

python {baseDir}/scripts/discover_marketplace.py
python {baseDir}/scripts/discover_marketplace.py search weather

C) Create and Manage Endpoint

python {baseDir}/scripts/create_endpoint.py my-api "My API" https://api.example.com 0.01
python {baseDir}/scripts/manage_endpoint.py list
python {baseDir}/scripts/manage_endpoint.py update my-api --price 0.02
python {baseDir}/scripts/topup_endpoint.py my-api 10

D) List/Update in Marketplace

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

E) Webhook Setup and Genuineness Verification

python {baseDir}/scripts/manage_webhook.py set my-api https://my-server.com/webhook
python {baseDir}/scripts/manage_webhook.py info my-api
python {baseDir}/scripts/manage_webhook.py remove my-api

Webhook verification helper:

python {baseDir}/scripts/verify_webhook_payment.py \
  --body-file ./webhook.json \
  --signature 't=1700000000,v1=<hex>' \
  --secret '<YOUR_SIGNING_SECRET>' \
  --required-source-slug my-api \
  --require-receipt

F) Agent Registration + Reputation

python {baseDir}/scripts/list_my_endpoints.py

python {baseDir}/scripts/register_agent.py \
  "My Agent" \
  "Autonomous service agent" \
  --network baseSepolia \
  --image https://example.com/agent.png \
  --version 1.4.0 \
  --tag finance \
  --tag automation \
  --endpoint-id <ENDPOINT_UUID> \
  --custom-endpoint https://api.example.com/agent

python {baseDir}/scripts/list_agents.py --network baseSepolia

python {baseDir}/scripts/update_agent.py \
  --network baseSepolia \
  --agent-id 123 \
  --version 1.4.1 \
  --tag finance \
  --tag automation \
  --endpoint-id <ENDPOINT_UUID> \
  --public

# The same EVM flow also supports:
#   --network ethereum
#   --network polygon
#   --network bsc
#   --network monad

python {baseDir}/scripts/submit_feedback.py \
  --network base \
  --agent-id 123 \
  --rating 5 \
  --comment "High quality responses"

References

Load only what is needed for the user task:

  • references/pay-per-request.md: EIP-712/Solana payment flow and low-level signing details.
  • references/credit-based.md: credit purchase + consumption behavior and examples.
  • references/marketplace.md: search/list/unlist marketplace endpoints.
  • references/agentic-endpoints.md: endpoint creation/top-up/status API behavior.
  • references/webhooks-verification.md: webhook events, signature verification, and receipt cross-checks.
  • references/agent-registry-reputation.md: ERC-8004/Solana-8004 registration, discovery, management, and feedback rules.
  • references/payment-signing.md: exact signing domains/types/header payload details.

Environment Reference

VariableRequired forNotes
PRIVATE_KEYBase private-key modeEVM signing key
WALLET_ADDRESSMost operationsPrimary wallet
SOLANA_SECRET_KEYSolana private-key modebase58 secret or JSON array bytes
SOLANA_WALLET_ADDRESSSolana overrideoptional
WALLET_ADDRESS_SECONDARYdual-chain endpoint modeoptional
X402_USE_AWALAWAL modeset 1
X402_AUTH_MODEauth selectionauto, private-key, awal
X402_PREFER_NETWORKnetwork selectionbase, solana
X402_API_BASEAPI overridedefault https://api.x402layer.cc
X_API_KEY / API_KEYprovider endpoint/webhook managementendpoint key
WORKER_FEEDBACK_API_KEYreputation feedbackworker auth key

API Base Paths

  • Endpoints: https://api.x402layer.cc/e/{slug}
  • Marketplace: https://api.x402layer.cc/api/marketplace
  • Credits: https://api.x402layer.cc/api/credits/*
  • Agent routes: https://api.x402layer.cc/agent/*

Resources


Known Issue

Solana payments currently have lower reliability than Base due to facilitator-side fee payer infra. Use retry logic in pay_solana.py, and prefer Base for production-critical flows.