-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLearning.sol
More file actions
51 lines (32 loc) · 1.39 KB
/
Learning.sol
File metadata and controls
51 lines (32 loc) · 1.39 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
contract SimpleStorage {
// this will deploy as 0
uint256 bigMoney;
// if i where to add a variable it would be at index 1
bool favbool;
struct People {
uint256 bigMoney;
string name;
}
/// the people array is not a fixed array, below the push function is used to push values into this array in this case it would be a string and a uint
/// the mapping is linking a type of variable to another to be able to pull values associated with each other.
People[] public people;
mapping(string => uint256) public nametobigmoney;
function store(uint256 _bigMoney) public {
bigMoney = _bigMoney;
}
/// function store2() public {
//view means you will read a state
// public variables are also view functions
// pure functions do only math but the state will not be saved
function retrieve() public view returns(uint256) {
return bigMoney;
}
/// this function uses the
/// storing in memory stores them only for execution, the string in solidity is an array of bytes that you can append text into
function addPerson(string memory _name, uint256 _bigMoney) public{
people.push(People(_bigMoney, _name));
nametobigmoney[_name] = _bigMoney;
}
}