Base58Check, step by step
How Base58Check works: a version byte, the payload, four checksum bytes from a double SHA-256, and an alphabet without 0, O, I and l. With the Bitcoin wiki's worked example.
16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvMOpen the checkerThree parts, then one encoding
Base58Check starts from bytes: a version byte that says which network and type, the payload (for an address, the 20-byte hash of a public key or script), and a checksum: the first 4 bytes of SHA-256 applied twice to version and payload. The three are joined and written as one Base58 number.
The Bitcoin wiki's worked example: version 00, hash 010966776006953D5567439E5E39F86A0D273BEE, checksum taken from the double SHA-256, encoded to 16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM.
The alphabet
Base58 uses the digits and letters except 0 (zero), O (capital o), I (capital i) and l (lower-case L), so that characters that look alike cannot both appear. A Base58 address that contains one of these four was mistyped, or is not Base58. XRP uses the same idea with a different order of the 58 characters, which is why XRP addresses start with r.
Which version byte makes which first character
Because the version byte is the most significant part of the number, it fixes the first character:
0x00→1(Bitcoin P2PKH)0x05→3(Bitcoin P2SH)0x30→L,0x32→M(Litecoin)0x1e→D(Dogecoin)0x41→T(TRON)0x4c→X(Dash)0x6f→morn,0xc4→2(Bitcoin testnet)
What the checksum catches
Four bytes means a random change passes the check with a chance of 1 in 4,294,967,296. Practically every typo is caught. What the checksum cannot catch is a different, valid address — one pasted by clipboard malware, or the wrong address copied from the wrong place.
Why the checksum characters are only approximately marked
Base58 does not align with bytes: each character carries about 5.86 bits. The last 4 bytes therefore spread over roughly the last six characters, and the checker marks them as approximate.
FAQ
Why does my Bitcoin address have no 0 or O?
Base58 leaves out 0, O, I and l so that characters that look alike cannot be confused. If an address contains one of them, a character was mistyped.
How likely is it that a typo passes the Base58Check checksum?
About 1 in 4.3 billion for a random change, because the checksum is 4 bytes (32 bits) of a double SHA-256.