Last active
March 29, 2022 14:36
-
-
Save amkurian/506ea06ae8dee21642c438dec91246f7 to your computer and use it in GitHub Desktop.
SimpleStorage.sol
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.6.0; | |
contract SimpleStorage { | |
uint256 public favoriteNumber; | |
struct People { | |
uint256 favoriteNumber; | |
string name; | |
} | |
People[] public people; | |
mapping(string => uint256) public nameToFavoriteNumber; | |
function store(uint256 _favoriteNumber) public { | |
favoriteNumber = _favoriteNumber; | |
} | |
function retrieve() public view returns (uint256) { | |
return favoriteNumber; | |
} | |
function addPerson(string memory _name, uint256 _favoriteNumber) public { | |
people.push(People({favoriteNumber: _favoriteNumber, name: _name})); | |
nameToFavoriteNumber[_name] = _favoriteNumber; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment