-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter_data.sol
More file actions
32 lines (25 loc) · 786 Bytes
/
Counter_data.sol
File metadata and controls
32 lines (25 loc) · 786 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
25
26
27
28
29
30
31
32
pragma solidity ^0.5.11;
contract count {
uint public counter;
// A struct can hold multiple data types
struct counting {
address counter;
string message;
}
// Array of our structs followed by a mapping
counting[] public numbers;
mapping(address => uint) public amount;
constructor() public {
counter = 0;
}
function increment(uint _counter, string calldata message) external {
counter += _counter;
// push a struct onto our array
numbers.push(counting(msg.sender, message));
// put the addresss of the transaction sent and the value they set into mapping
amount[msg.sender] = _counter;
}
function decrement() external {
counter--;
}
}