0
0
Blockchain / Solidityprogramming~10 mins

Interfaces 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 an interface named IToken.

Blockchain / Solidity
interface [1] {
    function totalSupply() external view returns (uint256);
}
Drag options to blanks, or click blank then click option'
AToken
BInterfaceToken
CTokenInterface
DIToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using a name without the 'I' prefix for the interface.
2fill in blank
medium

Complete the code to declare a function in the interface that transfers tokens.

Blockchain / Solidity
function transfer(address to, uint256 amount) external [1];
Drag options to blanks, or click blank then click option'
Aview
Breturns (bool)
Cpure
Dpayable
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'view' or 'pure' for a function that changes state.
3fill in blank
hard

Fix the error in the interface function declaration for balanceOf.

Blockchain / Solidity
function balanceOf(address owner) external [1] returns (uint256);
Drag options to blanks, or click blank then click option'
Aview
Bpayable
Cpure
Dexternal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'payable' or 'pure' incorrectly in the function declaration.
4fill in blank
hard

Fill both blanks to declare an interface with two functions: approve and allowance.

Blockchain / Solidity
interface IToken {
    function approve(address spender, uint256 amount) external [1];
    function allowance(address owner, address spender) external [2] returns (uint256);
}
Drag options to blanks, or click blank then click option'
Areturns (bool)
Bview
Cpure
Dpayable
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up 'view' and 'returns (bool)' in function declarations.
5fill in blank
hard

Fill all three blanks to declare an interface with functions: name, symbol, and decimals.

Blockchain / Solidity
interface IToken {
    function name() external [1] returns (string memory);
    function symbol() external [2] returns (string memory);
    function decimals() external [3] returns (uint8);
}
Drag options to blanks, or click blank then click option'
Aview
Bpure
Cpayable
Dreturns (string memory)
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pure' or 'payable' incorrectly for these read-only functions.