DRAIN

Testnet

DRAIN 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 validation follows the EIP-712 typed-data standard on Polygon (chain ID 137), verifying the voucher's structure rather than recovering the signer address.

Key Specs

ProtocolDRAIN — DRAIN Off-chain USDC Payments
BackerBittensor / Handshake58
Detection Headerx-drain-voucher
Identity Typewallet-address (Polygon)
Payment Typeoff-chain USDC voucher
StatusTestnet

Code Example

Here is how a developer's tool works with DRAIN via SettleGrid:

drain-example.tstypescript
// 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 vouchers

Start 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

SettleGrid Help

AI-powered support

How can I help?

Ask me anything about SettleGrid