@evozim/eliza-plugin-x402
v1.0.6
Published
Eliza OS plugin to natively resolve HTTP 402 challenges and sign gasless EIP-3009 USDC micro-payments on Base L2
Maintainers
Readme
🤖 @evozim/eliza-plugin-x402
Natively Intercept HTTP 402 Paywalls & Autonomously Settle USDC Micropayments on Base L2
🔥 v1.0.6 UPDATE: Fully supports the x402 V2 Protocol (Coinbase Bazaar &
x402scancompliant) and Vouch Protocol Grade A (100/100) standards. Natively parses Base64Payment-Required(accepts[0]),x-402-price, andx-402-contractheaders, runs free pre-flight validation on/:slug/api/preview, and verifiesPAYMENT-RESPONSEsettlement receipts — with zero runtime CJS/ESM conflicts across all@elizaos/coreversions.🌐 DISCOVER 1,057 DETERMINISTIC NODES (
<250msCompute SLA): Connect your ElizaOS agents to the complete M2MCent Zero-LLM utility network ($0.010–$0.250USDC). Browse the live catalog: api.m2mcent.com/llms-full.txt
@evozim/eliza-plugin-x402 is an official drop-in plugin for ElizaOS. It equips autonomous agents with the ability to consume 1,057 deterministic pay-per-use APIs and Model Context Protocol (MCP) servers on Base Mainnet (eip155:8453) without human intervention.
Whenever an external request returns an HTTP 402 Payment Required response, this plugin intercepts the call, decodes the payment metadata, signs a gasless EIP-3009 TransferWithAuthorization USDC signature, injects it into the headers, and completes the request autonomously.
🏛️ Smart Contracts & Treasury
- Base Mainnet Escrow Contract:
0x5d47070A36A37DAf417e64FF27a1e5B3F1c84efa - Institutional Treasury Safe:
0x8aaBAB75bE8825d0f5D514a9a5cBa04B7bF84920 - Vouch Trust Index: Grade A (100/100)
- Post-Quantum Compliance: FIPS 204 ML-DSA-65
⚙️ How it Works under the Hood
sequenceDiagram
participant Agent as Eliza OS Agent
participant Service as X402Service (Plugin)
participant API as M2MCent Gateway (1,062 Nodes)
participant Escrow as M2MCent Escrow (0x5d47...efa)
Agent->>API: 1. Request Tool / API Call
API-->>Agent: 2. Response: HTTP 402 Payment Required<br/>(Headers: x-402-price & x-402-contract)
Note over Service: Intercepts challenge &<br/>decodes metadata
Service->>Service: 3. Signs EIP-3009 Transfer Auth<br/>(EIP-712 Typed Signature)
Agent->>API: 4. Retry Request<br/>(Header: Payment-Signature in Base64)
API->>Escrow: 5. Relays Signature & Settles USDC Gaslessly
Escrow-->>API: 6. Settlement Confirmed (Atomic)
API-->>Agent: 7. Response: HTTP 200 with Tool Output🚀 Installation
npm install @evozim/eliza-plugin-x402
# or using yarn
yarn add @evozim/eliza-plugin-x402
# or using pnpm
pnpm add @evozim/eliza-plugin-x402🛠️ Configuration
Configure the agent runtime settings or environment variables (.env):
| Variable | Description | Required | Default |
| :--- | :--- | :---: | :--- |
| EVM_PRIVATE_KEY | Private key of the agent's EVM wallet. Must hold USDC on Base Mainnet. | Yes | - |
| EVM_PROVIDER_URL | Base RPC node endpoint URL. | No | https://mainnet.base.org |
📦 Usage
1. Register the Plugin in your Agent
Import and register the plugin inside your Eliza setup (agent/src/index.ts or character file):
import { x402Plugin } from "@evozim/eliza-plugin-x402";
const runtime = new AgentRuntime({
plugins: [
x402Plugin
]
});2. Calling Protected Endpoints programmatically
You can invoke the X402Service anywhere in your custom actions or providers:
import { X402Service, X402ServiceType } from "@evozim/eliza-plugin-x402";
const runAction = async (runtime: IAgentRuntime) => {
const x402Service = runtime.getService<X402Service>(X402ServiceType.X402 as any);
const result = await x402Service.fetchWithPaywall(
"https://api.m2mcent.com/autonomous-trading-bot-mcp/api/process",
{
method: "POST",
body: JSON.stringify({
symbol: "ETH",
rsiPeriod: 14
})
}
);
if (result.success) {
console.log("Success! Output:", result.responseBody);
}
};