CoinExample

Loading...
//Creation: 20189 + 61600
//External:
//  mint(address,uint256): 20395
//  queryBalance(address): 260
//  send(address,uint256): 42229
contract coin {
    address minter;
    mapping (address => uint) balances;
    
    event Send(address from, address to, uint amount);
    
    function coin() {
        minter = msg.sender;
    }
    
    function mint(address owner, uint amount) returns (uint stat)
    {
        if(owner != minter) return 3; //You are NOT the father!
        balances[owner] = amount;
        return 1; //successful mint
    }
    
    function send(address reciever, uint amount) returns (uint stat)
    {
        if(balances[msg.sender] < amount) return 2; //negative amount
        balances[msg.sender] -= amount;
        balances[reciever] += amount;
        Send(msg.sender, reciever, amount);
        return 1; //successful send
    }
    
    function queryBalance(address someAddress) constant returns (uint balance) {
        return balances[someAddress];
    }
}

Solidity contract for Ethereum

Copied from ethereum solidity tutorial. Used online solidity compiler, modified to give status returns. and used "optimize" option.

Preferences

Note: Your changes won't be saved, because not Logged-in.

Create your own Contract