Skip to content

Instantly share code, notes, and snippets.

@agnel
Created June 10, 2022 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agnel/371b94f933c5e75419c765c35a677117 to your computer and use it in GitHub Desktop.
Save agnel/371b94f933c5e75419c765c35a677117 to your computer and use it in GitHub Desktop.
The SimpleStorage contract in Solidity from Lesson 1: Welcome to Remix! Simple Storage on FreeCodeCamp
// SPDX-License-Identifier: MIT
pragma solidity >= 0.6.0 <0.9.0;
contract SimpleStorage {
// this will get initialized as 0
uint256 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, _name));
nameToFavoriteNumber[_name] = _favoriteNumber;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment