Files
wehub-resource-sync 426e9eeabd
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Waiting to run
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Waiting to run
Build Agent Image / build-and-push (push) Waiting to run
Chat shell gestures / Chat shell gesture + parity e2e (push) Waiting to run
ci / test (push) Waiting to run
ci / lint-and-format (push) Waiting to run
ci / build (push) Waiting to run
ci / dev-startup (push) Waiting to run
Cloud Gateway Discord / Test (push) Waiting to run
Cloud Gateway Webhook / Test (push) Waiting to run
Cloud Tests / lint-and-types (push) Waiting to run
Cloud Tests / unit-tests (push) Waiting to run
Cloud Tests / integration-tests (push) Waiting to run
Cloud Tests / e2e-tests (push) Blocked by required conditions
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Apps Worker (Product 2) / Determine environment (push) Waiting to run
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Blocked by required conditions
Deploy Eliza Provisioning Worker / Determine environment (push) Waiting to run
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Blocked by required conditions
Dev Smoke / Classify changed paths (push) Waiting to run
Dev Smoke / bun run dev onboarding chat (push) Blocked by required conditions
Dev Smoke / Vite HMR dependency-level smoke (push) Blocked by required conditions
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Waiting to run
gitleaks / gitleaks (push) Waiting to run
Markdown Links / Relative Markdown Links (push) Waiting to run
Publish @elizaos/example-code / check_npm (push) Waiting to run
Publish @elizaos/example-code / publish_npm (push) Blocked by required conditions
Publish @elizaos/plugin-elizacloud / verify_version (push) Waiting to run
Publish @elizaos/plugin-elizacloud / publish_npm (push) Blocked by required conditions
Quality (Extended) / Homepage Build (PR smoke) (push) Waiting to run
Quality (Extended) / Comment-only diff guard (push) Waiting to run
Quality (Extended) / Format + Type Safety Ratchet (push) Waiting to run
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Waiting to run
Quality (Extended) / Develop Gate (lint) (push) Waiting to run
Sandbox Live Smoke / Sandbox live smoke (push) Waiting to run
Snap Build & Test / Build Snap (amd64) (push) Waiting to run
Snap Build & Test / Build Snap (arm64) (push) Waiting to run
supply-chain / sbom (push) Waiting to run
supply-chain / vulnerability-scan (push) Waiting to run
Build, Push & Deploy to Phala Cloud / build-and-push (push) Waiting to run
Test Packaging / Validate Packaging Configs (push) Waiting to run
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Waiting to run
Test Packaging / Pack & Test JS Tarballs (push) Waiting to run
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Waiting to run
UI Fixture E2E / ui-fixture-e2e (push) Waiting to run
UI Fixture E2E / fixture-e2e (push) Waiting to run
UI Story Gate / story-gate (push) Waiting to run
vault-ci / test (macos-latest) (push) Waiting to run
vault-ci / test (ubuntu-latest) (push) Waiting to run
vault-ci / test (windows-latest) (push) Waiting to run
vault-ci / app-core wiring tests (push) Waiting to run
verify-patches / verify patches/CHECKSUMS.sha256 (push) Waiting to run
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Waiting to run
Voice Benchmark Smoke / voice bench smoke summary (push) Blocked by required conditions
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Waiting to run
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Waiting to run
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Waiting to run
Test Packaging / Build & Test PyPI Package (push) Waiting to run
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:43:05 +08:00
..

@elizaos/plugin-x402

x402 micropayment middleware for elizaOS plugin HTTP routes.

This package lets Eliza agent plugins gate their HTTP routes behind the x402 protocol, requiring on-chain micropayments before serving responses. It handles HTTP 402 negotiation, payment verification (on-chain and facilitator-backed), and replay protection in one integration point.

What it does

  • Declares payment requirements via HTTP 402 responses with accepts arrays describing payment networks, token addresses, amounts, and resource URLs — compatible with x402scan indexing.
  • Verifies payments using three strategies, tried in priority order:
    1. Standard X-Payment / PAYMENT-SIGNATURE payloads (x402-fetch / CDP-style) verified and settled via a facilitator.
    2. Direct on-chain proofs: Solana SPL token transfers (via @solana/web3.js), EVM ERC-20 transfers and EIP-712 authorizations (via viem).
    3. Facilitator payment IDs via X-Payment-Id header.
  • Prevents replay attacks using an atomic in-process guard plus a durable store backed by runtime.setCache/getCache (shared across processes when using the same DB).
  • Emits runtime events on payment required (PAYMENT_REQUIRED) and verified (PAYMENT_VERIFIED).

Supported networks and tokens

Config name Network Token
base_usdc Base (chain 8453) USDC
solana_usdc Solana USDC
polygon_usdc Polygon (chain 137) USDC
bsc_usdc BSC (chain 56) USDC
base_elizaos Base elizaOS token
solana_elizaos Solana elizaOS token
solana_degenai Solana degenai

Enabling in a plugin

Install (it declares @elizaos/core as a peer dependency; in this monorepo that resolves via workspace:*):

bun add @elizaos/plugin-x402

Wrap your route array before returning them from your plugin:

import { applyPaymentProtection } from '@elizaos/plugin-x402';
import type { Plugin, Route } from '@elizaos/core';

const routes: Route[] = applyPaymentProtection([
  {
    type: 'GET',
    path: '/api/premium-data',
    public: true,
    x402: {
      priceInCents: 10,                             // $0.10
      paymentConfigs: ['base_usdc', 'solana_usdc'],
    },
    handler: async (req, res, runtime) => {
      res.json({ result: 'premium content' });
    },
  },
]);

export const myPlugin: Plugin = { name: 'my-plugin', routes };

applyPaymentProtection validates config at call time and throws on misconfiguration so the agent fails fast at startup.

Shorthand with character defaults

Set x402: true on a route to inherit price and payment configs from the agent character:

// In character config:
character.settings.x402 = {
  defaultPriceInCents: 10,
  defaultPaymentConfigs: ['base_usdc', 'solana_usdc'],
};

// In route:
{ type: 'GET', path: '/api/resource', x402: true, handler: ... }

Required environment variables

Set your payout wallet addresses. If unset, bundled example addresses are used (startup warns in dev, errors in production).

# Payout wallets (set the networks you want to accept)
SOLANA_PUBLIC_KEY=<your-solana-wallet>
BASE_PUBLIC_KEY=<your-base-evm-wallet>
POLYGON_PUBLIC_KEY=<your-polygon-evm-wallet>
BSC_PUBLIC_KEY=<your-bsc-evm-wallet>

Optional environment variables

# Facilitator service (recommended for standard x402-fetch clients)
X402_FACILITATOR_URL=https://your-facilitator.example.com

# Override individual facilitator endpoints
X402_FACILITATOR_VERIFY_URL=https://your-facilitator.example.com/api/v1/x402/verify
X402_FACILITATOR_SETTLE_URL=https://your-facilitator.example.com/api/v1/x402/settle

# Public base URL for this server (used in resource URLs)
X402_BASE_URL=https://your-agent.example.com

# Development: skip all payment verification
X402_TEST_MODE=true

# Replay protection: use in-memory only (no DB persistence)
X402_REPLAY_DURABLE=0

# Custom RPC endpoints
SOLANA_RPC_URL=https://your-rpc.solana.com
BASE_RPC_URL=https://your-rpc.base.org

# Token prices for non-stablecoin configs (exact decimal string, dollars)
ELIZAOS_PRICE_USD=0.05
AI16Z_PRICE_USD=0.50
DEGENAI_PRICE_USD=0.01

# Debug logging
DEBUG_X402_PAYMENTS=true

Custom payment configs

Register additional token/network combinations at plugin init time:

import { registerX402Config } from '@elizaos/plugin-x402';

registerX402Config('mytoken_base', {
  network: 'BASE',
  assetNamespace: 'erc20',
  assetReference: '0x<token-contract-address>',
  paymentAddress: process.env.BASE_PUBLIC_KEY!,
  symbol: 'MYTOKEN',
  chainId: '8453',
});

Then reference 'mytoken_base' in your route's paymentConfigs array.

Payment headers

Clients send payment credentials in HTTP headers:

Header Purpose
X-Payment or PAYMENT-SIGNATURE Standard x402 payload (base64 JSON with x402Version, accepted, payload)
X-Payment-Proof Legacy proof: Solana tx sig, EVM tx hash, or colon-delimited format
X-Payment-Id Facilitator-issued payment ID

On success the response includes a PAYMENT-RESPONSE header from the facilitator and emits a PAYMENT_VERIFIED event on the agent runtime.