Last active
February 13, 2019 17:53
-
-
Save dsiganos/8791a99f0632119d304cd7d92a715d30 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
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.22 <0.6.0; | |
contract DepositAndRefund { | |
mapping (address => uint) public balances; | |
function get_balance(address party) public view returns (uint) { | |
return balances[party]; | |
} | |
function deposit() public payable returns (uint) { | |
balances[msg.sender] += msg.value; | |
} | |
function withdraw(uint amount) public payable { | |
require(balances[msg.sender] >= amount); | |
balances[msg.sender] -= amount; | |
msg.sender.transfer(amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment