TRC-20 - TRON Documentation
| Tags | |
|---|---|
| URL | https://tronprotocol.github.io/documentation-en/contracts/trc20/ |
TRC-20 is a technical standard used for smart contracts on the TRON blockchain for implementing tokens with the TRON Virtual Machine (TVM). It is fully compatible to ERC-20.
Implementation Rules
3 Optional Items
- Token Name
string public constant name = “TRONEuropeRewardCoin”;
- Token Abbreviation
string public constant symbol = “TERC”;
- Token Precision
uint8 public constant decimals = 6;
6 Required Items
contract TRC20 {
function totalSupply() constant returns (uint theTotalSupply);
function balanceOf(address _owner) constant returns (uint balance);
function transfer(address _to, uint _value) returns (bool success);
function transferFrom(address _from, address _to, uint _value) returns (bool success);
function approve(address _spender, uint _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint remaining);
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}
- totalSupply()
This function returns the total supply of the token.
- balanceOf()
This function returns the token balance of the specific account.
- transfer()
This function is used to transfer an amount of tokens from the smart contract to a specific address.
- approve()
This function is used to authorize the third party (like a DAPP smart contract) to transfer token from the token owner’s account.
- transferFrom()
This function is used to allow the third party to transfer token from an owner account to a receiver account. The owner account must be approved to be called by the third party.
- allowance()
This function is used to query the remaining amount of tokens the third party can transfer.
2 Event Functions
When token is successfully transferred, it has to trigger Transfer Event.
When approval() is successfully called, it has to trigger Approval Event.