Skip to content

Instantly share code, notes, and snippets.

@nexto123
Last active August 12, 2021 16:15
Show Gist options
  • Save nexto123/e02d8581f4da3580b3aed7867185acdf to your computer and use it in GitHub Desktop.
Save nexto123/e02d8581f4da3580b3aed7867185acdf to your computer and use it in GitHub Desktop.
solidity assignment solution
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