Sub topic 2
Reading address formats: Bitcoin, Ethereum and Solana
This chapter assumes you know what a blockchain is and have sent crypto from a wallet or an exchange. You should also be comfortable reading hexadecimal. The chapter shows how to read an address string: which family it belongs to, what its checksum protects, and what the string cannot tell you.
What an address string encodes
The previous chapter covered how a private key produces a public key, and how an address is derived from that public key. An address is a compact, human-copyable encoding of that derived value, plus a few extra bytes that help catch typing mistakes.
Each blockchain family chose its own derivation, byte layout and text encoding. The result is a few recognizable "looks":
- Bitcoin addresses start with
1,3orbc1. - Ethereum-style addresses start with
0xand contain 40 hexadecimal digits. - Solana addresses are 32 to 44 characters of base58 with no fixed prefix.
Reading these patterns is useful, but it has a hard limit. A format identifies a family of software and cryptography. It does not identify the one network that will receive your money. The rest of the chapter returns to this limit.
Bitcoin address formats
Bitcoin mainnet has several address types, which were introduced over time.
| Type | Starts with | Typical length | Encoding |
|---|---|---|---|
| P2PKH (legacy) | `1` | 26 to 34 | Base58Check |
| P2SH (script hash) | `3` | 34 | Base58Check |
| P2WPKH (native SegWit) | `bc1q` | 42 | Bech32 |
| P2TR (Taproot) | `bc1p` | 62 | Bech32m |
Two encodings matter here.
Base58Check writes bytes using 58 characters. It leaves out 0, O, I and l, because those are easy to confuse. The decoded bytes are a version byte, a 20-byte hash of the public key (or script), and a 4-byte checksum. The checksum is the first four bytes of SHA-256 applied twice to the version byte and hash. A wallet recomputes it and rejects the address if it does not match.
Bech32 (and its fix-up, Bech32m, used by Taproot) uses a 32-character lowercase alphabet. The characters 1, b, i and o are excluded. The 1 in bc1 is a separator between the human-readable prefix bc and the data. The checksum is a BCH error-detecting code. It is designed to detect any short run of wrong characters, and it also makes some errors easy to locate. Bech32 is case-insensitive, but you must not mix upper and lower case in one address.
Bitcoin testnet uses different prefixes (tb1 for bech32, and m, n or 2 for legacy forms). Test coins have no value, so sending real coins to a testnet address is not a normal mistake. The prefix still tells you which Bitcoin network an address was made for.
Ethereum and EVM address format
An Ethereum address is the last 20 bytes of the Keccak-256 hash of the public key, written as 0x followed by 40 hex digits. That is 42 characters in total.
The base format has no checksum. An address written all in lowercase is valid, and a single wrong digit gives a different valid-looking address.
EIP-55 adds an optional checksum using letter case. The wallet hashes the lowercase hex address with Keccak-256. For each letter in the address, it writes the letter in uppercase if the matching hex digit of the hash is 8 or higher, and in lowercase otherwise. Digits are unaffected. The result looks like 0x52908400098527886E0F7030069857D2E4169EE7. Wallets that verify EIP-55 will warn you if the mixed case does not fit the address.
Three practical consequences follow:
- A mixed-case address that fails the check probably contains a typo.
- An all-lowercase or all-uppercase address carries no checksum, so a wallet cannot detect typos in it.
- The case of letters does not change which account the address points to. The checksum is only a safety feature.
Ethereum, BNB Smart Chain, Polygon, Arbitrum, Base, Optimism and many other chains reuse this exact format. That reuse is the main subject of the "One address, many EVM networks" chapter.
Solana address format
A Solana address is the account's Ed25519 public key itself, with no hash and no checksum. The key is 32 bytes, written in base58. Depending on the bytes, the result is 32 to 44 characters, usually 43 or 44.
Because there is no checksum, a typo in a Solana address can still produce a string that looks fine. The base58 alphabet restriction is the only built-in format check. Your safety depends on copying the address exactly and comparing the start and end of it.
Other formats you will meet
Exchanges list many networks, so you will see other layouts:
- Tron addresses are Base58Check strings of 34 characters starting with
T. They are commonly used for USDT. - XRP addresses start with
rand also use a Base58-style encoding. Deposits often need a destination tag, covered in the "Memos and destination tags" chapter. - Bitcoin Cash, Litecoin and Dogecoin each have their own prefixes. Some of them are close to Bitcoin's legacy forms, and the next section explains why that matters.
What a format check can and cannot tell you
A format check rules networks out. It rarely leaves exactly one.
import re
def classify(address: str) -> list[str]:
"""Return the networks an address could plausibly belong to, judged by format only."""
candidates = []
if re.fullmatch(r"0x[0-9a-fA-F]{40}", address):
candidates.append("EVM-compatible (Ethereum, BNB Smart Chain, Polygon, Arbitrum, Base, ...)")
if address.startswith("bc1"):
candidates.append("Bitcoin mainnet (bech32)")
if re.fullmatch(r"[13][1-9A-HJ-NP-Za-km-z]{25,34}", address):
candidates.append("Bitcoin mainnet (legacy or P2SH)")
if re.fullmatch(r"[1-9A-HJ-NP-Za-km-z]{32,44}", address):
candidates.append("Solana (base58 public key)")
return candidates
print(classify("0x52908400098527886E0F7030069857D2E4169EE7"))For the 0x address, the function returns one entry, and that entry names a whole family of chains. Try it with Bitcoin's first-ever address, 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa. It is 34 characters of base58, so the function returns two candidates: Bitcoin legacy and Solana. Length and alphabet alone cannot separate them. Only the checksum can help, and Solana has none.
The same problem exists across networks that share an address format. Bitcoin Cash's legacy format is identical to Bitcoin's, and Litecoin has older forms that resemble Bitcoin's 3 addresses. In every one of these cases, an address that looks valid does not tell you which network will receive the funds.
Verifying a Base58Check checksum yourself
For legacy Bitcoin addresses, you can reproduce the wallet's check with the standard library only.
import hashlib
ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
def legacy_bitcoin_checksum_ok(address: str) -> bool:
"""Check the Base58Check checksum of a 25-byte legacy Bitcoin address."""
try:
number = 0
for ch in address:
number = number * 58 + ALPHABET.index(ch)
raw = number.to_bytes(25, "big")
except (ValueError, OverflowError):
return False
payload, checksum = raw[:-4], raw[-4:]
digest = hashlib.sha256(hashlib.sha256(payload).digest()).digest()
return digest[:4] == checksum
print(legacy_bitcoin_checksum_ok("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa")) # True
print(legacy_bitcoin_checksum_ok("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNb")) # FalseThe second call changes the last character. The checksum fails, and a wallet would refuse the address. A random typo slips past this check only about once in 4 billion tries, because the checksum is 32 bits long.
The function proves only that the string is a well-formed legacy address. It does not prove that anyone holds the key, and it does not prove which Bitcoin-like network the address was intended for.
Common errors when reading addresses
- Treating
0xas "Ethereum". The prefix means EVM format. The same string is receivable on dozens of networks. - Assuming a checksum exists. Solana and all-lowercase Ethereum addresses have none, so typos go undetected.
- Comparing only the first characters. Look-alike addresses can match at the start. The poisoning chapter explains how attackers exploit this, so compare the start and the end, or better, the whole string.
- Retyping an address. Copy and paste, then check. Retyping adds typo risk, and a wallet cannot catch typos in checksum-free formats.
- Mixing up case rules. Changing the case of an EIP-55 address does not change who owns it, but it removes the checksum protection and may trigger wallet warnings. Changing the case of a Base58 address changes the encoded number, which makes it a different address, or an invalid one.
- Trusting format when the network is listed separately. On an exchange, the network dropdown, not the address, determines where the withdrawal goes. The "Choosing the right network" chapter covers this.
Exercises
Exercise
An address is 0x followed by 40 hex digits, written in mixed case. A wallet accepts it. List two things you now know and one thing you do not know.
Show answer
You know it is in EVM address format, and, if the wallet verifies EIP-55, that the mixed case matches its checksum, so a typo is unlikely. You do not know which EVM network the recipient expects the funds on, because Ethereum, BNB Smart Chain, Polygon, Arbitrum, Base and others all accept the same string.
Exercise
A 44-character base58 string with no prefix is pasted into a send form. Why can't a format check alone tell you whether it is a Solana address?
Show answer
Solana addresses are plain base58-encoded 32-byte public keys with no checksum or fixed prefix. Many other base58 strings of similar length would pass the same alphabet and length check, so format alone cannot confirm the network. You must confirm the network from the recipient's instructions.