In this project I made a simple club contract designed to check if someone is eligible to enter a club based on their age.
For this project, write a smart contract that implements the require(), assert() and revert() statements.
To run this program, you can use Remix, an online Solidity IDE. To get started, go to the Remix website.
My Solution
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract AgeRestrictionClub {
uint public minimumAge = 18;
function enterClub(uint age) public view {
require(age > 0 && age < 60, "Age must be greater than 0 and less than 60.");
if (age < minimumAge) {
revert("You must be at least 18 years old to enter the club.");
}
assert(age >= minimumAge && age < 60);
}
}I recommend you to learn the basics of Solidity in MetaCrafters or check out my notes on this repo, before attempting this assessment.
Author:
Twitter: @jfmartinz
Github: @jfmartinz
Linkedin: @jfmartinz