TRC-20 protocol interface

Full reference for every function and event in the TRC-20 standard.

📘

Prerequisites

TRC-20 contract standard

TRC-20 is a set of contract standards for issuing fungible token assets on TRON. Any contract that implements the required functions and events below is considered a TRC-20 contract. Wallets and exchanges integrating a TRC-20 contract use this standard set of functions and events to interact with the contract.

Required interface

Every TRC-20 contract must implement the functions and events below:

interface TRC20 {
    function totalSupply() external view returns (uint theTotalSupply);
    function balanceOf(address _owner) external view returns (uint balance);
    function transfer(address _to, uint _value) external returns (bool success);
    function transferFrom(address _from, address _to, uint _value) external returns (bool success);
    function approve(address _spender, uint _value) external returns (bool success);
    function allowance(address _owner, address _spender) external view returns (uint remaining);

    event Transfer(address indexed _from, address indexed _to, uint _value);
    event Approval(address indexed _owner, address indexed _spender, uint _value);
}

Function reference

FunctionPurpose
totalSupply()Returns the total supply of the token.
balanceOf(address _owner)Returns the token balance of _owner.
transfer(address _to, uint _value)Transfers _value tokens from the caller's account to _to.
approve(address _spender, uint _value)Authorizes _spender (often a DApp contract) to transfer up to _value tokens from the caller's account.
transferFrom(address _from, address _to, uint _value)Allows an approved spender to transfer _value tokens from _from to _to. The owner account must have called approve first.
allowance(address _owner, address _spender)Returns the remaining number of tokens _spender is still allowed to transfer from _owner.

Event reference

EventFires when
Transfer(_from, _to, _value)A successful transfer or transferFrom moves tokens. Also fires on mint (_from = 0x0) and burn (_to = 0x0).
Approval(_owner, _spender, _value)A successful approve sets a new allowance for _spender on behalf of _owner.

Optional metadata

The following public state variables are optional but supported by virtually every wallet and explorer:

string public name = "TRONTestCoin";
string public symbol = "TTC";
uint8 public decimals = 6;
FieldPurpose
nameHuman-readable name of the token.
symbolShort abbreviation displayed by wallets and exchanges.
decimalsNumber of decimal places used in token amounts. decimals = 6 means 1 token = 1,000,000 base units.

Related resources