0
0
Blockchain / Solidityprogramming~10 mins

Gas and transaction fees in Blockchain / Solidity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the gas limit for a transaction.

Blockchain / Solidity
transaction = {"to": recipient, "value": amount, "gas": [1]
Drag options to blanks, or click blank then click option'
A5000
B21000
C100000
D30000
Attempts:
3 left
💡 Hint
Common Mistakes
Using too low or too high gas limits causing transaction failure or waste.
2fill in blank
medium

Complete the code to calculate the total transaction fee.

Blockchain / Solidity
total_fee = gas_price * [1]
Drag options to blanks, or click blank then click option'
Avalue
Bnonce
Cblock_number
Dgas_limit
Attempts:
3 left
💡 Hint
Common Mistakes
Multiplying gas price by nonce or value instead of gas limit.
3fill in blank
hard

Fix the error in the code to set the gas price correctly.

Blockchain / Solidity
transaction['gasPrice'] = [1]
Drag options to blanks, or click blank then click option'
Agas_price
Bgasprice
CGasPrice
DgasPrice
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong case or misspelled variable names.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension for gas fees above a threshold.

Blockchain / Solidity
high_fees = {tx_id: tx['gasPrice'] * [1] for tx_id, tx in transactions.items() if tx['gasPrice'] [2] threshold}
Drag options to blanks, or click blank then click option'
Atx['gasLimit']
Btx['value']
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong keys or wrong comparison operators.
5fill in blank
hard

Fill all three blanks to create a filtered dictionary of transactions with fees above a limit.

Blockchain / Solidity
filtered = {tx['from']: tx['gasPrice'] * [1] for tx in tx_list if tx['gasPrice'] [2] min_price and tx['gasLimit'] [3] max_limit}
Drag options to blanks, or click blank then click option'
Atx['gasLimit']
B>
C<
Dtx['value']
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up comparison operators or using wrong keys.