Sub topic 3
Networks are separate ledgers
This chapter assumes you know that a wallet address comes from a public key, which comes from a private key. It also assumes you can read the common address formats from the earlier chapters. Here the focus shifts from the address to the ledger that records what the address owns.
What a network is
A blockchain network is a group of computers (nodes) that run the same software, follow the same rules, and agree on one shared record of transactions. That record is the ledger. Each network has its own:
- genesis block, the first block that every later block builds on
- consensus rules, which decide which new blocks are valid
- state, the current balance of every address plus any contract data
- native coin, which pays fees on that network
- set of nodes and validators or miners
Two networks can use the same software and the same address format and still be completely independent. Neither one reads, writes, or even knows about the other's ledger.
A balance is therefore not a property of an address. It is an entry in one specific ledger, stored under that address. The same string can have an entry in several ledgers, or in none.
Where the wallet fits
A wallet app does not hold coins. It holds keys, and it asks a node for information. When you pick a network in a wallet, you are choosing which node endpoint to query and which network to sign transactions for.
The network selector controls three things:
- Which node answers the question "what is the balance of this address?"
- Which network the signed transaction is sent to.
- For EVM networks, which chain ID gets included in the signature.
This explains a common false alarm. If you switch to the wrong network in your wallet, your balance shows as zero. The funds are not gone. You are reading a different ledger, and switching back shows them again.
Mainnet and testnet
Most networks come in at least two kinds:
- Mainnet is the production network. Its coins have market value, and transactions on it are real.
- Testnet is a parallel network for developers. Its coins are free from "faucets" and have no market value.
A testnet is a separate ledger, just like any other network. Sending test coins to a mainnet-only service, or real coins to a testnet address, goes wrong in the same way as any other cross-network send.
| Chain | Mainnet | Common test network |
|---|---|---|
| Bitcoin | Addresses start with `bc1`, `1` or `3` | Testnet and signet addresses start with `tb1`, `m`, `n` or `2` |
| Ethereum | Chain ID 1 | Sepolia, chain ID 11155111 |
| Solana | `mainnet-beta` cluster | `devnet` and `testnet` clusters |
Bitcoin testnets use their own address prefixes, so a wallet can often catch the mistake. Ethereum test networks use exactly the same 0x addresses as mainnet, so nothing in the address warns you.
How a network identifies itself
For Bitcoin and Solana, the network is usually encoded in the address prefix or in the wallet's configuration. For EVM networks, the key identifier is the chain ID. It is an integer that a node reports about itself and that a transaction signer includes when signing.
Including the chain ID in the signed data is called replay protection (EIP-155). A transaction signed for chain ID 137 is invalid on chain ID 1, so someone cannot copy a signed transaction from one network and rebroadcast it on another. Replay protection is a protocol-level guard. It does not stop you from choosing the wrong network in the first place.
You can ask a node which network it serves with the eth_chainId JSON-RPC call.
curl -s -X POST https://YOUR-RPC-ENDPOINT \
-H 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}'
# Ethereum mainnet answers: {"jsonrpc":"2.0","id":1,"result":"0x1"}
# Other chain IDs: Optimism 10, BNB Smart Chain 56, Polygon 137, Base 8453, Arbitrum One 42161The result is a hexadecimal string. 0x1 is 1, and 0x89 is 137, which is Polygon. Replace YOUR-RPC-ENDPOINT with a real endpoint before running it.
Checking a chain ID in code
The following Python script uses only the standard library. It asks an endpoint for its chain ID and compares it with the one you expected.
import json
import os
import urllib.request
KNOWN_CHAINS = {
1: "Ethereum mainnet",
10: "Optimism",
56: "BNB Smart Chain",
137: "Polygon PoS",
8453: "Base",
42161: "Arbitrum One",
11155111: "Sepolia (testnet)",
}
def get_chain_id(rpc_url: str) -> int:
payload = json.dumps(
{"jsonrpc": "2.0", "method": "eth_chainId", "params": [], "id": 1}
).encode()
request = urllib.request.Request(
rpc_url, data=payload, headers={"Content-Type": "application/json"}
)
with urllib.request.urlopen(request, timeout=10) as response:
body = json.load(response)
return int(body["result"], 16)
def check_endpoint(rpc_url: str, expected_chain_id: int) -> None:
actual = get_chain_id(rpc_url)
name = KNOWN_CHAINS.get(actual, "unknown network")
if actual != expected_chain_id:
raise SystemExit(
f"Mismatch: endpoint reports chain ID {actual} ({name}), "
f"expected {expected_chain_id} ({KNOWN_CHAINS.get(expected_chain_id, 'unknown')})"
)
print(f"OK: chain ID {actual} ({name})")
if __name__ == "__main__":
check_endpoint(os.environ["RPC_URL"], expected_chain_id=1)Run it with RPC_URL=https://YOUR-RPC-ENDPOINT python check_chain.py. If the endpoint belongs to another network, the script stops with a clear message instead of letting you continue.
Networks that look related but are separate
Several kinds of network are easy to confuse with each other. All of them are independent ledgers.
- Layer 2 networks such as Arbitrum, Optimism and Base are separate chains with their own chain IDs and their own state. They periodically post data to Ethereum, but a balance on one is not a balance on Ethereum. Moving value between them requires a deliberate transfer, covered in the chapter on bridges.
- Sidechains and independent EVM chains such as BNB Smart Chain and Polygon PoS have their own validators and their own security. They copy Ethereum's address and transaction format for compatibility, not its ledger.
- Forks share history up to the split and then diverge. Ethereum Classic (chain ID 61) and Bitcoin Cash both descend from an earlier chain, but each keeps its own ledger from the fork onward.
- Same name, different network. "USDT" and "ETH" are asset names, not network names. The same asset can exist on several networks, which the chapter on tokens covers.
The native coin is the quickest hint about the network. It is the coin that pays fees there. Several L2 networks use ETH for fees, though, so the fee coin alone does not identify a network. Use the chain ID.
| Network | Chain ID | Fee coin |
|---|---|---|
| Ethereum mainnet | 1 | ETH |
| Optimism | 10 | ETH |
| BNB Smart Chain | 56 | BNB |
| Polygon PoS | 137 | POL |
| Base | 8453 | ETH |
| Arbitrum One | 42161 | ETH |
Notice that four of these six use ETH for fees. A wallet showing "ETH" tells you nothing about which of those networks you are on.
Common errors with network selection
These are the usual failure modes at the network level, before tokens or exchanges come into play.
- Reading the wrong ledger. The wallet is on network A, your funds are on network B, and the balance shows zero. Nothing is lost. Switch networks.
- Sending on a network you did not intend. You pick network A when the recipient expects B. The transaction is valid on A, so it confirms there. The recipient sees nothing on B. Later chapters cover what this means for recovery.
- Adding a custom network with a wrong or malicious endpoint. A wallet lets you add any RPC URL. A hostile node can report fake balances or fake history. Take network details from the project's official documentation or from a registry you trust, and verify the chain ID that comes back.
- Confusing a testnet with mainnet. Test coins on a faucet are free and worthless. If your wallet shows a large balance on a test network, it carries no value.
- Trusting a name instead of an ID. Two networks can be given the same label in a wallet. The chain ID is the reliable identifier.
Checking the same address on two networks
The next script reads one address on two EVM networks. It uses the ethers library (version 6). The address string is identical in both queries, and each node answers from its own ledger.
import { JsonRpcProvider, formatEther } from "ethers";
const address = "0x52908400098527886E0F7030069857D2E4169EE7";
const endpoints = {
ethereum: "https://YOUR-ETHEREUM-RPC",
polygon: "https://YOUR-POLYGON-RPC",
};
for (const [name, url] of Object.entries(endpoints)) {
const provider = new JsonRpcProvider(url);
const balance = await provider.getBalance(address);
console.log(name, formatEther(balance));
}Save it as an ES module (for example balances.mjs) so the top-level await works. The two balances can differ because they come from two ledgers, and neither is wrong. The next chapter explains why this works at all: EVM networks share one address space.
Summary
- A network is an independent ledger with its own rules, history, state and nodes.
- A balance is an entry in one ledger, not a property of the address string.
- A wallet's network selector chooses which node to ask and which network to sign for.
- Mainnet and testnet are separate networks. Test coins have no value.
- On EVM networks, the chain ID is the reliable identifier. Layer 2s, sidechains and forks each have their own.
- Showing a zero balance on the wrong network is a display issue. Sending on the wrong network is a different problem, covered in later chapters.
Exercise
Your wallet is set to Polygon and shows 0 for an address that you know received 1 ETH-denominated payment on Arbitrum One. Are your funds lost, and what is the quickest reliable way to confirm which network a given RPC endpoint serves?
Show answer
The funds are not lost. Polygon and Arbitrum One are separate ledgers, so a Polygon node reports nothing for a balance that exists only on Arbitrum. Switch the wallet to Arbitrum One (chain ID 42161) and the balance appears. To confirm which network an endpoint serves, call eth_chainId and compare the result with the expected value: 0x89 (137) for Polygon, 0xa4b1 (42161) for Arbitrum One.
Exercise
An address on Base (chain ID 8453) and the same address on Optimism (chain ID 10) both pay fees in ETH. Why can't you tell the networks apart by the fee coin, and what identifier should you use instead?
Show answer
Both networks use ETH as the fee coin, so the coin symbol does not identify the network. Use the chain ID, which each node reports through eth_chainId and which is also included in transaction signatures. Base reports 8453 and Optimism reports 10.