TRC-10

Introduction

TRC-10 is a token standard in TRON Ecosystem, which is based on chain rather than TVM. By paying 1024 TRX, every account in TRON network is allowed to issue TRC-10 token.

Issue

By utilizingAssetIssueContract, a particular type of transaction in TRON, each account is able to issue TRC-10 after paying 1024 TRX.

  • HTTP API
    Trough FullNode wallet/createassetissue to create an unsigned transaction issuing TRC-20,
    curl -X POST  https://api.shasta.trongrid.io/wallet/createassetissue -d '{
    "owner_address":"417946F66D0FC67924DA0AC9936183AB3B07C81126",
    "name":"0x6173736574497373756531353330383934333132313538",
    "abbr": "0x6162627231353330383934333132313538",
    "total_supply" :100000000,
    "trx_num":1,
    "num":1,
    "precision":1,
    "start_time" : 1581928489000,
    "end_time":1581938187000,
    "description":"007570646174654e616d6531353330363038383733343633",
    "url":"007570646174654e616d6531353330363038383733343633",
    "free_asset_net_limit":10000,
    "public_free_asset_net_limit":10000,
    "frozen_supply":{"frozen_amount":1, "frozen_days":2}
    }'

Once the transaction is done, we need to sign and broadcast this transaction in order to implement the issuing. Details can be found in Transactions.

  • TronWeb SDK
const privateKey = "...";
var createAssetAddress = "TM2TmqauSEiRf16CyFgzHV2BVxBejY9iyR";
const trc_options = {
      name : "test", 
      abbreviation : "tt",  
      description : "fortest", 
      url : "www.baidu.com",
      totalSupply : 10000000,
      trxRatio : 1,
      tokenRatio : 1,
      saleStart : 1581929489000,
      saleEnd : 1581938187000,
      freeBandwidth : 0,
      freeBandwidthLimit : 0,
      frozenAmount : 0,
      frozenDuration : 0,
      precision : 6
}
//create an unsigned transaction for TRC-10 issuing
tradeobj = await tronWeb.transactionBuilder.createAsset(
      trc_options,
      createAssetAddress
).then(output => {
  console.log('- Output:', output, '\n');
  return output;
});
//sign
const signedtxn = await tronWeb.trx.sign(
      tradeobj,
      privateKey
);
//broadcast
const receipt = await tronWeb.trx.sendRawTransaction(
      signedtxn
).then(output => {
  console.log('- Output:', output, '\n');
  return output;
});

Transfer

TransferAssetContract is introduced as a type of transaction in TRON network to transfers the token from one account address to another. It can be implemented with either HTTP API or TronWeb SDK.

  • HTTP API
    With fullnode HTTP API wallet/transferasset to start an unsigned transaction,
curl -X POST   https://127.0.0.1:8090/wallet/transferasset -d '{
  "owner_address":"41d1e7a6bc354106cb410e65ff8b181c600ff14292", 
  "to_address": "41e552f6487585c2b58bc2c9bb4492bc1f17132cd0", 
  "asset_name": "0x6173736574497373756531353330383934333132313538", 
  "amount": 100
}'

When the transaction is created, we need to sign and broadcast this transaction in order to implement the transfer. Details can be found in Transactions.

  • TronWeb SDK
const privateKey = "..."; 
var toAddress = "TM2TmqauSEiRf16CyFgzHV2BVxBejY9iyR";
var tokenID= "1000088";
var amount = 1000;
var fromAddress = "TVDGpn4hCSzJ5nkHPLetk8KQBtwaTppnkr";
//create an unsigned transfer
tradeobj = await tronWeb.transactionBuilder.sendToken(
      toAddress,
      amount,
      tokenID,
      fromAddress,    
).then(output => {
  console.log('- Output:', output, '\n');
  return output;
});
//sign
const signedtxn = await tronWeb.trx.sign(
      tradeobj,
      privateKey
);
//broadcast
const receipt = await tronWeb.trx.sendRawTransaction(
      signedtxn
).then(output => {
  console.log('- Output:', output, '\n');
  return output;
});

Check Balance

  • HTTP API
    The return value of assetV2 in fullnode HTTP APIwallet/getaccount shows the TRC-10 balance in wallet,
 curl -X POST  https://api.shasta.trongrid.io/wallet/getaccount -d 
     '{"address": "TM2TmqauSEiRf16CyFgzHV2BVxBejY9iyR",
       "visible": true
     }'
  • tronweb SDK
var address = "TM2TmqauSEiRf16CyFgzHV2BVxBejY9iyR"; 
//check the balance by assetV2 value in return
var tradeobj = await tronWeb.trx.getAccount(
      address,
).then(output => {console.log('- Output:', output, '\n');});

More TRC-10 API

NumAPIDescription
1easytransferassetbyprivateuse private key to make an easy transfer of TRC-10
2easytransferassetuse private key to make an easy transfer of TRC-10
3getassetissuebyaccountcheck issued TRC-10 by account
4getassetissuebyidcheck issued TRC-10 by ID
5getassetissuebynamecheck issued TRC-10 by name
6getassetissuelistbynamecheck issued TRC-10 list by name
7getassetissuelistcheck issued TRC-10 list
8getpaginatedassetissuelistcheck paginated TRC-10 list
9unfreezeassetunfreeze pledge ended token
10updateassetupdate token info
11participateassetissueparticipate token issuing