Complete the code to declare a contract named MyContract.
contract [1] {
}The contract name must start with a capital letter and match the declaration. 'MyContract' is the correct name.
Complete the code to declare a public state variable of type uint named count.
contract Counter {
[1] public count;
}int or wrong types like string or bool.In Solidity, uint is an unsigned integer type commonly used for counters.
Fix the error in the function declaration to make it a public function named increment.
contract Counter {
uint public count;
function [1]() public {
count += 1;
}
}Function names in Solidity are case-sensitive. The function should be named exactly 'increment' as specified.
Complete the code to declare a constructor that sets count to zero.
contract Counter {
uint public count;
constructor() { {
count {BLANK_2}} 0;
}
}The constructor body starts with '{' and the assignment uses '=' to set count to zero.
Fill both blanks to complete a function that returns the current count.
contract Counter {
uint public count;
function getCount() public view returns({BLANK_1}}) { {
return {{BLANK_2}};
}
}The function returns a uint type, the body starts with '{', and it returns the variable count.