A complete x402 payment protocol server providing paid Solidity development tools using USDC on Base networks (Sepolia testnet and mainnet).
This is a multi-protocol server implementation that provides paid Solidity development tools through:
- MCP Server (
/mcp) - Model Context Protocol for AI agents like Claude - HTTP x402 Server (
/compile,/analyze) - Standard HTTP REST endpoints with x402 payment protocol - Discovery Server (
/discovery) - Service metadata for Bazaar indexing and AI agent discovery
Key Capabilities:
- Verifies x402 payment settlements on-chain before providing services
- Provides Solidity compilation, security analysis, and deployment services
- Uses USDC payments via EIP-3009
TransferWithAuthorization - Facilitator-based settlement (HTTP x402 server only) - clients don't pay gas fees
- Operates delegated deployment service where the server deploys contracts on behalf of clients
For AI Agents (Claude, etc.):
- π± MCP Server Usage Guide β
- Model Context Protocol for AI agents
- Ampersend SDK payment handling
- Claude Desktop/CLI integration
- Clients pay gas fees
For Web Applications & REST APIs:
- π HTTP x402 Server Usage Guide β
- Standard HTTP REST endpoints
- Facilitator-based payment settlement
- No gas fees for clients! β
- Production-ready with CDP
- π₯οΈ Claude Setup Guide - Connect to Claude Desktop or Claude Code CLI
- π API Reference - Complete API specs for all 4 tools
- π§ HTTP Endpoints - HTTP x402 endpoint specifications
| Feature | MCP Server | HTTP x402 Server |
|---|---|---|
| Best for | AI agents (Claude) | Web apps, APIs |
| Protocol | MCP | HTTP REST |
| Endpoints | /mcp |
/compile, /analyze |
| Payment Library | Ampersend SDK | @x402/fetch |
| Gas Fees | Client pays | Facilitator pays β |
| Facilitator | Not used | CDP or x402.org |
| Setup | MCP_USAGE.md | HTTP_X402_USAGE.md |
Choose MCP if you're integrating with Claude Desktop/CLI or building AI agents. Choose HTTP if you're building web applications or want NO gas fees for clients.
- compile_solidity - Solidity compilation (0.01 USDC)
- analyze_with_slither - Security analysis (0.02 USDC)
- compile_and_deploy - Single network deployment (dynamic pricing)
- compile_and_deploy_multi_network - Multi-network deployment (dynamic pricing)
- x402 Payment Protocol: On-chain settlement verification before service execution
- USDC Payments: EIP-3009
TransferWithAuthorizationfor gasless approvals - Delegated Deployment: Server deploys contracts without requiring client private keys
- Dynamic Gas Pricing: Fair, transparent gas-based pricing for deployments
- MCP Integration: Built with Ampersend SDK for seamless payment-gated tools
- Bazaar Discovery: Indexed on agentic.market with full metadata for AI agent discovery
Modular MCP server implementation with payment-gated tools:
src/server/- Organized server architectureindex.ts- Main entry pointdiscovery.ts- Bazaar discovery HTTP servertools/- Individual MCP toolscompile-solidity.ts- Solidity compilationanalyze-slither.ts- Security analysis via Slithercompile-deploy.ts- Delegated deployment with dynamic gas-based pricingcompile-deploy-multi.ts- Multi-network deployment support
utils/- Shared utilitiespayment.ts- Payment verification utilities
config/- Configuration managementnetwork.ts- Centralized network configuration for easy mainnet/testnet switchingtools.ts- Central tool configuration (compiler versions, pricing, gas settings)bazaar.ts- Bazaar discovery metadata for all tools
- Verifies X402 payments on-chain before executing tools
- Integrates with Remix API for Slither analysis
- Provides Delegated Deployment Service for secure contract deployment
- Exposes discovery endpoint for x402 Bazaar indexing
- See
REFACTORING_SUMMARY.mdfor detailed refactoring documentation
src/lib/- Client SDK (included for testing and examples)src/examples/- Example client implementationstests/e2e/- End-to-end integration tests
# Install dependencies
yarn installRequired environment variables:
SERVER_DEPLOYER_PRIVATE_KEY- Required for deployment servicePAY_TO_ADDRESS- Required for receiving payments
Optional (for HTTP x402 server with CDP Facilitator):
CDP_API_KEY_ID- CDP API key for facilitator serviceCDP_API_KEY_SECRET- CDP API secret
Detailed configuration guides:
- HTTP x402 Server: See HTTP_X402_USAGE.md for facilitator configuration
- MCP Server: See MCP_USAGE.md for wallet setup
# Build TypeScript files
yarn run build# Build and start the server
yarn build && yarn startThe server will start:
- MCP Server:
http://localhost:8000/mcp- Main MCP endpoint for tool execution - Discovery Server:
http://localhost:8001/discovery- Bazaar discovery metadata endpoint - HTTP x402 Server (optional):
http://localhost:8002- REST endpoints with x402 protocol (requiresPAY_TO_ADDRESS)
The discovery endpoint exposes metadata for all tools in a format compatible with the x402 Bazaar:
# View discovery metadata
curl http://localhost:8001/discoveryThis endpoint is used by:
- agentic.market - To index and validate your service
- CDP Facilitator - To automatically catalog your tools
- AI agents - To discover available tools and their capabilities
End-to-end tests verify the complete payment and tool execution flow with real blockchain transactions.
Prerequisites:
- MCP server must be running
- Test wallet funded with USDC on Base Sepolia
- Configure
.env.testor.envwith test wallet
Run tests:
# Run all E2E tests
yarn test
# Watch mode
yarn test:watch
# Verbose output
yarn test:verboseTest coverage:
- β Compilation with automatic payment
- β Custom compiler settings
- β Multiple files with imports
- β Security analysis with Slither
- β Contract deployment
- β Multi-network deployment
- β Payment flow verification
Example client implementations are provided in src/examples/ for testing and reference:
This server supports two payment methods depending on which server you use:
- Protocol: Ampersend SDK
- Settlement: Client-side
- Gas fees: Paid by client
- Best for: AI agents, Claude integration
- Protocol: x402 with Facilitator service
- Settlement: Server-side via facilitator
- Gas fees: Paid by facilitator (NOT client!)
- Best for: Web applications, REST APIs
π Detailed payment flows:
- MCP_USAGE.md - MCP server payment flow
- HTTP_X402_USAGE.md - HTTP server with facilitator
- API_REFERENCE.md - Complete API specifications
This server is compatible with the x402 Bazaar discovery layer, making it discoverable on agentic.market and by AI agents.
The server exposes structured metadata at http://localhost:8001/discovery that includes:
- Tool specifications - Input/output schemas with JSON Schema validation
- Pricing information - Exact costs for each tool
- Payment requirements - Network, USDC address, and payment scheme
- Service descriptions - Natural language descriptions for semantic search
- Examples - Sample inputs and outputs for each tool
- Network: Base Sepolia
- Chain ID: 84532
- USDC Contract:
0x036CbD53842c5426634e7929541eC2318f3dCF7e - RPC:
https://sepolia.base.org