0
0
Blockchain / Solidityprogramming~10 mins

ERC-20 implementation 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 the total supply variable in an ERC-20 contract.

Blockchain / Solidity
uint256 public [1];
Drag options to blanks, or click blank then click option'
Aamount
Bbalance
Cowner
DtotalSupply
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names like balance or owner instead of totalSupply.
2fill in blank
medium

Complete the code to define the balance mapping for token holders.

Blockchain / Solidity
mapping(address => [1]) private balances;
Drag options to blanks, or click blank then click option'
Auint256
Bstring
Cbool
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Using bool or address instead of uint256.
3fill in blank
hard

Fix the error in the transfer function signature to match ERC-20 standard.

Blockchain / Solidity
function transfer(address [1], uint256 amount) public returns (bool) {
Drag options to blanks, or click blank then click option'
Afrom
Brecipient
Cto
Dspender
Attempts:
3 left
💡 Hint
Common Mistakes
Using from or spender instead of to.
4fill in blank
hard

Fill 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'
Aaddress
Buint256
Dbool
Attempts:
3 left
💡 Hint
Common Mistakes
Using uint256 or bool as keys instead of address.
5fill in blank
hard

Fill all three blanks to complete the transfer function body that updates balances and emits Transfer event.

Blockchain / Solidity
require(balances[msg.sender] >= [1], "Insufficient balance");
balances[msg.sender] -= [2];
balances[[3]] += amount;
emit Transfer(msg.sender, [3], amount);
return true;
Drag options to blanks, or click blank then click option'
Aamount
Bto
Dfrom
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names like from or mixing up amount and to.