Skip to content

Instantly share code, notes, and snippets.

@devlongs
Created August 1, 2022 15:00
Show Gist options
  • Select an option

  • Save devlongs/26c998b646c11c1e321549becce753af to your computer and use it in GitHub Desktop.

Select an option

Save devlongs/26c998b646c11c1e321549becce753af to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
contract SimpleStorage {
uint256 favoriteNumber;
mapping(string => uint256) public nameToFavoriteNumber;
struct People {
uint256 favoriteNumber;
string name;
}
People[] public people;
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