Overview
@toju.network/x402 implements the x402 protocol for autonomous storage payments. An agent instantiates AgentClient with a funded Base wallet, calls store(), and the SDK handles the full payment negotiation automatically — no wallet prompts, no manual signing steps.
The flow under the hood:
Install
Quick start
createAgentClient
Options
EVM private key for the agent’s wallet. Must hold USDC on Base to pay for storage.
Target environment. Use
'mainnet' for Base Mainnet with real USDC.estimateStorageCost
Check the cost before uploading.Parameters
Raw byte count of the file
How long to keep the file on IPFS
Response
Cost in USDC, formatted to 6 decimal places (e.g.
'0.000090')Approximate USD cost, formatted to 2 decimal places
store
Upload a file and pay autonomously via x402.Parameters
The file to upload. Use the standard Web API
File object — works in Node.js 20+ and all modern runtimes.Storage duration in days
Response
IPFS content identifier for the uploaded file (e.g.
bafybei...)ISO 8601 date string when the file will be removed from IPFS
Original file name
File size in bytes
USDC on Base
USDC uses 6 decimal places on all EVM chains (Circle standard). The SDK and server handle conversion automatically.| Network | USDC Contract |
|---|---|
| Base Mainnet | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
Your agent wallet needs enough USDC to cover the storage cost, plus a small amount of ETH on Base for gas. Gas fees on Base are typically under $0.001 per transaction.
Framework integrations
AgentClient works with any framework that can hold an EVM private key:
Related
Pricing
Storage rate and cost calculator
Upload (SOL)
Human wallet uploads with Solana
CID Computation
How content identifiers work
Storage Payments
Payment mechanics