Skip to content

Instantly share code, notes, and snippets.

@ArslanKathia
Created January 30, 2023 12:07
Show Gist options
  • Save ArslanKathia/8ab33309330b56fb1a25813e6d59313d to your computer and use it in GitHub Desktop.
Save ArslanKathia/8ab33309330b56fb1a25813e6d59313d to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8;
contract Require{
address public owner = msg.sender;
uint public age = 25;
//when require condition is false than execution stopped and previously set the state variable goes to reset state
// and refund the gas fee.
function CheckAge(uint _x) public{
age = age + 5;
require(_x>2,"X values is less than 2");
}
//when require condition is false than execution stopped and previously set the state variable goes to reset state
// and refund the gas fee.
function onlyOwner() public{
require(owner == msg.sender,"You are not the owner");
age = age +2 ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment