all files / contracts/ MetaCoin.sol

88.89% Statements 8/9
50% Branches 1/2
100% Functions 4/4
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                                                     
pragma solidity ^0.4.4;
 
import "./ConvertLib.sol";
 
// This is just a simple example of a coin-like contract.
// It is not standards compatible and cannot be expected to talk to other
// coin/token contracts. If you want to create a standards-compliant
// token, see: https://github.com/ConsenSys/Tokens. Cheers!
 
contract MetaCoin {
	mapping (address => uint) balances;
 
	event Transfer(address indexed _from, address indexed _to, uint256 _value);
 
	function MetaCoin() {
		balances[tx.origin] = 10000;
	}
 
	function sendCoin(address receiver, uint amount) returns(bool sufficient) {
		Iif (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];
	}
}