Challenge - 5 Problems
Abstract Contract Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of an abstract contract inheritance
What is the output when deploying and calling
getValue() from the ConcreteContract below?Blockchain / Solidity
abstract contract AbstractContract {
function getValue() public virtual returns (string memory);
}
contract ConcreteContract is AbstractContract {
function getValue() public override returns (string memory) {
return "Hello from Concrete!";
}
}Attempts:
2 left
💡 Hint
Remember that abstract contracts require derived contracts to implement abstract functions.
✗ Incorrect
The abstract contract declares getValue as virtual without implementation. ConcreteContract overrides and implements getValue, so calling it returns the implemented string.
🧠 Conceptual
intermediate1:30remaining
Purpose of abstract contracts
What is the main purpose of using abstract contracts in blockchain smart contract development?
Attempts:
2 left
💡 Hint
Think about contracts that act like blueprints.
✗ Incorrect
Abstract contracts serve as blueprints with function signatures but no implementations, requiring child contracts to provide the actual code.
🔧 Debug
advanced2:00remaining
Identify the error in abstract contract implementation
What error will the Solidity compiler produce for the following code?
Blockchain / Solidity
abstract contract Base {
function foo() public virtual returns (string memory);
}
contract Derived is Base {
// Missing override of foo
}Attempts:
2 left
💡 Hint
Check if Derived implements all abstract functions.
✗ Incorrect
Derived inherits an abstract function foo but does not implement it or declare itself abstract, causing a compiler error.
📝 Syntax
advanced1:30remaining
Correct syntax for abstract function declaration
Which option shows the correct syntax to declare an abstract function in Solidity?
Attempts:
2 left
💡 Hint
Abstract functions have no body and use the virtual keyword.
✗ Incorrect
In Solidity, abstract functions are declared with virtual and no body (semicolon at end). The other options are invalid syntax.
🚀 Application
expert2:30remaining
Number of items in a contract inheritance chain
Given the following contracts, how many contracts must be deployed to use
FinalContract and call getData() successfully?Blockchain / Solidity
abstract contract A {
function getData() public virtual returns (string memory);
}
abstract contract B is A {
function getData() public virtual override returns (string memory);
}
contract FinalContract is B {
function getData() public override returns (string memory) {
return "Data from Final";
}
}Attempts:
2 left
💡 Hint
Only concrete contracts can be deployed.
✗ Incorrect
Only FinalContract is concrete and deployable. Abstract contracts A and B cannot be deployed. FinalContract implements all abstract functions.