-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSimpleStorageV2.sol
More file actions
24 lines (15 loc) · 903 Bytes
/
SimpleStorageV2.sol
File metadata and controls
24 lines (15 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.9.0;
//this smart contract allows us to store names associated with numbers
contract Storage{
struct People{
string name;
uint256 number;
}
People[] public people; // this array will hold the structs creaded by the contract
mapping(string => uint256) public nameToNumber; // this mapping allows to associate a name to a number so we can search by name
function addPerson(string memory _name, uint256 _number) public{
people.push(People(_name, _number)); // adds a struct People to the array
nameToNumber[_name] = _number; // adds a name and number to the mapping
}
}