- YouTube
www.youtube.com
// 파라미터 값이 없는 경우
modifier 모디파이어명{
revert 나 require
_;
}
// 파라미터 값이 없는 경우
modifier 모디파이어명(파라미터){
revert 나 require
_;
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract lec27{
modifier onlyAdults{
revert("You are not allowed to pay for the cigarette");
_;
}
function BuyCigarette() public onlyAdults returns(string memory){
return "Your payment is scceeded";
}
}
function BuyCigarette() public onlyAdults returns(string memory){
revert("You are not allowed to pay for the cigarette");
return "Your payment is scceeded"; // 모디 파이어의 _; 이 부분.
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract lec27{
modifier onlyAdults2(uint256 _age){
require(_age>18,"You are not allowed to pay for the cigarette");
_;
}
function BuyCigarette2(uint256 _age) public onlyAdults2(_age) returns(string memory){
return "Your payment is scceeded";
}
}
function BuyCigarette2(uint256 _age) public returns(string memory){
require(_age>18,"You are not allowed to pay for the cigarette");
return "Your payment is scceeded";
}
솔리디티 강좌 32강 - payable,msg.value, 와 이더를 보내는 3가지 함수 (send, transfer, call) (0) | 2021.10.01 |
---|---|
솔리디티 강좌 31강 - SPDX 라이센스/주석 (0) | 2021.09.30 |
솔리디티 강좌 29강 - function 5 return값 변수 명시 (0) | 2021.09.28 |
솔리디티 강좌 28강 - 에러 핸들러 4 try/catch 2 (0) | 2021.09.27 |
솔리디티 강좌 27강 - 에러 핸들러 3 try/catch 1 (0) | 2021.09.26 |