Skip to content

Instantly share code, notes, and snippets.

@Amit0617
Created April 23, 2022 17:25
Show Gist options
  • Save Amit0617/0728a63ea76f4ff1cce5ca07259bf32d to your computer and use it in GitHub Desktop.
Save Amit0617/0728a63ea76f4ff1cce5ca07259bf32d to your computer and use it in GitHub Desktop.
Store a number and retreive its value
//SPDX-License-Identifier: MIT
pragma solidity 0.8.7;
contract HelloWorld {
// Declaring a global variable that stores the number
uint myNumber;
/** @dev Store a given number into a variable
* Input - unsigned integer
* @param num value to myNumber
*/
function storeNumber(uint num) public {
myNumber = num;
}
/** @dev Return the stored number
* Output - unsigned integer
* @return value of myNumber
*/
function retrieveNumber() public view returns(uint) {
return myNumber;
}
} //closing contract 'HelloWorld'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment