BC5: Ethereum in practice: accounts, transactions, gas and networks

Lesson 4 of 5 · reading 15–25 minutes; practice and project time is on the module page

Networks: main, test, local and layer 2

🎯You'll be able to

Choose the right network for each stage of work and connect to it safely.

🏠The everyday picture

A driving school car park, the quiet roads near it, and the highway: you practise in each before the next.

📘What it really is

📝A worked example

Input: SakhiKosh's app moves from practice to a public test network.

Steps:

  1. Practice: chain ID 31337 at http://127.0.0.1:8545, with the test accounts npm run chain prints.
  2. Public test network: a new RPC address, chain ID 11155111, a fresh account funded from a faucet, and its key in .env.
  3. The app refuses to send if the chain ID doesn't match the one configured.

Expected output: a safe path from practice to a public test network, with no main network step in the course.

🌍Where it's used

📝Case scenario

A developer's script was meant for a test network, but their RPC setting still pointed at the main network from another project. The script deployed a contract and paid real fees. A chain ID check at the start of the script would have stopped it.

🖱️Try it

Write the chain IDs of the practice network, Sepolia and Ethereum mainnet. Success: 31337, 11155111 and 1.

⚠️Common mistakes

🛠️For your project

Project 3's test 1 checks the app refuses to carry on when the chain ID isn't the expected one.

✅Quick check

Why check the chain ID before sending?

Show the answer

So a script meant for one network doesn't send on another, such as the main network.

What is a layer 2 network?

Show the answer

A network that runs transactions off the main chain and posts data and proofs back to it, for lower fees.

← PreviousGas and fees
ProLearners Assist