Last active
August 5, 2018 08:20
-
-
Save yhuag/5de142656a392bfdc919db06482c21ba 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.4.24; | |
import "github.com/OpenZeppelin/openzeppelin-solidity/contracts/math/SafeMath.sol"; | |
contract Payment { | |
using SafeMath for uint; | |
mapping (address => uint) public deposits; | |
function getBalance(address _user) public constant returns (uint) { | |
return deposits[_user]; | |
} | |
function deposit() public payable { | |
deposits[msg.sender] = deposits[msg.sender].add(msg.value); | |
} | |
function withdraw(uint _value) public { | |
deposits[msg.sender] = deposits[msg.sender].sub(_value); | |
msg.sender.transfer(_value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment