Skip to content
onchain-engineeringusdcbilling
Joshua C.

Building USDC Payment Reminders with Onchain Status Checks

Step-by-step guide to implementing USDC payment reminders with onchain status checks. Learn how to track, notify, and automate stablecoin invoice reminders.

Building USDC Payment Reminders with Onchain Status Checks

Tracking USDC payments onchain is straightforward, but combining that with an automated reminder system takes a bit more work. If you want to notify users about unpaid invoices or failed attempts, you need to detect payment status reliably, then trigger the right message at the right time. This guide walks through how to build such a system, starting from onchain payment tracking to delivery of reminders by email or other channels.

Why Onchain Payment Reminders Matter

Most SaaS and service businesses send reminders when invoices are due or overdue. In stablecoin billing, this becomes a technical problem: onchain payments settle outside your backend and can be triggered by the user at any time. Automated reminders reduce revenue leakage and give customers a clear prompt to act.

Core Concepts: Tracking USDC Payments Onchain

To send accurate reminders, you need to answer two questions:

  1. Has the invoice been paid, and is the payment final?
  2. If not, has the invoice expired or failed, or is it just pending?

Onchain, you track these by watching for USDC transfers to the merchant settlement address, matching the expected amount, on the correct chain.

Monitoring Settlement Addresses

Each invoice or subscription should have a unique reference: either a dedicated address, a unique payment reference in the transaction memo (if supported), or an offchain mapping of expected sender, amount, and invoice ID. For USDC, the most reliable approach is monitoring the merchant’s settlement address for incoming transfers of the required amount.

You can use a service or run your own indexer. For a simple implementation, most teams use a provider like Alchemy or Infura to subscribe to ERC-20 Transfer events.

Example: Tracking an Invoice Payment

Suppose you issue an invoice for $200 USDC on Polygon. The invoice is due in 7 days. You expect payment to your address 0xMerchant.... The customer will send exactly 200 USDC from their wallet.

You need to: - Record the invoice details (ID, due date, amount, payer, settlement address, chain) - Listen for incoming USDC transfers to 0xMerchant... on Polygon - When a transfer matches the amount and (optionally) sender, mark the invoice as paid

// Example: Using ethers.js to watch for USDC payments on Polygon
import { ethers } from "ethers";
const provider = new ethers.providers.JsonRpcProvider("https://polygon-rpc.com");
const USDC_ADDRESS = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
const merchantAddress = "0xMerchant...";
const requiredAmount = ethers.utils.parseUnits("200", 6);
const USDC_ABI = ["event Transfer(address indexed from, address indexed to, uint256 value)"];

const usdc = new ethers.Contract(USDC_ADDRESS, USDC_ABI, provider);
usdc.on("Transfer", (from, to, value, event) => {
  if (
    to.toLowerCase() === merchantAddress.toLowerCase() &&
    value.eq(requiredAmount)
  ) {
    // Mark invoice as paid in your system
    console.log(`Invoice paid by ${from}, tx: ${event.transactionHash}`);
  }
});

This script listens for any transfer of exactly 200 USDC to your address on Polygon. You can extend this to check sender addresses or to match amounts within a small tolerance if you want to support split payments.

Detecting Unpaid and Overdue Invoices

To send reminders, you need to regularly check for invoices that are not marked as paid and are approaching or past their due date. This is a standard query in your database. For each unpaid invoice, check: - Has the due date passed, or is it within a reminder window (e.g., 3 days before due)? - Has a corresponding onchain payment been seen?

If not, the invoice is a candidate for a reminder.

Automating Reminders: Email and Beyond

Once you have a list of unpaid or overdue invoices, trigger your reminder workflow. For most teams, this is an email notification. You can also integrate with Telegram, SMS, or push notification services.

Include key invoice details: - Amount due - Settlement address and chain - Due date - Link to the hosted checkout or payment link, if available

Email Reminder Template Example

Subject: “Your USDC Payment is Due”

Body:

Hi,

This is a reminder that your payment of 200 USDC is due for Invoice #12345.

  • Settlement address: 0xMerchant…
  • Chain: Polygon
  • Due date: 2024-07-15

You can pay using the following link: Pay Invoice

If you have already paid, you can ignore this reminder.

Handling Missed or Partial Payments

Onchain payments are final. If a customer sends less than the invoice amount, you need to detect the shortfall and notify them. You can either: - Mark the invoice as partially paid and request the remainder - Let the customer know that the payment did not settle the invoice

For recurring subscriptions, you might retry the charge or pause access until full payment is received.

Chaining Onchain Status to Reminder Logic

Your workflow should look like this: 1. Issue invoice and record all details 2. Monitor onchain for payment to settlement address 3. On payment, mark invoice as paid 4. If unpaid and nearing due date, send reminder 5. If overdue, escalate reminder or pause service

This pattern works for both one-time and recurring payments. For usage-based billing, the same logic applies: track usage, issue invoice, monitor payment, and send reminders as needed.

Real-World Example: Invoice Lifecycle

Assume you run a SaaS tool that bills $50 USDC per month per user on Base. You issue an invoice for July to Alice: - Invoice ID: INV-2024-07-ALICE - Amount: 50 USDC - Due date: 2024-07-10 - Settlement address: 0xSaaS…

Day 0: Invoice issued via email with payment link.

Day 4 (3 days before due): Alice has not paid. System detects unpaid invoice, sends reminder email.

Day 8 (1 day before due): Still unpaid. Final reminder sent.

Day 10: Invoice due. No payment seen. Service access paused, Alice notified.

Day 12: Alice sends 50 USDC on Base to 0xSaaS…. Payment detected, invoice marked paid, access restored.

Error Cases and Edge Conditions

  • Wrong chain: Payment sent on Ethereum instead of Base. System does not mark as paid. Notify customer with correct settlement instructions.
  • Incorrect amount: 48 USDC sent. System flags as partial payment. Notify customer of shortfall.
  • Multiple payments: Two payments of 25 USDC each. Detect both, sum to 50 USDC, mark as paid when threshold met.

Tools and Libraries

Scaling and Operational Tips

  • Watch only active, unpaid invoices to reduce event processing load
  • Index by both destination address and expected amount for efficiency
  • For large invoice volume, consider running a lightweight event indexer
  • Log all detected payments with transaction hashes for auditability

How We Handle Payment Reminders at Reclack

At Reclack, we use these same mechanics to automate payment reminders for USDC invoices and subscriptions. Our platform tracks onchain payment status in real time, triggers reminders before and after due dates, and handles all edge cases around underpayment, wrong chain, or delayed settlement. If you want to see how a complete onchain billing system handles reminders and notifications, visit reclack.com for details.

onchain-engineeringusdcbilling