MetaCoin.sol 807 B

1234567891011121314151617181920212223242526272829
  1. import "ConvertLib.sol";
  2. // This is just a simple example of a coin-like contract.
  3. // It is not standards compatible and cannot be expected to talk to other
  4. // coin/token contracts. If you want to create a standards-compliant
  5. // token, see: https://github.com/ConsenSys/Tokens. Cheers!
  6. contract MetaCoin {
  7. mapping (address => uint) balances;
  8. function MetaCoin() {
  9. balances[tx.origin] = 10000;
  10. }
  11. function sendCoin(address receiver, uint amount) returns(bool sufficient) {
  12. if (balances[msg.sender] < amount) return false;
  13. balances[msg.sender] -= amount;
  14. balances[receiver] += amount;
  15. return true;
  16. }
  17. function getBalanceInEth(address addr) returns(uint){
  18. return ConvertLib.convert(getBalance(addr),2);
  19. }
  20. function getBalance(address addr) returns(uint) {
  21. return balances[addr];
  22. }
  23. }