OpacusPay MAINNET LIVE
Next-generation micropayment protocol for AI agents, IoT networks, and real-time streaming.
๐ Overview
OpacusPay is a revolutionary micropayment protocol designed for the AI agent economy. Traditional payment systems have a minimum payment of $0.01, making them unsuitable for modern use cases like AI agent interactions, IoT sensor networks, and per-datagram streaming.
OpacusPay solves this with payments as low as $0.000001 and transparent, trustless on-chain settlement.
๐ How OpacusPay Works
๐ง Core Functions
OpacusPay provides six primary payment types, each optimized for specific use cases:
Use case: AI agent messages, IoT sensor readings, micro-transactions
Min amount: $0.000001 USDC
How it works:
- Lock USDC in escrow
- Generate unique escrow ID
- Record datagram hash on-chain
- Deliver service
- Release payment with byte metering
const payment = await client.lockDatagramPayment(
payeeAddress,
"0.001",
datagramBuffer
);
await client.releaseDatagramPayment(
payment.escrowId,
datagramBuffer.length
);
Use case: API calls, service requests, standard transactions
Typical amount: $0.001 - $1.00 USDC
How it works:
- Register service with pricing
- Auto-calculate payment amount
- Add payment headers
- Make HTTP request
- Auto-release on success (2xx)
- Auto-refund on failure (4xx/5xx)
await client.registerService({
endpoint: "https://api.example.com/v1/chat",
costPerCall: "0.002",
payee: "0xServiceProvider"
});
const response = await client.callAPI(endpoint, {
method: "POST",
body: JSON.stringify({ prompt: "Hello!" })
});
Use case: High-volume transactions, multi-recipient settlements
Savings: 99.5% gas reduction
How it works:
- Create batch with multiple recipients
- Aggregate all payments
- Generate ZK proof
- Single settlement transaction
- Distribute to all recipients
const batchId = await client.createBatchPayment([
{ address: "0xAddr1", amount: "0.5" },
{ address: "0xAddr2", amount: "0.3" },
{ address: "0xAddr3", amount: "0.2" }
]);
await client.executeBatch(batchId, {
generateZKProof: true
});
// Gas: Individual (210K) โ Batch (100K) = 52% savings
// With 1000 payments: 99.86% savings!
Use case: Video/audio streaming, real-time data feeds
Billing: Per-datagram metering
How it works:
- Start streaming session
- Add datagrams as they arrive
- Track bytes delivered
- Close with batch settlement
- 99.5% gas savings with ZK proof
const sessionId = await client.startStreamingSession(
"wss://stream.example.com/video",
300 // 5 minutes
);
for await (const chunk of videoStream) {
await client.addToStream(sessionId, chunk, "0.000001");
}
const settlement = await client.closeStream(sessionId, {
generateZKProof: true
});
// 3600 chunks: $0.072 โ $0.00002 (99.97% savings)
Use case: Automated services, pay-per-use APIs
Integration: Express.js middleware
How it works:
- Client sends payment headers
- Middleware verifies on-chain
- Handler executes if valid
- Auto-release after response
- Byte metering recorded
const middleware = new PaymentMiddleware(client);
app.post('/api/chat',
middleware.verify({ costPerCall: "0.002" }),
async (req, res) => {
const { escrowId, verified } = req.payment;
if (!verified) return res.status(402).json({ error: 'Payment required' });
const response = await aiModel.generate(req.body.prompt);
res.json({ response, payment: { escrowId, status: "verified" } });
}
);
Use case: AI agents paying each other for services
Protection: Smart escrow with dispute resolution
How it works:
- Agent A locks payment for service
- Agent B completes task
- Agent A verifies results
- Payment released or refunded
- Reputation tracking for both
const escrowId = await client.payAgent({
fromAgent: "0xAgentA",
toAgent: "0xAgentB",
serviceType: "data-analysis",
amount: "0.005",
metadata: {
task: "analyze-user-behavior",
deadline: Date.now() + 3600000
}
});
// Agent B completes task
const results = await agentB.analyzeData(dataset);
// Agent A verifies and releases
if (await agentA.verifyResults(results)) {
await client.releasePayment(escrowId, results.bytesDelivered);
}
๐ฐ Pricing & Fees
OpacusPay uses a transparent 5% protocol fee on all transactions, with additional discounts for high-reputation relayers.
Fee Structure
| Payment Type | Protocol Fee | Gas Cost (0G Chain) | Total Cost |
|---|---|---|---|
| Micropayment (< 0.01 USDC) | 5% | ~$0.00002 | 5% + gas |
| Regular Payment (0.01-100 USDC) | 5% | ~$0.00002 | 5% + gas |
| Batch Settlement (1000 txs) | 5% | ~$0.0001 | 5% + (gas/1000) |
Real-World Examples
Reputation Discounts
High-quality relayers earn reputation scores that unlock fee discounts:
| Reputation Score | Discount | Effective Fee |
|---|---|---|
| 0-20 | 0% | 5.00% |
| 21-40 | 4% | 4.80% |
| 41-60 | 8% | 4.40% |
| 61-80 | 12% | 4.00% |
| 81-100 | 20% | 3.60% |
Formula: discount = (baseFee ร reputationScore) / 500
Minimum Amounts & Bonds
โ๏ธ How It Works
Payment Flow
-
Lock Payment
lockPayment(escrowId, payee, amount, datagramHash, nonce)- Funds locked in smart contract escrow
- Datagram hash recorded on-chain
- Nonce prevents replay attacks
-
Verify Payment
- Check payment state on-chain
- Validate escrow ID matches
- Confirm amount is correct
-
Release Payment
releasePayment(escrowId, bytesDelivered)- Only authorized relayer can release
- Byte metering recorded on-chain
- Protocol fee (5%) โ treasury
- Reputation discount โ relayer
- Remainder โ payee
๐ Network Configuration
OpacusPay is live on both testnet and mainnet:
๐งช 0G Galileo Testnet
๐ฅ 0G Mainnet (Production) LIVE
๐ Quick Start
1. Installation
npm install @opacus/sdk ethers
2. Setup Client
import { ethers } from 'ethers';
import { AutoPaymentClient } from '@opacus/sdk';
// Mainnet configuration
const provider = new ethers.JsonRpcProvider('https://evmrpc.0g.ai');
const signer = new ethers.Wallet(PRIVATE_KEY, provider);
const client = new AutoPaymentClient({
provider,
signer,
escrowAddress: "0x74129D43A721Ba29C94D1C12bc7e0aB9c9b256F7",
usdcAddress: "0x1f3aa82227281ca364bfb3d253b0f1af1da6473e",
autoApprove: true,
maxAutoPayment: "10.0", // Pre-approve 10 USDC
networkType: 'mainnet'
});
3. Make Your First Payment
// Register service
await client.registerService({
endpoint: "https://api.example.com/v1/chat",
costPerCall: "0.002",
payee: "0xServiceProviderAddress"
});
// Make API call with automatic payment
const response = await client.callAPI(
"https://api.example.com/v1/chat",
{
method: "POST",
body: JSON.stringify({ prompt: "Hello, OpacusPay!" })
}
);
const data = await response.json();
console.log("Response:", data);
// Payment automatically locked โ API called โ released!
4. Try the Live Demo
Experience OpacusPay in action with our interactive demo:
๐ฏ Real-World Use Cases
Volume: 1M requests/day
Volume: 10M readings/day
Duration: 1 hour (3600 chunks)
๐ Security Features
All state-changing functions use OpenZeppelin's nonReentrant modifier to prevent reentrancy attacks.
Each payment requires a unique nonce, ensuring payments cannot be replayed or duplicated.
Only bonded relayers (1.0 0G bond) can release payments, ensuring accountability and quality.
Accurate on-chain tracking of bytes delivered ensures fair payment for actual data transferred.
Optional end-to-end encryption using x25519 ECDH + ChaCha20-Poly1305 AEAD, beyond TLS.
Track relayer performance with on-chain reputation scores, unlocking fee discounts up to 20%.
๐ Additional Resources
๐ฏ Next Steps
- Try the Demo: Experience OpacusPay in action at our live demo
- Install SDK:
npm install @opacus/sdk - Join Community: Connect with developers on Discord
- Build: Start integrating OpacusPay into your AI agent or IoT project!