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.

๐Ÿ’ก Live on Mainnet! OpacusPay is now deployed on 0G Mainnet with real USDC.e support. Try the live demo โ†’

๐Ÿ“Š How OpacusPay Works

PAYER AI Agent / User 1. Lock USDC ESCROW Smart Contract 2. Verify Hash PAYEE Service Provider 3. Deliver DATA API Response 4. Confirm 5. Release โœ“ PAID To Payee 6. USDC Transfer ๐Ÿ” 0G Data Availability Layer Datagram hashes + ZK proofs stored on-chain for transparency
โšก Instant Lock
USDC locked in escrow with unique ID and datagram hash recorded on-chain
๐Ÿ”’ Trustless Escrow
Smart contract holds funds until service delivery is verified by relayer
๐Ÿ“Š Byte Metering
Accurate tracking of bytes delivered ensures fair payment for actual data
โœ… Auto-Release
Payment automatically released upon successful delivery verification

๐Ÿ”ง Core Functions

OpacusPay provides six primary payment types, each optimized for specific use cases:

๐Ÿ“ฑ
1. Micropayments

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
);
๐Ÿ’ณ
2. Regular Payments

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!" })
});
๐Ÿ’ฐ
3. Batch Payments

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!
๐ŸŽฅ
4. Streaming Payments

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)
๐Ÿ”Œ
5. API Auto-Payment

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" } });
  }
);
๐Ÿค–
6. Agent-to-Agent Payments

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

Example 1: Micropayment
Payment: $0.001 USDC
Protocol fee (5%): $0.00005
Gas: $0.00002
Total: $0.00107 USDC
Example 2: AI API Call
Payment: $0.002 USDC
Protocol fee (5%): $0.0001
Gas: $0.00002
Total: $0.00212 USDC
Example 3: Batch (1000 payments)
Total payments: $1.00 USDC
Protocol fee (5%): $0.05
Gas (individual): $0.02
Gas (batch): $0.0001
Savings: $0.0199 (99.5%)
Example 4: With Reputation (score 100)
Base payment: $1.00 USDC
Protocol fee (5%): $0.05
Reputation discount (20%): -$0.01
Final fee: $0.04 (4%)

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

Minimum payment: 0.001 USDC (1000 wei)
Minimum approval: 0.01 USDC
Relayer bond: 1.0 0G (refundable)

โš™๏ธ How It Works

Payment Flow

  1. Lock Payment
    lockPayment(escrowId, payee, amount, datagramHash, nonce)
    • Funds locked in smart contract escrow
    • Datagram hash recorded on-chain
    • Nonce prevents replay attacks
  2. Verify Payment
    • Check payment state on-chain
    • Validate escrow ID matches
    • Confirm amount is correct
  3. Release Payment
    releasePayment(escrowId, bytesDelivered)
    • Only authorized relayer can release
    • Byte metering recorded on-chain
    • Protocol fee (5%) โ†’ treasury
    • Reputation discount โ†’ relayer
    • Remainder โ†’ payee
โš ๏ธ Security: All functions use OpenZeppelin's reentrancy protection. Nonces ensure each payment is unique and cannot be replayed.

๐ŸŒ Network Configuration

OpacusPay is live on both testnet and mainnet:

๐Ÿงช 0G Galileo Testnet

Chain ID: 16602
RPC: https://evmrpc-testnet.0g.ai
Explorer: https://chainscan-galileo.0g.ai
Escrow Contract: 0x4Bb9Bc3DEF78A93B7e4A9a947698400805dC1C7a
Mock USDC: 0x96f7c32232E60C89F1aef5bF1fC0a1695F67c483
Faucet: https://faucet.0g.ai

๐Ÿ”ฅ 0G Mainnet (Production) LIVE

Chain ID: 16661
RPC: https://evmrpc.0g.ai
Explorer: https://chainscan.0g.ai
Escrow Contract: 0x74129D43A721Ba29C94D1C12bc7e0aB9c9b256F7
USDC.e: 0x1f3aa82227281ca364bfb3d253b0f1af1da6473e
โš ๏ธ Mainnet Warning: This is REAL MONEY! All transactions are permanent. Start with very small amounts (0.001-0.01 USDC) for testing.

๐Ÿš€ 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:

Launch Interactive Demo โ†’

๐ŸŽฏ Real-World Use Cases

AI API Services

Volume: 1M requests/day

Traditional Cost: $10,000/day
OpacusPay Cost: $2,000/day
Savings: $8,000/day (80%)
IoT Sensor Networks

Volume: 10M readings/day

Traditional: IMPOSSIBLE (min $0.01)
OpacusPay: $10/day
Enabled: 10,000x smaller payments
Video Streaming

Duration: 1 hour (3600 chunks)

Individual Settlement: $0.072
Batch Settlement: $0.00002
Savings: 99.97%

๐Ÿ”’ Security Features

๐Ÿ›ก๏ธ
Reentrancy Protection

All state-changing functions use OpenZeppelin's nonReentrant modifier to prevent reentrancy attacks.

๐Ÿ”ข
Nonce-Based Replay Protection

Each payment requires a unique nonce, ensuring payments cannot be replayed or duplicated.

๐Ÿ‘ฅ
Authorized Relayers

Only bonded relayers (1.0 0G bond) can release payments, ensuring accountability and quality.

๐Ÿ“Š
Byte Metering

Accurate on-chain tracking of bytes delivered ensures fair payment for actual data transferred.

๐Ÿ”
E2E Encryption

Optional end-to-end encryption using x25519 ECDH + ChaCha20-Poly1305 AEAD, beyond TLS.

๐Ÿ†
Reputation System

Track relayer performance with on-chain reputation scores, unlocking fee discounts up to 20%.

๐Ÿ“š Additional Resources

๐ŸŽฏ Next Steps

  1. Try the Demo: Experience OpacusPay in action at our live demo
  2. Install SDK: npm install @opacus/sdk
  3. Join Community: Connect with developers on Discord
  4. Build: Start integrating OpacusPay into your AI agent or IoT project!
๐Ÿ’ก Need Help? Join our Discord or check the full documentation for detailed guides and examples.