OwnerHelper
abstract contract OwnerHelper {
address private _owner;
event OwnershipTransferred(address indexed preOwner, address indexed nextOwner);
modifier onlyOwner {
require(msg.sender == _owner, "OwnerHelper: caller is not owner");
_;
}
constructor() {
_owner = msg.sender;
}
function owner() public view virtual returns (address) {
return _owner;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != _owner);
require(newOwner != address(0x0));
_owner = newOwner;
emit OwnershipTransferred(_owner, newOwner);
}
}
_owner는 관리자를 나타냅니다.
address private _owner;
OwnershipTransferred이벤트는 관리자가 변경됐을때 이전관리자주소, 새 관리자주소를 로그에 남긴다.
event OwnershipTransferred(address indexed preOwner, address indexed nextOwner);
onlyOwner함수 변경자는 함수실행 이전에 함수를 실행시키는 사람이 관리자인지 확인한다.
modifier onlyOwner {
require(msg.sender == _owner, "OwnerHelper: caller is not owner");
_;
}
'개발 학습 > 블록체인' 카테고리의 다른 글
S4: ERC-721 함수 (0) | 2021.11.30 |
---|---|
S4: 토큰 LOCK 설정 및 제거 (0) | 2021.11.29 |
S4: Over/Under flow를 막아주는 SafeMath (0) | 2021.11.26 |
S4: ERC-20 (0) | 2021.11.26 |
S4: Solidity 기본 문법 (0) | 2021.11.25 |
댓글