What is TRC20?

Introduction

Implementation Rules

3 Optional Items:

string public constant name = “TRONEuropeRewardCoin”;
string public constant symbol = “TERC”;
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);}
contract MyTRCToken {    uint256 _totalSupply = 1000000;    function totalSupply() constant returns (uint256 theTotalSuppl {        theTotalSupply = _totalSupply;        return theTotalSupply;    }}
contract MyTRCToken {    mapping(address => uint256) balances;    address public owner; // Owner of this contract    function balanceOf(address _owner) constant returns (uint256 balance) {        return balances[_owner];    }}
contract MyTRCToken {    mapping(address => uint256) balances;    function transfer(address _to, uint256 _amount) returns (bool success) {        if (balances[msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) {            balances[msg.sender] -= _amount;            balances[_to] += _amount;            Transfer(msg.sender, _to, _amount); // trigger event            return true;        } else {                   return false;               }    }}
contract MyTRCToken {    mapping(address => mapping (address => uint256)) allowed;    function approve(address _spender, uint256 _amount) returns (bool success) {        allowed[msg.sender][_spender] = _amount;
// msg.sender is the third party's account
Approval(msg.sender, _spender, _amount);
// trigger event
return true; } }
contract MyTRCToken {    mapping(address => uint256) balances;    function transferFrom(address _from, address _to, uint256 _amount) returns (bool success) {        if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) {            balances[_from] -= _amount;            balances[_to] += _amount;            Transfer(_from, _to, _amount);            return true;        } else {                   return false;               }    }}

2 Event Functions

event Transfer(address indexed _from, address indexed _to, uint256 _value)
event Approval(address indexed _owner, address indexed _spender, uint256 _value)

References

For more information

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store