comprehensive blockchain application that demonstrates the integration of x402 payment protocol with 0G Storage through Model Context Protocol (MCP). The project features a multi-package monorepo structure with frontend, backend, MCP server, and AWS CDK infrastructure components.
.
├── docs/ # Project documentation and diagrams
├── pkgs/
│ ├── frontend/ # Next.js 15 frontend application
│ ├── backend/ # Hono-based API server with x402 payment handling
│ ├── mcp/ # Model Context Protocol server for 0G Storage file operations
│ └── cdk/ # AWS CDK infrastructure for cloud deployment
├── .github/workflows/ # CI/CD pipeline configuration
├── biome.json # Code linting and formatting configuration
├── pnpm-workspace.yaml # pnpm monorepo workspace configuration
└── tsconfig.json # TypeScript base configuration
- Package Manager: pnpm v8+ with workspace support
- Monorepo Structure: pnpm workspaces for multi-package management
- Frontend: Next.js 15 with React 19, TypeScript, and PWA support
- Backend: Hono framework with TypeScript, x402 payment protocol integration
- MCP: Model Context Protocol SDK for 0G Storage file operations and blockchain payments
- Blockchain: x402-enabled payment interactions
- Payment: x402 protocol for USDC payments on Base Sepolia
- Storage: 0G Storage modern cloud storage with AI-powered insights
- Infrastructure: AWS CDK for cloud deployment and Lambda functions
- Code Quality: Biome for linting and formatting
- CI/CD: GitHub Actions for automated building and testing
- Node.js (v20+)
- pnpm v8+
- A wallet with USDC on Base Sepolia for payment functionality
# Clone the repository
git clone <your_repo_url>
cd <repo_name>
# Install dependencies
pnpm install# Format code with Biome
pnpm format
# Lint code
pnpm lint
# Check and apply fixes
pnpm check
# Package-specific commands
pnpm frontend <command> # Frontend-specific commands
pnpm backend <command> # Backend-specific commands
pnpm mcp <command> # MCP-specific commands
pnpm cdk <command> # CDK-specific commandsCreate pkgs/backend/.env file:
FACILITATOR_URL=https://x402.org/facilitator
NETWORK=base-sepolia
ADDRESS=<your_wallet_address>Create pkgs/mcp/.env file:
RESOURCE_SERVER_URL=http://localhost:4021
ENDPOINT_PATH=/download
PRIVATE_KEY=<your_private_key_with_usdc_on_base_sepolia>Create pkgs/frontend/.env.local file:
OPENAI_API_KEY=<your_openai_api_key>
GOOGLE_GENERATIVE_AI_API_KEY=<your_google_ai_key>
ANTHROPIC_API_KEY=<your_anthropic_key>
PATH_TO_MCP=<absolute_path_to_repo>/pkgs/mcp/dist/index.jsCreate pkgs/cdk/.env file:
FACILITATOR_URL=https://facilitator.x402.io
NETWORK=base-sepolia
ADDRESS=<your_wallet_address>
ENDPOINT_PATH=/download/
PRIVATE_KEY=<your_private_key>pnpm backend devThe backend API will be available at http://localhost:4021
pnpm mcp buildConfigure MCP in .vscode/mcp.json:
{
"inputs": [],
"servers": {
"x402-0g-storage": {
"command": "node",
"args": [
"${workspaceFolder}/pkgs/mcp/dist/index.js"
],
"envFile": "${workspaceFolder}/pkgs/mcp/.env"
},
}
}pnpm frontend devThe frontend will be available at http://localhost:3001
pnpm cdk run deploy '*' --require-approval neverpnpm cdk run destroy '*' --forceConfigure MCP in VS Code's settings.json:
"aws-x402-0g-storage-mcp": {
"type": "sse",
"url": "<yoururl>/mcp",
"headers": {
"VERSION": "1.2",
"Accept": "application/json, text/event-stream",
"Content-Type": "application/json"
}
},Upload files to 0G Storage:
Upload your file to 0G Storage.
File path: <absolute_path_to_repo>/pkgs/mcp/samples/sample.txt
Storage duration: 30
use x402-0g-storage-mcpDownload files from 0G Storage:
Download the file from 0G Storage.
FileID: [file_id_from_upload]
use x402-0g-storage-mcpGet file information:
Get information about the file.
FileID: [file_id_from_upload]
use x402-0g-storage-mcpList stored files:
List my files from 0G Storage.
use x402-0g-storage-mcpGenerate AI recommendations from your data:
Generate AI recommendations from my shopping data.
UserID: user123
DataType: shopping_history
use x402-0g-storage-mcpTrain AI models on your data:
Train an AI model on my fitness tracking data.
UserID: user123
TrainingData: [fitness_data_array]
ModelType: collaborative_filtering
use x402-0g-storage-mcpIndex your data for efficient search:
Index my research papers for semantic search.
UserID: user123
DataType: research_papers
Data: [paper_data_array]
use x402-0g-storage-mcpSearch your data using AI:
Find similar documents to my current research.
UserID: user123
Query: machine learning applications
SearchType: semantic
use x402-0g-storage-mcpCreate data processing pipelines:
Create a data pipeline to analyze my sales data.
UserID: user123
PipelineConfig: {name: "Sales Analysis", stages: [...]}
use x402-0g-storage-mcpCheck your profit history:
Show me my profit history from data monetization.
UserID: user123
use x402-0g-storage-mcpMonitor data access statistics:
Get my data access statistics for this month.
UserID: user123
TimeRange: month
use x402-0g-storage-mcpZERO_G_API_KEY- Your 0G platform API key for accessing AI, search, and payment servicesPRIVATE_KEY- Your private key for x402 payment processing (hex format)
# 0G Platform Configuration
ZERO_G_API_KEY=your_0g_platform_api_key_here
# x402 Payment Configuration
PRIVATE_KEY=your_private_key_for_x402_payments_here
# Resource Server (for Lambda)
RESOURCE_SERVER_URL=http://localhost:4021Next.js 15 application featuring:
- React 19 with TypeScript and modern hooks
- Progressive Web App (PWA) capabilities with next-pwa
- Styling: Tailwind CSS with shadcn/ui components
- AI Integration: Mastra AI framework with multiple providers (OpenAI, Google, Anthropic)
- State Management: TanStack Query for server state
- Theme Support: Dark/light mode with next-themes
Key Dependencies:
- @mastra/core, @mastra/mcp for AI and MCP functionality
- @radix-ui components for accessible UI primitives
- Tailwind CSS and lucide-react for styling and icons
Hono-based API server with:
- Framework: Hono with Node.js server adapter
- Payment Processing: x402 protocol integration for USDC payments
- Environment: Docker support for containerized deployment
- TypeScript: Full TypeScript support with modern ES modules
Key Dependencies:
- @hono/node-server for HTTP server
- x402, x402-hono for payment protocol
- dotenv for environment configuration
Model Context Protocol server for 0G Storage operations:
- Protocol: MCP SDK for VS Code/GitHub Copilot integration
- Blockchain: Viem for Ethereum/Base interactions
- Storage: 0G Storage modern cloud storage integration
- Payment: x402-axios for automated payment handling
- Deployment: AWS Lambda support with serverless-express
Key Dependencies:
- @modelcontextprotocol/sdk for MCP implementation
- viem for blockchain interactions
- x402-axios for payment-enabled HTTP requests
- @vendia/serverless-express for Lambda deployment
AWS Cloud Development Kit infrastructure:
- Infrastructure as Code: AWS CDK v2 for cloud resources
- Deployment: Lambda function deployment for MCP server
- Testing: Jest for infrastructure testing
- Build: esbuild for optimized Lambda bundles
Key Dependencies:
- aws-cdk-lib, constructs for CDK infrastructure
- @modelcontextprotocol/sdk for MCP Lambda integration
- esbuild for bundling and optimization
The project demonstrates a modern application architecture:
- Frontend: React application for user interaction
- Backend: Payment-enabled API server for file operations
- MCP Server: Bridge between AI tools and blockchain/storage services
- Infrastructure: Cloud-ready deployment with AWS CDK
- Follow the monorepo structure and use pnpm workspaces
- Use Biome for code formatting:
pnpm format - Ensure all packages build successfully:
pnpm install && pnpm mcp build && pnpm frontend build - Test MCP integration with GitHub Copilot/VS Code

