Complete the code to make the function accessible from anywhere.
function greet() [1] returns (string memory) { return "Hello!"; }
The public visibility modifier allows the function to be called from anywhere, both inside and outside the contract.
Complete the code to make the variable accessible only within the contract and derived contracts.
uint256 [1] myNumber;The internal modifier restricts access to the contract itself and any contracts that inherit from it.
Fix the error in the function declaration to allow it to be called only from outside the contract.
function externalCall() [1] {
// function logic
}The external modifier means the function can only be called from outside the contract, not from inside.
Fill both blanks to create a private variable and a public function to access it.
uint256 [1] secretNumber; function getSecret() [2] view returns (uint256) { return secretNumber; }
The variable is private so it can't be accessed directly outside the contract. The function is public so anyone can call it to get the value.
Fill all three blanks to define an internal variable, a private function, and a public function that calls the private one.
uint256 [1] data; function calculate() [2] view returns (uint256) { return data * 2; } function getResult() [3] view returns (uint256) { return calculate(); }
The variable is internal so accessible inside the contract and children. The private function can only be called inside this contract. The public function allows anyone to call it and get the result.