Last active
August 12, 2021 16:15
-
-
Save nexto123/e02d8581f4da3580b3aed7867185acdf to your computer and use it in GitHub Desktop.
solidity assignment solution
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 0.7.5; | |
contract MemoryAndStorage { | |
mapping(uint => User) users; | |
struct User{ | |
uint id; | |
uint balance; | |
} | |
function addUser(uint id, uint balance) public { | |
users[id] = User(id, balance); | |
} | |
function updateBalance(uint id, uint balance) public { | |
users[id].balance = balance; | |
} | |
function getBalance(uint id) view public returns (uint) { | |
return users[id].balance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment