Code has been added to clipboard!

Subcurrency Basics

Example
pragma solidity ^0.4.0;

contract Subcurrency {
    // The "public" keyword allows external accounts to read the variable
    address public minter;
    mapping (address => uint) public coinBalances;

    // Light clients can react on changes efficiently thanks to events.
    event Sent(address from, address to, uint sum);

    // The code of this constructor is run only once the contract is created.
    function Coin() {
        minter = msg.sender;
    }

    function mint(address receiver, uint sum) {
        if (msg.sender != minter) return;
        coinBalances[receiver] += sum;
    }

    function send(address receiver, uint amount) {
        if (coinBalances[msg.sender] < sum) return;
        coinBalances[msg.sender] -= sum;
        coinBalances[receiver] += sum;
        Sent(msg.sender, receiver, sum);
    }
}