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.4.26+commit.4563c3fc.js&optimize=false&runs=200&gist=
pragma solidity ^0.4.17; | |
// https://programtheblockchain.com/posts/2017/12/15/writing-a-contract-that-handles-ether/ | |
// https://colab.research.google.com/drive/1S860CGKebS9MxuzmdaQjpnbpBnYc0Ag3?usp=sharing | |
contract pmEtherBox { | |
string msgWithdrawn = 'Withdrawn'; | |
string msgDeposit = 'Deposit'; | |
string msgBalance = 'Current Balance'; | |
string msgSentTo = 'Sent To'; | |
// address Beneficiary; | |
event LogStatus (uint i1, string s1, uint i2, string s2); | |
event LogStatus2 (uint i1, string s1, address B, uint i2, string s2); | |
function pullOut(uint amount) public { | |
msg.sender.transfer(amount); | |
emit LogStatus(amount,msgWithdrawn,address(this).balance, msgBalance); | |
} | |
function sendTo(uint amount, address Beneficiary) public { | |
Beneficiary.transfer(amount); | |
emit LogStatus2(amount,msgSentTo, Beneficiary, address(this).balance, msgBalance); | |
} | |
function putIn(uint amount) payable public { | |
require(msg.value == amount); | |
emit LogStatus(amount,msgDeposit,address(this).balance, msgBalance); | |
// nothing else to do! | |
} | |
function getBalance() public view returns (uint256) { | |
return address(this).balance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment