Skip to content

Subcurrency Example

KinSquare edited this page May 9, 2021 · 1 revision
pragma solidity >=0.7.0<0.9.0;

contract Coin {
  address public minter;
  mapping (address => uint) public balances;

  event Sent(address from, address to, uint amount);

  constructor(){
    minter = msg.sender; //here i would like to indicate anyone rather than only one. what if it I omit?
  }

function mint(address receiver, uint amount) public {
  require(msg.sender == minter);
  require(amount < 1e60);
  balances[receiver] += amount;
}

function send(address receiver, uint amount) public {
  require(amount <= balances[msg.sender], "Insufficient balance.");
  balances[msg.sender] -= amount;
  balances[receiver] += amount;
  emit Sent(msg.sender, receiver, amount); //clueless on emit and why caps for Sent ?internal stuff?
  }
}

Clone this wiki locally