tip: 10
title: TRC-10 Token Standard
author: Marcus Zhao<zhaohong229@gmail.com>
type: Standards Track
category: TRC
discussion-to: https://github.com/tronprotocol/TIPs/issues/10
status: Final
created: 2018-11-11
A standard interface for tokens.
The following standard allows for the implementation of a standard API for tokens on the native chain. This standard provides basic functionality to transfer tokens.
A standard interface allows any language to implement the token.
returns the id of token
The ID is integer stored as a string and start from 100001. the ID less then 100000 is reserved.
returns the name of token When the ALLOW_SAME_TOKEN_NAME proposal is opened, duplicate names are allowed
Returns the number of decimals the token uses - e.g. 6, means to divide the token amount by 1000000 to get its user representation.
The value range is between 0 to 6. ALLOW_SAME_TOKEN_NAME proposal needs to be turned on first. Otherwise, it defaults to 0
Returns the total token supply.
the list of the amount and duration of frozen tokens
the equivalent TRX amount, for example,232241
the equivalent custom amount of assets
starting time, for example,20170312
finishing time, for example,20170512
Token description, for example,”trondada”
the URL link of the token.
The free available bandwidth for transferring this specific asset of each account.
The free available bandwidth for transferring this specific asset of all accounts.
free bandwidth used by all accounts for transferring this specific asset.
the amount of time used on free bandwidth when the token was most recently transferred
The identity of the token will be id instead of name and every token will support decimal places after the proposal is approved, so it will affect the following structure and contracts.
message Account {
// the other asset owned by this account, deprecated
map<string, int64> asset = 6;
// the other asset owned by this account, key is assetId
map<string, int64> assetV2 = 56;
// name of asset issued, deprecated
bytes asset_issued_name = 17;
// id of asset issued
bytes asset_issued_ID = 57;
// latest asset operation time, deprecated
map<string, int64> latest_asset_operation_time = 18;
// latest asset operation time, key is assetId
map<string, int64> latest_asset_operation_timeV2 = 58;
// free asset net usage, deprecated
map<string, int64> free_asset_net_usage = 20;
// free asset net usage, key is assetId
map<string, int64> free_asset_net_usageV2 = 59;
}
AssetIssueContract: add field precision, means the number of decimal places
message TransferAssetContract {
bytes asset_name = 1; // this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id which should be in string format.
bytes owner_address = 2;
bytes to_address = 3;
int64 amount = 4; // the number of tokens in smallest unit
}
message ParticipateAssetIssueContract {
bytes owner_address = 1;
bytes to_address = 2;
bytes asset_name = 3; // this field is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id which should be in string format.
int64 amount = 4; // the amount of sun
}
**notice**
asset_name is token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise it is token id which should be in string format.
message ExchangeCreateContract {
bytes owner_address = 1;
bytes first_token_id = 2;
int64 first_token_balance = 3;
bytes second_token_id = 4;
int64 second_token_balance = 5;
}
message ExchangeInjectContract {
bytes owner_address = 1;
int64 exchange_id = 2;
bytes token_id = 3;
int64 quant = 4;
}
message ExchangeWithdrawContract {
bytes owner_address = 1;
int64 exchange_id = 2;
bytes token_id = 3;
int64 quant = 4;
}
message ExchangeTransactionContract {
bytes owner_address = 1;
int64 exchange_id = 2;
bytes token_id = 3;
int64 quant = 4;
int64 expected = 5;
}
**notice**
first_token_id and second_token_id are token name before the proposal ALLOW_SAME_TOKEN_NAME is active, otherwise they are token id in string format. first_token_balance and second_token_balance are the number of token in smallest unit. quant and expected are the number of token in smallest unit.