0
0
Blockchain / Solidityprogramming~10 mins

Timelock pattern 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 declare a public variable named 'delay' of type uint.

Blockchain / Solidity
uint public [1];
Drag options to blanks, or click blank then click option'
Alock
Btime
Cdelay
Dduration
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that does not describe the delay.
Forgetting to make the variable public.
2fill in blank
medium

Complete the function signature to set a new admin address.

Blockchain / Solidity
function [1](address newAdmin) external onlyAdmin { admin = newAdmin; }
Drag options to blanks, or click blank then click option'
AupdateAdmin
BsetAdmin
CchangeAdmin
DmodifyAdmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function name that is too vague or uncommon.
Not using a verb that clearly indicates setting a value.
3fill in blank
hard

Fix the error in the require statement to check if the current time is past the unlock time.

Blockchain / Solidity
require(block.timestamp [1] unlockTime, "Timelock not expired");
Drag options to blanks, or click blank then click option'
A==
B<
C<=
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>=' causing premature execution.
Using '==' which is too strict and may block valid calls.
4fill in blank
hard

Fill both blanks to create a mapping that stores queued transactions and a function to queue a transaction.

Blockchain / Solidity
mapping(bytes32 => bool) public [1];

function [2](bytes32 txHash) public onlyAdmin { queuedTransactions[txHash] = true; }
Drag options to blanks, or click blank then click option'
AqueuedTransactions
BpendingTx
CqueueTransaction
DaddTransaction
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent names between mapping and function.
Choosing vague names that do not describe their purpose.
5fill in blank
hard

Fill all three blanks to implement the executeTransaction function with checks for queued status, timelock, and deletion after execution.

Blockchain / Solidity
function [1](bytes32 txHash) public onlyAdmin {
    require(queuedTransactions[txHash], "Transaction not queued");
    require(block.timestamp [2] unlockTime, "Timelock not expired");
    queuedTransactions[txHash] = [3];
    // execute transaction logic here
}
Drag options to blanks, or click blank then click option'
AexecuteTransaction
B>=
Cfalse
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect comparison operators in the require statement.
Not marking the transaction as executed (false) after running.