Complete the code to define a function named setOwner.
function [1](address newOwner) public {
owner = newOwner;
}The function name setOwner clearly defines the behavior to set a new owner in the contract.
Complete the code to declare a function that returns the owner address.
function [1]() public view returns (address) { return owner; }
The function getOwner clearly indicates it returns the current owner address without changing state.
Fix the error in the function declaration to make it a valid Solidity function.
function setOwner(address newOwner) [1] {
owner = newOwner;
}view or returns incorrectly in a function that modifies state.The function must be declared public to be callable from outside the contract.
Fill both blanks to complete a function that checks if the caller is the owner before changing it.
function [1](address newOwner) public { require(msg.sender [2] owner, "Not owner"); owner = newOwner; }
The function setOwner changes the owner only if the caller is the current owner, checked by msg.sender == owner.
Fill all three blanks to create a function that emits an event when the owner changes.
event OwnerChanged(address indexed oldOwner, address indexed newOwner); function [1](address newOwner) public { require(msg.sender == owner, "Not owner"); address [2] = owner; owner = newOwner; emit [3](oldOwner, newOwner); }
The function setOwner updates the owner and emits the OwnerChanged event with the old and new owner addresses.