Skip to content
recurring-billingusage-based-billing
Joshua C.

Implement Usage-Based Stablecoin Billing with Capped USDC Approvals

Learn how to set up usage-based SaaS billing with recurring, capped USDC approvals onchain. Covers pricing, approvals, error handling, and a worked example.

Implement Usage-Based Stablecoin Billing with Capped USDC Approvals

Usage-based SaaS billing is common when customers pay only for what they use. In crypto, collecting these fees with recurring stablecoin payments requires careful handling of onchain approvals and price metering. This guide covers the mechanics of collecting metered fees with capped USDC approvals, from pricing to settlement and handling edge cases.

Understanding Metered Billing and Capped Approvals

Usage-based billing means each customer has a variable monthly or periodic charge based on their activity. Onchain, you cannot pull funds from a wallet without a signed approval. For recurring billing, this means you need the customer to sign a transaction authorizing your contract or settlement address to spend up to a specific cap in USDC.

A capped approval limits risk for both sides. The customer sets a maximum for what can be charged in a period. This cap is visible before signing. Unlimited approvals are not used. Every recurring approval is bounded and the cap can be updated or revoked by the customer at any time.

Billing Flow: Step by Step

1. Meter Usage and Calculate Charges

Track customer activity in your app. Meter each unit of usage. At the end of the period, sum the usage and apply your price per unit. For example, if you charge $0.10 per API call and the customer made 250 calls, the bill is $25.00.

2. Request Approval for the Billing Cap

Before collection, show the customer the maximum possible charge for the next period. Ask them to sign an onchain approval for your settlement address or contract to spend up to that cap. The cap should be at least as high as their expected maximum usage, possibly with a buffer if you want to avoid failed attempts.

If the customer is already approved for a high enough cap, you do not need a new approval unless usage patterns change.

3. Collect Payment Onchain

At the end of each billing period, collect the actual usage charge. This is a transfer from the customer’s wallet to your settlement address, up to the approved cap. You cannot collect more than the approval allows. If the usage is below the cap, only the amount due is transferred.

The transaction is final once confirmed. There is no chargeback. If the customer’s wallet does not have enough USDC or gas, the payment fails and can be retried once funds are available.

Worked Example: Metered API Billing

Suppose your SaaS product charges $0.05 per API request. You invoice monthly. A customer expects to use up to 1,000 requests, so you set the billing cap at $50 USDC.

Period 1 Usage: - 400 requests × $0.05 = $20.00 - You collect $20.00 USDC from their wallet at month end, using the approval signed for $50.00. - Remaining cap: $30.00. No new approval needed for the next cycle unless usage will exceed $1,000.

Period 2 Usage: - 950 requests × $0.05 = $47.50 - You collect $47.50 USDC, still within the $50.00 cap. - After this, only $2.50 remains on the cap. If the customer’s usage is trending up, prompt them to sign a new approval for a higher cap before the next period.

If Usage Exceeds Cap: - Usage is 1,200 requests × $0.05 = $60.00 - Only $50.00 can be collected. The remaining $10.00 must wait until the customer signs a higher approval.

If Wallet Lacks Funds: - Customer owes $30.00 but has only $20.00 USDC in the wallet. - The payment attempt fails. No funds move. Prompt the customer to top up and retry collection.

Key Implementation Considerations

Price Metering and Idempotent Calls

Always store usage and invoices offchain before attempting collection. This avoids double billing on retries. Use unique invoice IDs or billing period tokens to ensure you never settle the same usage twice.

Approval UX

Clearly display the cap, the period covered, and who controls settlement. Let customers control their approval limit. Never ask for or store private keys. All signatures are handled by the user’s wallet.

Handling Failed Payments

Failed collections can happen due to low balance, revoked approval, or insufficient gas. Build retry logic and notify the customer when payment fails. Do not attempt to re-collect more than the approved amount.

Updating or Revoking Approvals

A customer can update or revoke their capped approval onchain at any time. If revoked, collection is blocked until they sign a new approval. If increased, you may collect higher usage in the future. Always check the allowance before initiating a transfer.

Settlement and Reconciliation

All collected funds settle directly to your onchain address. Reclack never holds customer funds. Each transaction is final once confirmed. For reconciliation, index by transaction hash, customer account, and billing period.

Supported Chains and Assets

This pattern works on Arc, Base, Ethereum and Polygon, with USDC as the settled asset. Do not request or accept other tokens or operate on unsupported networks for this flow.

Example: Solidity Approval and Transfer (for Developers)

If you want to see how the approval and transfer work at the contract level, here is a minimal example. In production, use robust checks and security patterns.

// Approve capped spending (run by customer)
IERC20(USDC).approve(merchantAddress, capAmount);

// Merchant initiates transfer on settlement
IERC20(USDC).transferFrom(customer, merchantAddress, actualUsageAmount);

Check the customer’s allowance before transfer. Only attempt transfer up to the approved cap. If allowance or balance is insufficient, the transfer call will revert.

Operator Checklist

  • Meter and store usage per billing period
  • Set and communicate the cap before requesting approval
  • Collect only up to the cap, never more
  • Provide clear error handling and retry options
  • Let customers revoke or update their approval at any time
  • Reconcile onchain settlements to customer accounts with each transaction hash

We handle these flows at Reclack with non-custodial, capped USDC approvals for metered SaaS billing. Each approval is explicit and bounded. All payments settle directly to your wallet. To learn more about recurring usage-based billing with stablecoins, visit reclack.com.

recurring-billingusage-based-billing