// ----------------------------------------------------------------------------
// Owned contract
// ----------------------------------------------------------------------------
contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
The old owner transfers the ownership of the contract to new owner and the new owner needs to accept the ownership.
As a smart contract developer, you need to write a contract which needs to derive this contract (Owned) and use onlyOwner() for control access.
2 Likes
So this is wrong? Also how does the new owner accept it? Is it a pop up in the wallet?
I do not see anything wrong.
The new owner needs to interact with smart contract, easy way is to use etherscan with metamask connected.