Created
March 29, 2019 17:52
-
-
Save JesseAbram/0283233be0e03086060f38390fd92c39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.1; | |
contract count { | |
uint counter; | |
address paid; | |
struct counting { | |
address counter; | |
string message; | |
uint value; | |
} | |
counting[] public numbers; | |
mapping(address => uint) amount; | |
constructor () public { | |
counter = 0; | |
} | |
function increment(uint _counter, string calldata message) payable external { | |
counter += _counter; | |
numbers.push(counting(msg.sender, message, msg.value)); | |
amount[msg.sender] = msg.value; | |
} | |
function decrement() external { | |
//require(counter > 0); | |
counter --; | |
} | |
function get() external view returns(uint){ | |
return counter; | |
} | |
function () payable external { | |
counter += msg.value; | |
paid = msg.sender; | |
} | |
function getMoney() external view returns (uint){ | |
return address(this).balance; | |
} | |
function getPaid() external view returns (address){ | |
return paid; | |
} | |
function getNumbers(uint index) external view returns (address, string memory, uint){ | |
counting memory object = numbers[index]; | |
return (object.counter, object.message, object.value); | |
} | |
function getAmount(address key) external view returns (uint){ | |
return amount[key]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment