Sub topic 4
Networks and chains: choosing the right one
This chapter assumes you know what a blockchain is, that you have met private keys and addresses in the earlier chapters, and that you can read short JavaScript snippets. By the end you should be able to confirm which network and which asset a transfer uses before you send anything.
What a network is
A blockchain network is a set of nodes that follow the same rules and keep the same ledger. Two networks can run the same software and use the same address format, yet their ledgers are completely separate. A balance on one network does not exist on another.
The words "network" and "chain" are often used as synonyms. In this tutorial, "chain" means the ledger itself, and "network" means the live set of nodes serving it. Wallets usually show a single label, such as "Ethereum Mainnet", for both.
Funds do not live inside your wallet app. They are entries on a chain, and your key authorizes changes to those entries. Choosing a network therefore means choosing which ledger records the transfer.
Mainnet, testnet and layer 2
There are three kinds of networks you will meet.
- Mainnet is the production network. Its coins have real market value, and mistakes cost real money.
- Testnet is a parallel network for practice. Its coins are free from "faucets" (websites that hand out small amounts) and have no market value. Examples include Sepolia for Ethereum.
- Layer 2 (L2) is a separate network built on top of another chain, called its layer 1. It batches transactions and posts proof of them to the layer 1 chain. Examples include Arbitrum, Optimism and Base. Fees are usually lower than on layer 1.
An L2 is its own network with its own balances. Sending coins "to an L2" requires a bridge or an exchange withdrawal that targets that L2. A plain transfer on layer 1 does not move your funds there.
Why the same address works on many networks
Many chains share one address format. Ethereum, Polygon, Arbitrum, Base and BNB Smart Chain all use 20-byte hexadecimal addresses beginning with 0x. They are called EVM-compatible, meaning they run the Ethereum Virtual Machine, so the same private key produces the same address on every one of them.
This is convenient, and it is also the most common source of mistakes. An address carries no network tag. If you paste an 0x address into a withdrawal form and select the wrong network, the transfer is valid on the network you picked. The funds arrive at that address on that chain, and you see nothing on the chain you expected.
Other chains use different formats, which gives you a partial safety check.
| Network family | Typical address look | Example prefix |
|---|---|---|
| EVM chains | 42 characters, hex | `0x...` |
| Bitcoin | Base58 or Bech32 | `1...`, `3...`, `bc1...` |
| Solana | Base58, 32 to 44 characters | no fixed prefix |
| Tron | Base58, 34 characters | `T...` |
A Bitcoin address pasted into an Ethereum form will be rejected. An 0x address on the wrong EVM chain will not.
Chain ID and network settings
Every EVM network has a numeric chain ID. It is part of what your wallet signs, which prevents a signed transaction from being replayed on a different chain. The wallet also needs an RPC URL, the web endpoint of a node it talks to.
| Network | Chain ID | Native coin |
|---|---|---|
| Ethereum Mainnet | 1 | ETH |
| Sepolia (testnet) | 11155111 | Sepolia ETH |
| Polygon PoS | 137 | POL |
| BNB Smart Chain | 56 | BNB |
| Arbitrum One | 42161 | ETH |
| Optimism | 10 | ETH |
| Base | 8453 | ETH |
Notice that several networks use ETH as the native coin, but each holds its own separate ETH balance. The coin has the same name on Arbitrum and on Ethereum Mainnet, yet they are different ledger entries.
You can check which network your code is talking to. This script asks the node for its chain ID and refuses to continue if it is not the one you intended.
import { JsonRpcProvider } from "ethers";
const EXPECTED_CHAIN_ID = 11155111n; // Sepolia
const provider = new JsonRpcProvider(process.env.RPC_URL);
const network = await provider.getNetwork();
console.log("Connected to chain ID:", network.chainId.toString());
if (network.chainId !== EXPECTED_CHAIN_ID) {
throw new Error(
`Wrong network: expected ${EXPECTED_CHAIN_ID}, got ${network.chainId}`
);
}
console.log("Network check passed");In ethers v6, chainId is a bigint, which is why the constant ends in n. Comparing it to a plain number with !== would always report a mismatch.
Gas is paid in the network's native coin
Each network charges fees in its own native coin. To send anything on Base, you need ETH on Base. To send on Polygon, you need POL on Polygon. A wallet holding tokens but no native coin on that network cannot move them. Later chapters cover fees in detail. For now, the network choice decides which coin you must hold for fees.
Checking the network before you send
A short routine prevents most network errors.
- Decide the network first. Ask the recipient, or read the service's deposit page, for the exact network name. "USDC" alone is not enough, because USDC exists on many networks.
- Match the name, not just the symbol. Exchanges list networks such as "ERC-20", "Arbitrum One" or "BEP-20". Choose the one the receiver supports.
- Check the wallet's active network. Wallet apps show a network selector at the top of the send screen. Confirm it before entering an amount.
- Check that you hold fee coin on that network.
- Send a small test amount if the value is large, and confirm it arrives before sending the rest.
- Verify on a block explorer. Each network has its own explorer, such as Etherscan for Ethereum or Basescan for Base. Search the transaction hash or the address on the explorer for the network you used.
Recovering from a wrong-network transfer
The outcome depends on who controls the destination address.
- You own the key. The same private key controls the same address on every EVM chain. Add the network you sent on to your wallet, switch to it, and the funds will appear. You can then bridge or send them onward.
- An exchange or service owns the key. Contact support with the transaction hash, the network used and the intended network. Recovery is a manual courtesy, not a guarantee.
- The chains are not compatible. If you sent to an address format the destination chain does not control, such as an EVM address on a non-EVM chain, funds can be unrecoverable.
- A smart contract wallet. Contract addresses can differ between networks. An address that is a wallet on Ethereum may be an empty address, or controlled by someone else, on another chain. Never assume a contract address is controlled by the same owner everywhere.
Same asset name, different assets
The network also determines which token you hold. A token is a contract on one specific chain, so "USDC on Ethereum" and "USDC on Base" are two separate contracts with separate balances. Some tokens come in a "bridged" version and a "native" version on the same L2, with different contract addresses, and many apps treat only one of them as valid.
Always confirm the token's contract address on the correct network. Copy it from the project's official site or from a trusted explorer page. Searching a token by symbol in a wallet can lead to counterfeit tokens with the same name.
The next diagram shows the decision flow before a transfer.
Common errors
- Wrong network in a withdrawal form. Match the network the receiver supports.
- Looking at the wrong explorer. A transaction on Base will not show on Etherscan. If a hash is "not found", you are probably on the wrong explorer.
- Mixing mainnet and testnet. Testnet coins have no value, and mainnet coins sent to a testnet address do not exist there. Keep separate wallet profiles or clear labels.
- Untrusted RPC URLs. A malicious RPC endpoint can show false balances or false transaction results. Use endpoints from the network's documentation or a provider you trust.
- Copying chain settings from random pages. Fake "add network" buttons can point your wallet at a hostile node. Cross-check the chain ID against a trusted registry.
Exercise
You withdraw USDC from an exchange to your own 0x address, choosing "Base" as the network. Your wallet is set to Ethereum Mainnet and shows a zero balance. What happened, and what do you do?
Show answer
Nothing is lost. The USDC is on Base at your address, and your wallet is only looking at Ethereum Mainnet, which has a separate ledger. Switch the wallet to Base (chain ID 8453), and the balance appears. You will also need ETH on Base to pay for any later transfer.
Exercise
A script prints "Wrong network: expected 11155111, got 1". What does this tell you, and why is a check like this useful before sending?
Show answer
The RPC URL points to Ethereum Mainnet (chain ID 1) rather than Sepolia, so a send would move real funds instead of test coins. Checking the chain ID before signing stops the script before any transaction is created.