Created
March 5, 2022 09:16
-
-
Save MManzar786/53ed49edf94ca353e7591465cfa40d3c 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=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // pragma solidity means whick version of solidity youre using and we | |
| // are using Solidity version gt & eq version 0.7.0 and less than 0.9.0 | |
| pragma solidity >=0.7.0 <0.9.0; | |
| // contract is keyword for creating Contract with named as TestContract | |
| contract TestContract { | |
| // variable of the greeting | |
| string private greeting; | |
| // Initialize the greeting value to 'Hello!!'. | |
| constructor() public { | |
| greeting = "Hello!!"; | |
| } | |
| // just like any other language we made setter / getter for setting values | |
| function setGreeting(string memory newGreeting) public { | |
| greeting = newGreeting; | |
| } | |
| // public: greet function will be publicly accessed by users because of public modifiers | |
| // view: means only viewable to value is gonna change | |
| // return: tells a return type if string and memory tells that this is temporary data | |
| // and it will not stay forever in block chain | |
| function greet() public view returns (string memory) { | |
| return greeting; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment