Advanced Cryptocurrency Topics: ERC20 Interface

Reviewing & Summarizing The ERC20 Token Interface

Introducing Solidity

ERC20 Interface Walkthrough

Allowance

function allowance(address _owner, address _spender) constant       returns (uint remaining);

Approve

function approve(address _spender, uint tokens) public returns (bool success);

BalanceOf

function balanceOf(address tokenOwner) public constant returns (uint balance);

TotalSupply

function totalSupply() public constant returns (uint);

Transfer

function transfer(address to, uint tokens) public returns (bool success);

TransferFrom

function transferFrom(address from, address to, uint tokens) public returns (bool success);

Bringing It All Together

// All of this can be found here: https://github.com/ethereum/EIPs/issues/20interface ERC20 {//standard variables
string public constant name = "Token Name";
string public constant symbol = "SYM";
uint8 public constant decimals = 18;
//core ERC20 functions
function allowance(address _owner, address _spender) constant returns (uint remaining);
function approve(address _spender, uint _value) returns (bool success);
function balanceOf(address _owner) constant returns (uint balance);
function totalSupply() constant returns (uint totalSupply);
function transfer(address _to, uint _value) returns (bool success);
function transferFrom(address _from, address _to, uint _value) returns (bool success);
// logging events
event Approval(address indexed _owner, address indexed _spender, uint _value);
event Transfer(address indexed _from, address indexed _to, uint _value);
}

Owner @ SetDesign, NightKnight & CryptoSpace | Product Designer | Hobbyist Mathematician | VR Developer | MS in Finance @ UF