ERC20

Interface#

function totalSupply() public constant returns (uint);
function balanceOf(address tokenOwner) public constant returns (uint balance);
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);

Explanation of each method:

Code Notes#

  • You cannot get "existing" keys for a mapping. You'd have to store them separately.
  • public contract variables automatically have a getter created for them, but not a setter.
  • When a require condition is not met, all prior transactions are undone.
  • Useful variables available in Solidity
    • msg.sender: The address of the sender of the whatever function is being executed.
    • block.timestamp: The current block timestamp as seconds since unix epoch.