Skip to content

Instantly share code, notes, and snippets.

@Zeegaths
Created February 11, 2024 12:01
Show Gist options
  • Save Zeegaths/eb97fb790250a9ea352b5bd9796373e5 to your computer and use it in GitHub Desktop.
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
//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