Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare the transfer function signature.
Blockchain / Solidity
function transfer(address [1], uint256 amount) public returns (bool); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'from' instead of 'to' for the recipient address.
✗ Incorrect
The transfer function sends tokens to the to address.
2fill in blank
mediumComplete the code to approve a spender to spend tokens.
Blockchain / Solidity
function approve(address [1], uint256 amount) public returns (bool); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'owner' instead of 'spender'.
✗ Incorrect
The approve function allows the spender to spend tokens on behalf of the owner.
3fill in blank
hardFix the error in the transferFrom function parameter name.
Blockchain / Solidity
function transferFrom(address [1], address to, uint256 amount) public returns (bool); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'to' or 'spender' instead of 'from'.
✗ Incorrect
The transferFrom function moves tokens from the from address to to.
4fill in blank
hardFill both blanks to complete the allowance mapping declaration.
Blockchain / Solidity
mapping([1] => mapping([2] => uint256)) private _allowances;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using uint256 or bool as keys instead of address.
✗ Incorrect
The _allowances mapping tracks how many tokens an owner allows a spender to use. Both keys are addresses.
5fill in blank
hardFill all three blanks to complete the transferFrom function body snippet.
Blockchain / Solidity
require(_allowances[[1]][[2]] >= amount, "Allowance too low"); _allowances[[3]][[2]] -= amount;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up 'to' and 'spender' keys.
✗ Incorrect
The allowance is checked and reduced for the from owner and spender. The from address's allowance is decreased.