0
0
Blockchain / Solidityprogramming~10 mins

Why Ethereum enables programmable money in Blockchain / Solidity - Test Your Understanding

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

Complete the code to define a simple Ethereum smart contract that stores a number.

Blockchain / Solidity
contract SimpleStorage {
    uint256 public [1];
}
Drag options to blanks, or click blank then click option'
AstoredData
Bvalue
Cnumber
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using names that are too generic or reserved keywords.
2fill in blank
medium

Complete the code to create a function that sets the stored number.

Blockchain / Solidity
function set(uint256 x) public {
    [1] = x;
}
Drag options to blanks, or click blank then click option'
AstoredData
Bdata
Cvalue
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that is not declared in the contract.
3fill in blank
hard

Fix the error in the function to return the stored number correctly.

Blockchain / Solidity
function get() public view returns (uint256) {
    return [1];
}
Drag options to blanks, or click blank then click option'
Avalue
BstoredData
Cnumber
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Returning a variable that is not declared or misspelled.
4fill in blank
hard

Fill both blanks to create a mapping that stores balances and a function to update it.

Blockchain / Solidity
mapping(address => uint256) public [1];

function updateBalance(address user, uint256 amount) public {
    [2][user] = amount;
}
Drag options to blanks, or click blank then click option'
Abalances
Baccounts
Dledger
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for the mapping and in the function.
5fill in blank
hard

Fill all three blanks to create a function that transfers tokens between users.

Blockchain / Solidity
function transfer(address to, uint256 amount) public {
    require([1][msg.sender] >= amount, "Insufficient balance");
    [2][msg.sender] -= amount;
    [3][to] += amount;
}
Drag options to blanks, or click blank then click option'
Abalances
Baccounts
Dledger
Attempts:
3 left
💡 Hint
Common Mistakes
Using different mapping names causing errors.