@elliotpadfield/openclaw-x402
v0.1.1
Published
OpenClaw plugin for discovering and calling x402-paid APIs
Maintainers
Readme
@elliotpadfield/openclaw-x402
Installable OpenClaw plugin for discovering and calling x402-paid HTTP APIs.
This plugin fits the existing OpenClaw ecosystem:
- install it as a standard OpenClaw plugin
- let the agent use
x402_fetchfor payable HTTP calls - use
x402_openapi_importto inspect OpenAPI specs and save local API indexes - use
x402_api_searchto search configured x402 services and imported APIs - optionally bundle planner guidance via the included
x402skill
It does not rewrite every other plugin's HTTP stack. It makes x402 work through its own tools without needing OpenClaw core changes.
Status
Alpha.
What is already proven:
- loads as an OpenClaw plugin
- registers tools correctly
- handles
402 -> sign -> retrywith Coinbase's x402 libraries - works against a real public x402 endpoint
What is not fully proven yet:
- end-to-end settlement with a funded wallet against multiple public services
- automatic generation of first-class OpenClaw tools from imported OpenAPI specs
Ecosystem Shape
This package is structured to match how current OpenClaw plugins are distributed:
- published to npm
- installable with
openclaw plugins install <npm-spec> - public source repo with docs and issue tracker
- package metadata compatible with OpenClaw's plugin loader
That matches the current OpenClaw community plugin guidance and the shape used by
published packages like @openclaw/voice-call and @icesword760/openclaw-wechat.
Install
From npm:
openclaw plugins install @elliotpadfield/openclaw-x402From a local tarball while developing:
npm pack
openclaw plugins install ./openclaw-x402-0.1.1.tgzInstalled plugins are enabled by default. You can verify load status with:
openclaw plugins list
openclaw plugins info openclaw-x402Setup
OpenClaw plugin config belongs under plugins.entries.openclaw-x402.config.
Minimal example:
{
"plugins": {
"entries": {
"openclaw-x402": {
"enabled": true,
"config": {
"defaultBudgetUsd": 5,
"approvalThresholdUsd": 0.25,
"allowedNetworks": ["eip155:8453", "eip155:84532"],
"allowedDomains": ["api.example.com", "*.x402.org"]
}
}
}
}
}You can also set it through the CLI:
openclaw config set plugins.entries.openclaw-x402.enabled true --json
openclaw config set plugins.entries.openclaw-x402.config.defaultBudgetUsd 5 --json
openclaw config set plugins.entries.openclaw-x402.config.approvalThresholdUsd 0.25 --json
openclaw config set plugins.entries.openclaw-x402.config.allowedNetworks '["eip155:8453"]' --jsonSigner env vars:
export OPENCLAW_X402_EVM_PRIVATE_KEY=0x...
export OPENCLAW_X402_SVM_PRIVATE_KEY=...If you want custom env var names:
{
"plugins": {
"entries": {
"openclaw-x402": {
"enabled": true,
"config": {
"evmPrivateKeyEnv": "MY_X402_EVM_KEY",
"svmPrivateKeyEnv": "MY_X402_SVM_KEY"
}
}
}
}
}Restart the Gateway after config changes.
Configuration
Supported config fields:
stateDir: override the default state directoryevmPrivateKeyEnv: env var name used for the EVM signersvmPrivateKeyEnv: env var name used for the SVM signerdefaultBudgetUsd: hard budget for cumulative spendapprovalThresholdUsd: requests above this are blockedallowUnknownAssets: allow payment requirements without a usable USD estimateallowPrivateHosts: allowlocalhostand private network targetsmaxResponseBytes: response body capdefaultTimeoutMs: default request timeoutallowedDomains: outbound domain allowlistallowedNetworks: x402 network allowlistallowedPayees: payee allowlistregistry: static list of known x402 services forx402_api_search
Example registry entry:
{
"plugins": {
"entries": {
"openclaw-x402": {
"enabled": true,
"config": {
"registry": [
{
"id": "spraay",
"name": "Spraay Gateway",
"baseUrl": "https://gateway.spraay.app",
"docsUrl": "https://github.com/plagtech/spraay-x402-gateway",
"description": "Public x402 gateway",
"tags": ["ai", "gateway", "search"]
}
]
}
}
}
}
}See .env.example for a starter env file.
Tools
x402_fetch
Calls an arbitrary HTTP endpoint. If the endpoint returns 402 Payment Required
and policy allows it, the plugin signs the payment payload with Coinbase's x402
SDKs, retries the request, and stores a receipt.
Payment status is explicit:
payment.attempted: false: no x402 flow happenedpayment.attempted: trueandpayment.paid: false: retry happened, but the remote service still rejected paymentpayment.attempted: trueandpayment.paid: true: payment retry succeeded
x402_openapi_import
Fetches or parses an OpenAPI document, summarizes operations, and optionally saves an import snapshot into the plugin state directory.
x402_api_search
Searches configured registry entries plus locally saved imports.
External Smoke Test
As of March 7, 2026, this public endpoint returns a real x402 402 Payment Required
response when called without a valid funded signer:
https://gateway.spraay.app/api/v1/models
Raw curl check:
curl -i https://gateway.spraay.app/api/v1/modelsExpected result:
- HTTP
402 - a
PAYMENT-REQUIREDheader
Plugin behavior with a throwaway unfunded EVM key:
- the plugin reaches the public endpoint
- parses the x402 requirement
- signs and retries
- the server rejects with
402 insufficient_funds - the plugin returns
payment.attempted: trueandpayment.paid: false
This is a safe public smoke test because no funded wallet is required.
State
By default the plugin stores state under:
<workspace>/.openclaw-x402/This includes:
receipts.jsonlimports/*.json
Development
npm install
npm run typecheck
npm test
npm pack --dry-runSee CONTRIBUTING.md for local install and smoke-test steps.
License
Apache-2.0. See LICENSE.
