modifier and payable
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function getCoin() onlyOwner {
...
}
getCoin함수를 실행하지 이전에 modifier 함수인 onlyOwner를 실행해서 체크할 것을 미리 체크한 후 함수를 실행하라는 것입니다.
중요한 부분은 _; 인데 이것은 호출 함수를 대체하는 부분이다. _;의 위치가 어떤 역할을 하게 될지 판단해 봐야한다.
function tokenSend() payable {
token.distribute(msg.sender); //토큰 전송기능
}
토큰의 전송을 실행하기 위해서는 payable 내장 modifier 함수를 설정해야만 한다. 그렇지 않으면 토큰 전송은 실행 되지 않는다.
function domain 결정자
public
internal
modifier
payable
first sight
this.balance : contract balance이다.
keccak256 :
emit function_name : event function임을 명시적으로 나타낸다.
'solidity' 카테고리의 다른 글
Struicture of a Contract (0) | 2018.02.26 |
---|---|
layout of a solidity source file (0) | 2018.02.26 |
Solidity by Example Auction (1) | 2018.02.22 |
Solidity by Example Vote (1) | 2018.02.22 |
Introduction to Smart Contracts (1) | 2018.02.20 |