0
0
Blockchain / Solidityprogramming~15 mins

Rollups (Optimistic vs ZK) in Blockchain / Solidity - Hands-On Comparison

Choose your learning style9 modes available
Understanding Rollups: Optimistic vs ZK
📖 Scenario: You are learning about blockchain scaling solutions called rollups. Rollups help process many transactions off the main blockchain to make it faster and cheaper. There are two main types: Optimistic Rollups and Zero-Knowledge (ZK) Rollups.In this project, you will create a simple program to compare how many transactions each rollup type can handle and decide which one is better for a given situation.
🎯 Goal: Build a Python program that stores transaction data for Optimistic and ZK rollups, sets a minimum transaction threshold, filters rollups that meet this threshold, and prints the filtered results.
📋 What You'll Learn
Create a dictionary with exact rollup names and their transaction speeds
Add a threshold variable to filter rollups
Use a dictionary comprehension to select rollups meeting the threshold
Print the filtered rollups clearly
💡 Why This Matters
🌍 Real World
Rollups are important in blockchain to speed up transactions and reduce costs. Understanding how to compare their speeds helps developers choose the right solution.
💼 Career
Blockchain developers and engineers often analyze rollup performance to optimize decentralized applications and improve user experience.
Progress0 / 4 steps
1
Create the rollup transaction speeds dictionary
Create a dictionary called rollup_speeds with these exact entries: 'Optimistic': 200, 'ZK': 1500, 'Other': 100
Blockchain / Solidity
Need a hint?

Use curly braces {} to create a dictionary with keys and values separated by colons.

2
Set the minimum transaction speed threshold
Create a variable called min_speed and set it to 300 to filter rollups with speeds at least this value
Blockchain / Solidity
Need a hint?

Just assign the number 300 to the variable min_speed.

3
Filter rollups using dictionary comprehension
Use a dictionary comprehension to create a new dictionary called fast_rollups that includes only rollups from rollup_speeds with speeds greater than or equal to min_speed. Use for name, speed in rollup_speeds.items() in your comprehension.
Blockchain / Solidity
Need a hint?

Use dictionary comprehension syntax: {key: value for key, value in dict.items() if condition}

4
Print the filtered rollups
Write a print statement to display the fast_rollups dictionary
Blockchain / Solidity
Need a hint?

Use print(fast_rollups) to show the filtered dictionary.