function owner() public view returns (address) { return _owner; }
modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; }
function isOwner() public view returns (bool) { return msg.sender == _owner; }
function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); }
function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); }
function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
contract AlienCodex is Ownable {
bool public contact; bytes32[] public codex;
modifier contacted() { assert(contact); _; } function make_contact() public { contact = true; }
function record(bytes32 _content) contacted public { codex.push(_content); }
function retract() contacted public { codex.length--; }
function revise(uint i, bytes32 _content) contacted public { codex[i] = _content; } }
我们发现,需要声明的所有权在父类中Ownable的_owner。但是我们发现,AlienCodex当中没用任何一个方法可以直接修改owner的值,但是有一个边长数组bytes32[] public codex;,并且有一系列方法可以操作它。