0
0
Blockchain / Solidityprogramming~15 mins

If-else statements in Blockchain / Solidity - Mini Project: Build & Apply

Choose your learning style9 modes available
Simple Blockchain Transaction Approval
📖 Scenario: You are building a simple blockchain transaction approval system. Each transaction has an amount, and you want to approve or reject it based on a limit.
🎯 Goal: Build a program that checks if a transaction amount is within the allowed limit using if-else statements and prints whether the transaction is approved or rejected.
📋 What You'll Learn
Create a variable called transaction_amount with the value 150.
Create a variable called approval_limit with the value 200.
Use an if-else statement to check if transaction_amount is less than or equal to approval_limit.
Print "Transaction approved" if the condition is true, otherwise print "Transaction rejected".
💡 Why This Matters
🌍 Real World
Blockchain systems often need to approve or reject transactions based on rules like limits or balances.
💼 Career
Understanding if-else statements is essential for writing smart contracts and blockchain transaction logic.
Progress0 / 4 steps
1
Set the transaction amount
Create a variable called transaction_amount and set it to 150.
Blockchain / Solidity
Need a hint?

Use the equals sign = to assign the value 150 to transaction_amount.

2
Set the approval limit
Create a variable called approval_limit and set it to 200.
Blockchain / Solidity
Need a hint?

Use the equals sign = to assign the value 200 to approval_limit.

3
Check if transaction is within limit
Use an if-else statement to check if transaction_amount is less than or equal to approval_limit. Use the variables transaction_amount and approval_limit exactly.
Blockchain / Solidity
Need a hint?

Use if transaction_amount <= approval_limit: to start the condition. Use else: for the other case.

4
Print the result
Print the variable result to show if the transaction is approved or rejected.
Blockchain / Solidity
Need a hint?

Use print(result) to show the message.