FlowPay combines x402's HTTP-native service discovery with continuous payment streaming for AI agents using MNEE stablecoin. The best of both worlds: standardized discovery + efficient streaming.
π Built for the MNEE Hackathon: Programmable Money for Agents, Commerce, and Automated Finance
| Resource | Link |
|---|---|
| Live dApp | https://flowpay-dashboard.netlify.app |
| Demo Video | Watch on YouTube |
| GitHub Repo | https://github.com/ola-893/flowpay |
| MNEE Contract (Mainnet) | 0x8ccedbAe4916b79da7F3F612EfB2EB93A2bFD6cF |
git clone https://github.com/ola-893/flowpay.git
cd flowpay
npm run install:allnpm run devOpen http://localhost:5173 in your browser.
-
Add Sepolia to MetaMask (if not already added):
- Network: Sepolia
- RPC:
https://sepolia.infura.io/v3/YOUR_KEYor use MetaMask's default - Chain ID:
11155111
-
Get Sepolia ETH for gas fees:
-
Connect wallet and click "Mint MNEE" to get free test tokens
-
Create a stream and watch payments flow in real-time!
That's it! The contracts are already deployed on Sepolia - no deployment needed.
| Contract | Address |
|---|---|
| FlowPayStream | 0x155A00fBE3D290a8935ca4Bf5244283685Bb0035 |
| MockMNEE | 0x96B1FE54Ee89811f46ecE4a347950E0D682D3896 |
Copy .env.example to .env and fill in your values:
cp .env.example .env# Only needed if deploying your own contracts
SEPOLIA_RPC_URL="https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY"
PRIVATE_KEY="YOUR_DEPLOYER_PRIVATE_KEY"
# AI Features (Optional)
GEMINI_API_KEY="your_gemini_api_key"npx hardhat run scripts/deploy.js --network sepolianpm test # Run all tests
npm run test:contracts # Smart contract tests only
npm run test:sdk # SDK tests only| Command | Description |
|---|---|
npm run dev |
Start frontend dev server |
npm run build:web |
Build for production |
npm run test |
Run all tests |
npm run deploy:sepolia |
Deploy contracts to Sepolia |
npm run demo:provider |
Run provider demo |
npm run demo:consumer |
Run consumer demo |
| Approach | Best For | Limitation |
|---|---|---|
| x402 Per-Request | Few API calls | Payment overhead per request |
| Streaming | High-volume usage | Requires upfront deposit |
| FlowPay Hybrid | Any usage pattern | None - best of both! |
1. Agent makes HTTP request to API
2. Server returns HTTP 402 with x402-compatible payment requirements
3. FlowPay SDK parses requirements, uses Gemini AI to decide:
- Few requests expected? β Use x402 per-request mode
- Many requests expected? β Create MNEE payment stream
4. Agent pays and accesses service
5. AI continuously optimizes payment mode based on actual usage
The Challenge: AI agents need to make thousands of micropayments per second for:
- API calls ($0.0001 per call)
- Compute resources ($0.01/second)
- Data feeds ($0.001/second)
- Content consumption (per-token pricing)
Traditional Solutions Fail:
- β Discrete transactions: Too expensive (gas fees exceed payment value)
- β Batching: Creates settlement delays (30+ seconds)
- β Off-chain solutions: Requires trusted intermediaries
FlowPay Solution:
- β x402 discovery: Standard HTTP 402 for universal agent interoperability
- β Streaming payments: Efficient for high-volume usage
- β MNEE stablecoin: Sub-cent fees + instant settlement
- β AI-powered: Gemini decides optimal payment mode
- HTTP 402 responses - Standard payment required responses
- Universal interoperability - Works with any x402-compatible agent
- Payment requirements - Clear pricing in response headers
- Flexible modes - Support both per-request and streaming
- Per-second value transfer - Money flows continuously for high-volume usage
- Instant withdrawals - Recipients claim funds anytime
- Live balance counters - Watch payments stream in real-time
- Micropayment support - Rates as low as $0.0001/second
// Add payment requirements to any Express endpoint
app.use(flowPayMiddleware({
endpoints: {
"GET /api/weather": {
price: "0.0001",
mode: "streaming", // or "per-request"
minDeposit: "1.00",
description: "Real-time weather data"
}
}
}));- Automatic 402 handling - SDK parses payment requirements automatically
- Smart mode selection - Gemini AI chooses streaming vs per-request
- Auto-discovery - Agents find and connect to services via HTTP 402
- Budget management - Spending limits and safety controls
- Payment mode optimization - AI recommends streaming vs per-request
- Spending analysis - Analyzes usage and recommends adjustments
- Service quality evaluation - Automatically switch providers
- Natural language queries - Ask your agent about payment status
- Real-time monitoring - See all active streams with live updates
- x402 discovery logs - Track payment requirement responses
- Agent console - Configure and test AI agents
- Emergency controls - Pause or cancel streams instantly
import { FlowPayAgent } from 'flowpay-sdk';
const agent = new FlowPayAgent({
privateKey: process.env.AGENT_PRIVATE_KEY,
geminiApiKey: process.env.GEMINI_API_KEY
});
// SDK automatically handles x402 flow:
// 1. Makes request β receives HTTP 402
// 2. Parses payment requirements
// 3. AI decides: streaming (high volume) or per-request (low volume)
// 4. Creates MNEE stream if streaming mode
// 5. Retries request with payment proof
const weather = await agent.fetch('https://api.weather-agent.com/forecast');
console.log(await weather.json());import express from 'express';
import { flowPayMiddleware } from 'flowpay-sdk';
const app = express();
// One line to add payment requirements!
app.use(flowPayMiddleware({
endpoints: {
"GET /api/weather": {
price: "0.0001",
mode: "streaming",
minDeposit: "1.00",
description: "Weather data API"
},
"POST /api/translate": {
price: "0.001",
mode: "per-request",
description: "Translation service"
}
},
mneeAddress: process.env.MNEE_ADDRESS,
flowPayContract: process.env.FLOWPAY_CONTRACT
}));
app.get('/api/weather', (req, res) => {
// Only reached if payment verified!
res.json({ temp: 28, city: 'Lagos' });
});// Gemini analyzes usage and recommends optimal mode
const agent = new FlowPayAgent({
geminiApiKey: process.env.GEMINI_API_KEY,
dailyBudget: '50.00'
});
// First request: AI analyzes expected usage
// "I expect to make 1000 API calls" β Streaming mode (more efficient)
// "I need just one translation" β Per-request mode (simpler)
const recommendation = await agent.recommendPaymentMode({
service: 'weather-api',
expectedCalls: 1000,
duration: '1 hour'
});
console.log(recommendation);
// { mode: 'streaming', reason: 'High volume usage - streaming saves 90% on gas' }// Rent GPU resources with real-time payment
const computeStream = await agent.createStream({
recipient: gpuProviderAddress,
ratePerSecond: '0.01', // $36/hour
deposit: '36.00', // 1 hour prepaid
metadata: { purpose: 'ML training' }
});
// Cancel early? Get unused funds back automatically
await computeStream.cancel(); // Refunds remaining deposit| Feature | x402 Only | Streaming Only | FlowPay Hybrid |
|---|---|---|---|
| Discovery | β Standard HTTP 402 | β Custom | β Standard HTTP 402 |
| Low-volume efficiency | β Pay per request | β Deposit overhead | β Per-request mode |
| High-volume efficiency | β Gas per request | β One stream | β Streaming mode |
| AI optimization | β | β | β Gemini selects mode |
| Interoperability | β x402 ecosystem | β Custom | β x402 compatible |
| MNEE native | β Generic | β | β |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FlowPay Hybrid Architecture β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ HTTP Request ββββββββββββββ β
β β Consumer β ββββββββββββββββββββββββββββββΆβ Provider β β
β β Agent β β API β β
β ββββββββ¬ββββββββ βββββββ¬βββββββ β
β β β β
β β ββββββββ HTTP 402 Payment Required ββββββββββ β
β β (x402 compatible headers) β
β β β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β FlowPay SDK β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββββββ β β
β β β x402 Parser β β Gemini AI β β Payment Manager β β β
β β β β β Mode Select β β Stream/Request β β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββββββ β β
β ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββΌββββββββββββββββββββ β
β β β β β
β ββββββββΌβββββββ ββββββββΌβββββββ ββββββββΌβββββββ β
β β FlowPay β β MNEE β β Web β β
β β Contract βββββΆβ Token β β Dashboard β β
β β (Streams) β β (ERC-20) β β (Oversight) β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β
β Ethereum Sepolia Testnet β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Consumer Agent Provider API FlowPay Contract
β β β
βββββ GET /api/weather ββββββΆβ β
β β β
βββββ 402 Payment Required βββ β
β X-Payment-Required: β β
β X-FlowPay-Mode: stream β β
β X-FlowPay-Rate: 0.0001 β β
β β β
β [SDK parses, AI decides] β β
β β β
βββββββββββ createStream βββββββββββββββββββββββββββββββββΆβ
βββββββββββ Stream #1234 ββββββββββββββββββββββββββββββββββ
β β β
βββ GET /api/weather ββββββββΆβ β
β X-FlowPay-Stream: 1234 β β
β βββ verify stream βββββββββββΆβ
β βββ balance OK βββββββββββββββ
βββββ 200 OK + Data ββββββββββ β
β β β
| Component | Technology |
|---|---|
| Blockchain | Ethereum Sepolia Testnet |
| Token | MNEE Stablecoin (ERC-20) |
| Discovery Protocol | x402 (HTTP 402 standard) |
| Smart Contracts | Solidity, Hardhat |
| Agent SDK | TypeScript |
| Server Middleware | Express.js |
| AI Integration | Google Gemini API |
| Frontend | React (Vite), JavaScript |
| Blockchain Interaction | Ethers.js v6 |
| Styling | Tailwind CSS |
When ready for production with real MNEE:
| Feature | Testnet (Sepolia) | Mainnet |
|---|---|---|
| Token | MockMNEE (free mint) | Real MNEE |
| Network | Sepolia (11155111) | Ethereum (1) |
| Gas | Free testnet ETH | Real ETH |
MNEE Mainnet Contract: 0x8ccedbAe4916b79da7F3F612EfB2EB93A2bFD6cF
Update vite-project/src/contactInfo.js with mainnet addresses and deploy FlowPayStream to mainnet.
import { FlowPayAgent } from 'flowpay-sdk';
const agent = new FlowPayAgent({
privateKey: process.env.AGENT_PRIVATE_KEY,
network: 'sepolia'
});
// Create a payment stream
const stream = await agent.createStream({
recipient: '0x1234...5678',
ratePerSecond: '0.0001',
deposit: '10.00',
metadata: {
agentId: 'weather_bot_01',
purpose: 'API Metering'
}
});
console.log(`Stream #${stream.id} created!`);import { FlowPayAgent } from 'flowpay-sdk';
const agent = new FlowPayAgent({
privateKey: process.env.AGENT_PRIVATE_KEY,
geminiApiKey: process.env.GEMINI_API_KEY,
dailyBudget: '50.00'
});
// Let AI optimize your spending
const decision = await agent.optimizeSpending();
console.log(`AI Decision: ${decision.action}`);
console.log(`Reasoning: ${decision.reasoning}`);
// Natural language queries
const response = await agent.ask("Should I subscribe to the translation API?");
console.log(response);Watch two AI agents transact autonomously:
- Agent Alice (Consumer) needs weather data
- Agent Bob (Provider) offers weather API at $0.0001/call
- Alice opens a FlowPay stream to Bob
- Alice makes 1,000 API calls over 10 minutes
- Bob's balance increases in real-time: $0.00 β $0.10
- Bob withdraws earnings anytime
- Alice cancels stream when done, gets unused deposit back
All payments happen automatically, no human intervention!
- Spending Limits: Daily and per-stream caps
- Emergency Pause: Instantly stop all agent activity
- Auto-cancellation: Streams cancel when services fail
- Suspicious Activity Detection: AI monitors for anomalies
- Human Override: Dashboard controls for manual intervention
flowpay/
βββ contracts/
β βββ FlowPayStream.sol # MNEE streaming contract
β βββ MockMNEE.sol # Test token for Sepolia
βββ scripts/
β βββ deploy.js # Deployment script
βββ sdk/
β βββ src/
β βββ FlowPaySDK.ts # Agent SDK with x402 handling
β βββ GeminiPaymentBrain.ts # AI payment decisions
β βββ SpendingMonitor.ts # Budget management
βββ server/
β βββ middleware/
β βββ flowPayMiddleware.js # x402 Express middleware
βββ demo/
β βββ consumer.ts # AI agent demo (consumer)
β βββ provider.ts # API provider demo
βββ vite-project/
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Dashboard, Streams, Docs
β β βββ context/ # Wallet context
β β βββ contactInfo.js # Contract addresses
β βββ netlify.toml # Deployment config
βββ test/
β βββ FlowPayStream.test.js # Contract tests
βββ hardhat.config.js
βββ package.json
βββ LICENSE # MIT License
βββ README.md
AI & Agent Payments - Agents or automated systems paying for services or data
FlowPay uses MNEE stablecoin as the payment token for all streaming payments:
- Payment Streams: MNEE tokens are locked in the FlowPayStream smart contract and streamed per-second to recipients
- x402 Protocol: AI agents pay for API access using MNEE via the x402 HTTP payment negotiation standard
- Testnet: Uses MockMNEE (
0x96B1FE54Ee89811f46ecE4a347950E0D682D3896) on Sepolia - Mainnet Ready: Designed to work with real MNEE (
0x8ccedbAe4916b79da7F3F612EfB2EB93A2bFD6cF) on Ethereum mainnet
FlowPay demonstrates:
- β x402-compatible service discovery (HTTP 402 standard)
- β AI agents transacting autonomously with MNEE
- β Hybrid payment modes (per-request + streaming)
- β Intelligent decision-making with Gemini AI
- β Multi-agent service coordination
- β Human oversight and safety controls
- x402 Compatibility - Works with the emerging agent payment ecosystem
- Streaming Efficiency - 90% gas savings for high-volume usage
- AI-Powered - Gemini automatically optimizes payment mode
- MNEE Native - Built specifically for MNEE stablecoin
- Production Ready - Express middleware for easy integration
| Dependency | Purpose | License |
|---|---|---|
| Ethers.js | Blockchain interaction | MIT |
| React | Frontend framework | MIT |
| Vite | Build tool | MIT |
| Tailwind CSS | Styling | MIT |
| Hardhat | Smart contract development | MIT |
| Google Gemini API | AI payment decisions | Google API Terms |
| Axios | HTTP client | MIT |
All third-party dependencies are used in accordance with their respective licenses.
MIT License - see LICENSE for details.
- MNEE - USD-backed stablecoin powering this project
- Google Gemini - AI decision-making capabilities
- Ethereum - Blockchain infrastructure
Built with π for the MNEE Hackathon
Enabling the autonomous economy, one stream at a time.