-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleStorage.sol
37 lines (29 loc) · 883 Bytes
/
SimpleStorage.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.9.0;
contract SimpleStorage {
// comments are created like this
/*
I think
I can also
comment
like this
*/
uint256 favoriteNumber;
struct People {
uint256 favoriteNumber;
string name;
}
People public person = People({favoriteNumber: 69, name: "Kuba"});
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;
}
}