How to verify a USDC payment on-chain
Showing a wallet address and trusting a screenshot isn't verification. Here is what a correct check looks like, and the mistake most DIY checkers make.
1. Fetch the receipt
eth_getTransactionReceipt(txHash) on the right chain. No receipt means the tx isn't mined yet (or it's on another chain).
2. Require success
receipt.status === "0x1". Reverted transactions still have receipts.
3. Require confirmations
head - receipt.blockNumber + 1 >= N. On Base and Arbitrum, 3 is a sensible default for digital goods.
4. Read the Transfer logs, from the right contract
An ERC-20 transfer emits Transfer(from, to, value) with topic0 = 0xddf252ad…b3ef. For each log:
- log.address must equal the real USDC contract on that chain (Base:
0x8335…2913, Arbitrum:0xaf88…5831). - topics[2] is the recipient (left-padded to 32 bytes).
- data is the amount (6 decimals for USDC).
The fake-token trap
Anyone can deploy a token named "USDC" and emit a perfectly valid-looking Transfer to your address for any amount. If your checker only looks at the event signature and recipient, it accepts worthless tokens. Always compare log.address with the canonical contract.
5. Sum, then compare
One tx can contain several transfers (e.g. through a router). Sum the ones to your address, then compare with the price.
Or skip all of this
import { verifyPayment } from "paidonchain";
await verifyPayment({ chain: "base", tx, to: PAY_TO, minAmount: "19" });
The library is open source (MIT) and has a test suite covering these cases, including the fake-token attack. Quickstart →