0
0
Blockchain / Solidityprogramming~10 mins

Ethereum networks (mainnet, testnet) in Blockchain / Solidity - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Ethereum networks (mainnet, testnet)
Start: Choose Network
Use Testnet
Yes
Use Mainnet
Deploy/Interact with Contracts
Transactions Confirmed
End
You pick a network: mainnet for real money or testnet for practice. Then you deploy or interact with contracts and wait for confirmations.
Execution Sample
Blockchain / Solidity
network = "testnet"
if network == "mainnet":
    print("Using real Ethereum network")
else:
    print("Using test network for practice")
This code chooses between mainnet and testnet and prints which network is used.
Execution Table
StepVariable 'network'Condition 'network == "mainnet"'Branch TakenOutput
1"testnet"FalseElse branch"Using test network for practice"
2---Program ends
💡 Condition is false because network is 'testnet', so else branch runs and program ends.
Variable Tracker
VariableStartAfter Step 1Final
networkundefined"testnet""testnet"
Key Moments - 2 Insights
Why does the program print 'Using test network for practice' instead of 'Using real Ethereum network'?
Because the variable 'network' is set to 'testnet', the condition 'network == "mainnet"' is false (see execution_table step 1), so the else branch runs.
What is the difference between mainnet and testnet?
Mainnet is the real Ethereum network where real money is used. Testnet is a practice network with fake money to test code safely.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the value of 'network' at Step 1?
A"testnet"
Bundefined
C"mainnet"
D"unknown"
💡 Hint
Check the 'Variable network' column in execution_table at Step 1.
At which step does the program decide to run the else branch?
AStep 2
BProgram never runs else branch
CStep 1
DBefore Step 1
💡 Hint
Look at the 'Branch Taken' column in execution_table.
If 'network' was set to 'mainnet', what would the output be?
A"Using test network for practice"
B"Using real Ethereum network"
CNo output
DError
💡 Hint
Think about the condition 'network == "mainnet"' and which branch runs.
Concept Snapshot
Ethereum networks:
- Mainnet: real Ethereum, real money
- Testnet: practice network, fake money
- Use 'if' to choose network
- Deploy/test contracts safely on testnet
- Switch to mainnet for real transactions
Full Transcript
This visual trace shows how a program chooses between Ethereum mainnet and testnet. The variable 'network' is set to 'testnet'. The program checks if 'network' equals 'mainnet'. Since it does not, it runs the else branch and prints 'Using test network for practice'. Mainnet is the real Ethereum network with real money. Testnet is a safe practice network with fake money. This helps developers test their code without risking real funds. The execution table tracks each step, showing variable values, conditions, branches, and output. The variable tracker shows how 'network' stays 'testnet'. Key moments clarify why the else branch runs and the difference between mainnet and testnet. The quiz asks about variable values and program flow to reinforce understanding.