Skip to content

Instantly share code, notes, and snippets.

@yhuag
Last active August 5, 2018 08:20
Show Gist options
  • Save yhuag/5de142656a392bfdc919db06482c21ba to your computer and use it in GitHub Desktop.
Save yhuag/5de142656a392bfdc919db06482c21ba to your computer and use it in GitHub Desktop.
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