Address formats and checksums, and the Keccak vs SHA-3 trap
An address is not a random string. It is data plus a checksum, and validating it in code catches the typing mistakes that lose money.
Bitcoin
- Base58Check (legacy): a version byte, the payload (a 20-byte hash) and a four-byte checksum, the first four bytes of a double SHA-256 of the rest. Addresses starting with
1are P2PKH and those starting with3are P2SH. Base58 leaves out 0, O, I and l, which look alike, and it is case sensitive. - Bech32 (BIP 173): addresses beginning
bc1qfor native SegWit. It uses a BCH error-detecting code that can even locate a small number of typos, and it is case-insensitive, though mixed case is not allowed. - Bech32m (BIP 350): the same encoding with a different checksum constant, used for Taproot addresses beginning
bc1p.
Ethereum
An Ethereum address is the last 20 bytes of the Keccak-256 hash of the public key (the 64-byte uncompressed key without its prefix byte). Written as hex, it carries no checksum by itself. EIP-55 added an optional one hidden in the capitalisation: hash the lowercase hex address and uppercase each letter whose corresponding hash digit is 8 or higher. A wallet that receives a mixed-case address can then verify it, and an all-lowercase address is accepted with no check, which is why you should require the checksummed form in your own forms.
Tron
A Tron address uses the same 20 bytes, prefixed with 0x41, and encoded in Base58Check, giving a 34-character string beginning with T. APIs return either that or the hex form with the 41 prefix, and libraries mix them up. Convert at your edges and store one canonical form.
The Keccak trap
Keccak-256 is the algorithm that won the SHA-3 competition. NIST then made small changes to its padding when standardising it as SHA3-256. Ethereum had already adopted the original Keccak, so the two produce different digests for the same input. Python's hashlib.sha3_256 is the NIST version. Using it to compute an Ethereum address or a function selector gives a wrong value that looks perfectly plausible.

Use a library that says Keccak (pycryptodome's keccak, eth-hash, pysha3 in older setups, or ethers and viem in JavaScript). Test against a known vector: the Keccak-256 of empty input is c5d24601...a470, and the SHA3-256 of empty input is a7ffc6f8...f8434a.
Practical rules for a payment form
- Validate the format and checksum on the server, and reject invalid input instead of correcting it.
- Never change the case of a Base58 string, since it will not be the same address.
- Show the beginning and the end of the address to the user when they confirm, and consider that copy and paste malware can swap addresses in the clipboard.
- Tie the address to its network. A valid-looking Ethereum address on Tron, or the reverse, is a common mistake in support tickets, since the same 20 bytes exist on both, and sending to the wrong network can mean permanent loss.
Human-readable names carry their own spoofing risk
Address-naming services such as ENS (Ethereum Name Service) let a wallet display alice.eth instead of a 40-character hex address, which solves a real usability problem but introduces a different risk than the checksum and format issues above: names that look alike to a human eye but are different strings to a computer. A name using a character from a different script that renders identically or near-identically to a Latin letter (a homoglyph) can resolve to an entirely different, attacker-controlled address while looking correct in a wallet's display, especially in fonts or interfaces that do not visually distinguish the scripts involved. This is a naming-layer problem, separate from the checksum mechanisms described above, which validate that an address string was not mistyped but say nothing about whether a human-readable name that resolves to a technically valid address is the name the user actually intended to send to. Software that displays resolved names alongside the raw address they resolved to, and that flags mixed-script names for extra scrutiny, addresses a problem that address checksums alone do not touch.