Skip to content

jfmartinz/functionErrors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Metacrafters: Project

In this project I made a simple club contract designed to check if someone is eligible to enter a club based on their age.

Project requirments:

For this project, write a smart contract that implements the require(), assert() and revert() statements.

Excuting the program

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

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published