Created
February 17, 2017 16:05
-
-
Save ianmonkuk/1e50fa2fc78c9c80eed92ddc388874ba 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.4; | |
import "./ConvertLib.sol"; | |
contract MetaCoin { | |
mapping (address => uint) balances; | |
address originAddress; | |
event Transfer(address indexed _from, address indexed _to, uint256 _value); | |
function MetaCoin() { | |
balances[tx.origin] = 10000; | |
originAddress = tx.origin; | |
} | |
function sendCoin(address receiver, uint amount) returns(bool sufficient) { | |
if (balances[msg.sender] < amount) return false; | |
balances[msg.sender] -= amount; | |
balances[receiver] += amount; | |
Transfer(msg.sender, receiver, amount); | |
return true; | |
} | |
function getBalanceInEth(address addr) returns(uint){ | |
return ConvertLib.convert(getBalance(addr),2); | |
} | |
function getBalance(address addr) returns(uint) { | |
return balances[addr]; | |
} | |
function getOriginAddress() returns(address) { | |
return originAddress; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment