Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 sum) {
- if (coinBalances[msg.sender] < sum) return;
- coinBalances[msg.sender] -= sum;
- coinBalances[receiver] += sum;
- Sent(msg.sender, receiver, sum);
- }
- }
Add Comment
Please, Sign In to add comment