Sub topic 12
Receiving Funds and Checking That They Arrived
Assume you know what a blockchain transaction is, can read a wallet address, and understand that different networks can use similar address formats. This chapter focuses on verifying a payment rather than trusting a wallet notification.
What You Need to Verify
A received payment is correct only when all of these match:
- The transaction uses the expected network.
- The destination address is yours.
- The asset is the expected native coin or token.
- The amount is correct after accounting for token decimals.
- The transaction is included in a block.
- The transaction has enough confirmations for your risk level.
- A token transfer reached your address, rather than merely calling a token contract.
An address alone does not identify a network. The same hexadecimal address may exist on several EVM-compatible networks, but balances and transactions on those networks are separate.
Follow the Payment
Ask the sender for the transaction hash, also called a transaction ID. Search that hash on the block explorer for the expected network. Do not use a similarly named explorer for another chain.
A typical verification path looks like this:
A transaction that appears as pending has not yet been included in a block. Once included, it has one confirmation in many explorer interfaces. A simple count is:
current block number - transaction block number + 1
More confirmations reduce the chance that a chain reorganization removes the transaction, but they do not make an incorrect address or network correct.
Check Native Coins
For a native coin, inspect the receiving address on the correct explorer. Compare the balance before and after the payment when possible. The transaction details should show:
- The correct recipient.
- The transferred value.
- The transaction status as successful.
- The block number and timestamp.
- The network fee, which is normally paid by the sender.
A successful transaction means the network executed it successfully. It does not prove that the recipient is the person you intended to pay.
Check Tokens
Tokens are recorded by smart contracts. The native balance of an address can remain unchanged even when a token payment succeeds. Check the token contract address, token symbol, sender, recipient, raw amount, and token decimals.
For example, a token with 6 decimals represents 5.0 tokens as 5,000,000 smallest units. Do not verify a token only by its symbol. Different contracts can use the same symbol.
import { JsonRpcProvider, formatEther } from "ethers";
const provider = new JsonRpcProvider(process.env.RPC_URL);
const address = process.env.RECEIVING_ADDRESS;
const tx = await provider.getTransaction(process.env.TX_HASH);
const currentBlock = await provider.getBlockNumber();
console.log("Native balance:", formatEther(await provider.getBalance(address)));
if (!tx || tx.blockNumber === null) {
console.log("The transaction is not included yet");
} else {
console.log("Confirmations:", currentBlock - tx.blockNumber + 1);
}This example checks a native balance and transaction inclusion. For tokens, query the token contract's balanceOf function or inspect the explorer's token-transfer events.
Confirmation Policy
Choose a confirmation policy before accepting payments. A small, low-risk payment may be accepted after one confirmation. A large or irreversible settlement may require several confirmations or the network's documented finality point. Follow the recipient service's policy when one exists.
Exercise
Exercise
A sender provides a successful transaction hash, but your wallet balance did not increase. What should you check first?
Show answer
Check that the transaction is on the expected network, that its recipient is your exact address, and that the asset is the expected token contract rather than a similarly named token.