DRAIN
TestnetDRAIN Off-chain USDC Payments — Bittensor / Handshake58
Overview
DRAIN is a protocol for ultra-low-cost micropayments using off-chain payment channels with EIP-712 signed vouchers on Polygon. It enables payments as low as $0.0001 per request with only a one-time $0.02 channel opening cost. DRAIN is designed for high-frequency, low-value transactions — exactly the pattern AI agents use when calling tools thousands of times per task.
How It Works
DRAIN uses payment channels — a well-established pattern in crypto for reducing on-chain costs. The flow works as follows:
1. Channel Opening: The payer opens a payment channel by depositing USDC into a smart contract on Polygon (one-time cost of ~$0.02). This creates a channel between the payer and the service provider.
2. Off-chain Vouchers: For each payment, the payer signs an EIP-712 typed data voucher containing the cumulative amount, a monotonically increasing nonce, and an expiry timestamp. This voucher is sent in the x-drain-voucher header — no on-chain transaction needed.
3. Service Delivery: The service provider verifies the EIP-712 signature, checks the amount and nonce, and serves the request. The provider accumulates vouchers.
4. Channel Settlement: At any time, the provider can submit the latest voucher to the smart contract to claim the accumulated payments on-chain. Only one on-chain transaction is needed regardless of how many vouchers were exchanged.
This architecture amortizes gas costs across thousands of requests, making per-token or per-byte pricing economically viable.
How SettleGrid Integrates
SettleGrid supports DRAIN vouchers with full EIP-712 structural validation. When an agent presents a DRAIN voucher via the x-drain-voucher header, SettleGrid parses the voucher (JSON or base64-encoded), validates the EIP-712 signature format, checks the expiry and nonce, verifies the amount covers the tool cost, and optionally validates the channel address against DRAIN_CHANNEL_ADDRESS. Voucher signature recovery uses the EIP-712 typed data standard on Polygon (chain ID 137).
Key Specs
| Protocol | DRAIN — DRAIN Off-chain USDC Payments |
| Backer | Bittensor / Handshake58 |
| Detection Header | x-drain-voucher |
| Identity Type | wallet-address (Polygon) |
| Payment Type | off-chain USDC voucher |
| Status | Testnet |
Code Example
Here is how a developer's tool works with DRAIN via SettleGrid:
// Agent paying for a SettleGrid tool via DRAIN off-chain voucher
const voucher = {
channelAddress: '0x1234...payment-channel-contract',
payer: '0xABCD...my-polygon-wallet',
amount: '100000', // 0.10 USDC (6 decimals)
nonce: 42,
expiry: Math.floor(Date.now() / 1000) + 3600,
signature: '0x...', // EIP-712 signed
}
const response = await fetch('https://settlegrid.ai/api/proxy/embedding-service', {
method: 'POST',
headers: {
'x-drain-voucher': JSON.stringify(voucher),
'Content-Type': 'application/json',
},
body: JSON.stringify({ text: 'Generate embedding for this text' }),
})
// Ultra-low cost: $0.001 per embedding call
// Only $0.02 to open the channel, then unlimited off-chain vouchersStart monetizing with SettleGrid
Free forever — 50,000 ops/month, progressive take rate. Add billing to your DRAIN tool in under 5 minutes.
Get Started Free