0
0
Blockchain / Solidityprogramming~30 mins

Distributed ledger concept in Blockchain / Solidity - Mini Project: Build & Apply

Choose your learning style9 modes available
Distributed Ledger Concept
📖 Scenario: Imagine you want to keep a shared list of transactions that multiple friends can see and agree on. This shared list is called a distributed ledger. Each friend adds their transactions, and everyone can check the list to make sure it is correct.
🎯 Goal: You will build a simple distributed ledger using a list of dictionaries. Each dictionary will represent a transaction with a sender, receiver, and amount. You will add transactions, set a minimum amount to record, and then print the filtered transactions.
📋 What You'll Learn
Create a list called ledger with 3 specific transactions
Create a variable called min_amount set to 50
Use a list comprehension to create filtered_ledger with transactions having amount greater than or equal to min_amount
Print the filtered_ledger list
💡 Why This Matters
🌍 Real World
Distributed ledgers are used in blockchain to keep a shared, secure record of transactions that many people can trust without a central authority.
💼 Career
Understanding how to manage and filter transaction data is important for blockchain developers, data analysts, and software engineers working with decentralized systems.
Progress0 / 4 steps
1
Create the initial ledger with transactions
Create a list called ledger with these exact transactions as dictionaries:
{'sender': 'Alice', 'receiver': 'Bob', 'amount': 100}, {'sender': 'Bob', 'receiver': 'Charlie', 'amount': 30}, and {'sender': 'Charlie', 'receiver': 'Alice', 'amount': 70}.
Blockchain / Solidity
Need a hint?

Use a list with three dictionaries. Each dictionary has keys 'sender', 'receiver', and 'amount'.

2
Set the minimum amount to record
Create a variable called min_amount and set it to 50.
Blockchain / Solidity
Need a hint?

Just create a variable named min_amount and assign the number 50.

3
Filter transactions by minimum amount
Use a list comprehension to create a new list called filtered_ledger that includes only transactions from ledger where the amount is greater than or equal to min_amount.
Blockchain / Solidity
Need a hint?

Use a list comprehension with for tx in ledger and an if condition checking tx['amount'] >= min_amount.

4
Print the filtered ledger
Write a print statement to display the filtered_ledger list.
Blockchain / Solidity
Need a hint?

Use print(filtered_ledger) to show the filtered transactions.