1.8 KiB
1.8 KiB
How it works ?
The standard
This is a ERC20 token so it has all the function you would expect from it.
The getters:
// to get the full name of the token (in this case Kanel42)
function name() public view returns (string)
// to get the symbol of the token (in this case KNL42)
function symbol() public view returns (string)
// to get the number of decimals (number of token * 10^decimals to get the number of token)
function decimals() public view returns (uint8)
// to get the total supply that can be minted (in this case 8000(000000))
function totalSupply() public view returns (uint256)
// to get the balance of an address
function balanceOf(address _owner) public view returns (uint256 balance)
// to know how much the _spender can send on behalf of the _owner
function allowance(address _owner, address _spender) public view returns (uint256 remaining)
The member functions:
// to transfer tokens to another address (_to)
function transfer(address _to, uint256 _value) public returns (bool success)
// to transfer tokens on behalf of _from to another address (_to)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
// to approve a certain amount to a _spender that can send token on your behalf
function approve(address _spender, uint256 _value) public returns (bool success)
Events:
// is sent when a transfer is successful
event Transfer(address indexed _from, address indexed _to, uint256 _value)
// is sent when an approval is successful
event Approval(address indexed _owner, address indexed _spender, uint256 _value)
And there is also another function for minting the token:
// the _value determine how much to mint (in *(10^decimals))
function mint(uint256 _value) public