7

If I try to compile the following example code in Mix it doesn't work. As soon as I change the name from Coin to Coins it starts working as supposed? Is this a bug or a feature?

contract Coin {
    // The keyword "public" makes those variables
    // readable from outside.
    address public minter;
    mapping (address => uint) public balances;

    // Events allow light clients to react on
    // changes efficiently.
    event Sent(address from, address to, uint amount);

    // This is the constructor whose code is
    // run only when the contract is created.
    function Coin() {
        minter = msg.sender;
    }
    function mint(address receiver, uint amount) {
        if (msg.sender != minter) return;
        balances[receiver] += amount;
    }
    function send(address receiver, uint amount) {
        if (balances[msg.sender] < amount) return;
        balances[msg.sender] -= amount;
        balances[receiver] += amount;
        Sent(msg.sender, receiver, amount);
    }
}
8

The Coin contract is included in the Solidity standard library – a feature from Proof of Concepts times. The standard library includes following contracts:

  • Config,
  • Coin,
  • CoinReg,
  • coin,
  • service,
  • owned,
  • mortal,
  • NameReg,
  • named,
  • std,
  • configUser.

Currently all uses of them are discouraged except for owned and mortal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.