Skip to content

Instantly share code, notes, and snippets.

@HaQadosch
Created September 15, 2021 20:32
Show Gist options
  • Save HaQadosch/670590646faaab12eeb9977689bd0c34 to your computer and use it in GitHub Desktop.
Save HaQadosch/670590646faaab12eeb9977689bd0c34 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.9.0;
contract SimpleStorage {
uint256 favoriteNumber = 0;
struct People {
string name;
uint256 favoriteNumber;
}
People[] public peoples;
mapping (string => uint256) public nameToFavoriteNumber;
function store (uint256 newFavNumber) public {
favoriteNumber = newFavNumber;
}
function viewFavNumber () public view returns (uint256) {
return favoriteNumber;
}
function addPerson (string memory name, uint256 favNumber) public {
peoples.push(People(name, favNumber));
nameToFavoriteNumber[name] = favNumber;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment