Skip to main content
Circle Gateway enables nanopayments by batching many individual payment authorizations into a single onchain transaction. Instead of settling each payment separately (and paying gas each time), Gateway collects signed authorizations offchain, computes net balance changes, and applies them in bulk. This document explains the batching lifecycle, the security model that keeps it non-custodial, and how balances move through the system.

The economics of batching

Settling a USDC transfer onchain costs gas. Even on low-fee blockchains, gas costs can exceed the value of a sub-cent payment. Batching solves this by amortizing gas across thousands of payments:
ApproachGas cost per paymentViable minimum payment
Individual settlementFull gas per transaction~$0.01+ (depends on blockchain)
Batched settlementGas / number of payments in batch$0.000001
By settling net positions rather than individual transfers, Gateway reduces both the number of onchain transactions and the total gas consumed.

Payment lifecycle

A nanopayment moves through five stages from initiation to settlement:
1

Deposit

The buyer deposits USDC from their wallet into a Gateway Wallet contract. This is a one-time onchain transaction that establishes the buyer’s Gateway balance. Once deposited, the buyer can make gasless payments from this balance.
2

Request and negotiate

The buyer requests a paid resource. The seller responds with 402 Payment Required, including payment details. This follows the standard x402 protocol flow.
3

Sign authorization

The buyer signs an EIP-3009 TransferWithAuthorization message authorizing Gateway to transfer USDC from their balance to the seller. This signature is created offchain and costs zero gas. The buyer retries the request with the signed authorization attached.
4

Settle and serve

The seller (or a facilitator) submits the signed authorization to Gateway. Gateway verifies the signature, locks the buyer’s funds, and credits the seller’s pending balance. The seller serves the resource immediately, without waiting for onchain settlement. Neither the buyer nor the seller pays gas for this step.
5

Batch and onchain settlement

Gateway periodically collects pending authorizations, computes net balance changes across all participants, and submits a single onchain transaction that applies the changes. After onchain confirmation, pending balances become available. The seller can then withdraw funds to any supported blockchain.

Security model

Gateway’s batching system is non-custodial. Gateway never has arbitrary control over user funds. The security model relies on three components:

Trusted execution environment (TEE)

A Trusted Execution Environment (TEE) is an isolated hardware enclave that runs code in a secure, tamper-proof environment. Gateway uses an AWS Nitro Enclave to:
  • Verify every EIP-3009 signature before including it in a batch
  • Compute net balance changes across all payments in the batch
  • Sign the batch result with the enclave’s private key
The enclave’s signing key is protected by AWS Key Management Service (KMS) with attestation-based access policies. Only the audited enclave image can access the key. Even Circle operators cannot extract it outside the enclave.

Onchain verification

The Gateway Wallet smart contract verifies the TEE’s signature before executing any batch. If the signature is invalid or comes from an unauthorized signer, the contract reverts. This ensures that only correctly computed batches are applied onchain.

Cryptographic attestations

AWS Nitro Enclaves produce cryptographic attestation documents that prove the enclave is running a specific, audited code image. These attestations can be independently verified, providing transparency into the batching process.

Balance states

Gateway tracks funds through multiple states as they move through the batching pipeline:
StateDescription
availableSpendable balance. Set after deposit or after receiving a settled batch payment.

Example: Alice sends 10 USDC to Bob

EventAlice (sender)Bob (receiver)
Initial stateavailable: 100available: 0
Authorization submittedavailable: 90available: 0
Batch settled onchainavailable: 90available: 10
When Alice submits her authorization, Gateway locks her funds internally. Once the batch settles onchain, Bob’s available balance increases.

Withdrawal

After settlement, sellers (and buyers) can withdraw their Gateway balance to any supported blockchain. Same-chain withdrawals are instant. Crosschain withdrawals use Gateway’s standard minting infrastructure and are also near instant.