Skip to content

Instantly share code, notes, and snippets.

Created February 20, 2018 00:54
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at
pragma solidity ^0.4.11;
contract MyEthBank {
mapping (address => uint) private balances;
address owner;
uint constant totalSupply = 10**4;
function MyEthBank() public payable {
balances[msg.sender] = totalSupply;
owner = msg.sender;
function deposit() public payable { // How Eth is received by bank
balances[owner] -= msg.value; // owner is bank
balances[msg.sender] += msg.value;
function send(uint amount, address addr) public { // How Eth is sent
if(amount >= 0) {
// It is important to set this to zero because the recipient
// can call this function again as part of the receiving call
// before `transfer` returns (see the remark above about
// conditions -> effects -> interaction).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment