Created
February 11, 2024 12:01
-
-
Save Zeegaths/eb97fb790250a9ea352b5bd9796373e5 to your computer and use it in GitHub Desktop.
A smart contract that has both storage and memory types of variables in it
This file contains 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
//SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.0; | |
contract Storage { | |
struct student{ | |
string Name; | |
uint Age; | |
} | |
mapping (address => student) students; | |
//gets the age of the student | |
function calculateAge ( uint _yearofbirth, uint _currentYear) public returns (uint) { | |
students[msg.sender].Age = _currentYear - _yearofbirth; | |
return students[msg.sender].Age; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment