0
0
Blockchain / Solidityprogramming~20 mins

Ethereum networks (mainnet, testnet) in Blockchain / Solidity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Ethereum Network Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference between Ethereum Mainnet and Testnet

Which statement correctly describes the difference between Ethereum Mainnet and Testnet?

AMainnet is the live Ethereum network where real transactions occur; Testnet is a separate network used for testing with no real value.
BMainnet is used only for testing smart contracts; Testnet is the live network for real transactions.
CMainnet and Testnet are identical networks but use different cryptocurrencies.
DTestnet is the main network for Ethereum, while Mainnet is deprecated.
Attempts:
2 left
💡 Hint

Think about where real money is involved versus where developers try out code safely.

Predict Output
intermediate
2:00remaining
Identify the network from chain ID

What is the output of the following code snippet that checks the Ethereum network by chain ID?

Blockchain / Solidity
chain_id = 5
network = "Mainnet" if chain_id == 1 else "Goerli Testnet" if chain_id == 5 else "Unknown"
print(network)
AUnknown
BMainnet
CGoerli Testnet
DError
Attempts:
2 left
💡 Hint

Chain ID 1 is Mainnet; 5 is a popular testnet.

Predict Output
advanced
2:00remaining
Output of transaction cost calculation on testnet

What is the output of this Python code that calculates the total cost of a transaction on a testnet?

Blockchain / Solidity
gas_price_gwei = 20
gas_used = 21000
total_cost_eth = (gas_price_gwei * gas_used) / 1_000_000_000
print(f"Total cost in ETH: {total_cost_eth}")
ATotal cost in ETH: 0.42
BTotal cost in ETH: 0.00042
CTotal cost in ETH: 420000000
DTotal cost in ETH: 0.0000021
Attempts:
2 left
💡 Hint

Remember 1 Gwei = 10⁻⁹ ETH. Multiply gas price by gas used, then convert.

🔧 Debug
advanced
2:00remaining
Identify the error in network selection code

What error does the following code raise when trying to select the Ethereum network?

def select_network(chain_id):
    if chain_id == 1:
        return "Mainnet"
    elif chain_id == 3:
        return "Ropsten Testnet"
    else:
        return "Unknown"

print(select_network(1))
ATypeError because chain_id is not an integer
BNo error, prints 'Mainnet'
CNameError because select_network is not defined
DSyntaxError due to assignment in if condition
Attempts:
2 left
💡 Hint

Check the if statement condition syntax carefully.

🚀 Application
expert
2:00remaining
Determine the number of unique Ethereum testnets in a list

Given the list of network names below, how many unique Ethereum testnets are included?

networks = ["Mainnet", "Goerli", "Ropsten", "Kovan", "Mainnet", "Goerli", "Rinkeby"]
A4
B3
C5
D6
Attempts:
2 left
💡 Hint

Count only testnets, ignore Mainnet duplicates.