Skip to content

Instantly share code, notes, and snippets.

@dhananjayhegde
Created December 5, 2021 14:23
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 dhananjayhegde/9acce90a42e2ceeb492e39ee3b7c4456 to your computer and use it in GitHub Desktop.
Save dhananjayhegde/9acce90a42e2ceeb492e39ee3b7c4456 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.1+commit.df193b15.js&optimize=undefined&runs=undefined&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
contract SimpleStorage{
struct People {
uint256 favoriteNumber;
string name;
}
People[] public people;
mapping(string => uint256) public nameToFavNum;
function addPerson(string memory _name, uint256 _favoriteNumber) public {
people.push( People( {favoriteNumber: _favoriteNumber, name: _name} ) );
nameToFavNum[_name] = _favoriteNumber;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment