Challenge - 5 Problems
Interface Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a Solidity Interface Call
Consider the following Solidity interface and contract. What will be the output when
getValue() is called on MyContract?Blockchain / Solidity
pragma solidity ^0.8.0; interface IValue { function getValue() external view returns (uint); } contract MyContract is IValue { function getValue() external pure override returns (uint) { return 42; } }
Attempts:
2 left
💡 Hint
The contract implements the interface function and returns a fixed number.
✗ Incorrect
The contract
MyContract implements the interface IValue and overrides getValue() to return 42. Calling getValue() returns 42.🧠 Conceptual
intermediate1:30remaining
Purpose of Interfaces in Smart Contracts
What is the main purpose of using interfaces in blockchain smart contracts?
Attempts:
2 left
💡 Hint
Think about how contracts communicate with each other.
✗ Incorrect
Interfaces declare function signatures without implementation. They allow contracts to interact by specifying how to call external contracts without needing their full code.
🔧 Debug
advanced2:00remaining
Identify the Error in Interface Implementation
What error will this Solidity contract produce?
Blockchain / Solidity
pragma solidity ^0.8.0; interface ICalc { function add(uint a, uint b) external returns (uint); } contract Calculator is ICalc { function add(uint a, uint b) public pure override returns (uint) { return a + b; } }
Attempts:
2 left
💡 Hint
Check the function signature and keywords for interface implementation.
✗ Incorrect
The contract function implementing the interface must include the 'override' keyword. Missing it causes a compiler error.
📝 Syntax
advanced1:30remaining
Correct Interface Syntax in Solidity
Which option shows the correct syntax for declaring an interface with a function
transfer that takes an address and uint and returns a bool?Attempts:
2 left
💡 Hint
Interfaces declare function signatures without bodies and use 'external' visibility.
✗ Incorrect
Option A correctly declares the function signature with 'external' visibility and return type, without a function body.
🚀 Application
expert2:30remaining
Number of Functions in a Contract Implementing Multiple Interfaces
Given these interfaces and contract, how many functions must
MultiContract implement?Blockchain / Solidity
pragma solidity ^0.8.0; interface IA { function foo() external; function bar() external; } interface IB { function bar() external; function baz() external; } contract MultiContract is IA, IB { // Implementations here }
Attempts:
2 left
💡 Hint
Count unique function signatures from both interfaces.
✗ Incorrect
Functions foo, bar, and baz must be implemented. 'bar' appears in both interfaces but only needs one implementation. Total is 3.