Tron

TRON

TRON (TRX) can be accessed with the following coin types:

EnvironmentCoin TypeFaucet
TRON Productiontrx
TRON Testnetttrxhttps://developers.tron.network/docs/networks#testnet

Generating wallets

To create an Tron wallet using BitGoJS:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 bitgo .coin('ttrx') .wallets() .generateWallet({ label: 'My Test Wallet', passphrase: 'secretpassphrase1a5df8380e0e30', }) .then(function (wallet) { // print the new wallet console.dir(wallet); // print the new wallets address to send to console.dir(wallet.coinSpecific.rootAddress); });

You need to fund the wallet with 100 TRX as wallet creation costs this much for an individual user. You can find the address to fill on the rootAddress field above. TRON accounts must also maintain a minimum balance of 100 TRX.

To create an TRON wallet using the platform API:

1 2 3 4 5 6 7 8 LABEL="My Test Wallet" PASSPHRASE="secretpassphrase1a5df8380e0e30" curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -d "{ \"label\": \"$LABEL\", \"passphrase\": \"$PASSPHRASE\" }" \ http://$BITGO_EXPRESS_HOST:3080/api/v2/ttrx/wallet/generate

A similar operation will need to be provided above to the resultant rootAddress.

Creating addresses

BitGo supports multiple receive addresses for Tron. To create a new receive address in your TRX Wallet:

1 2 const address = await wallet.createAddress({ label: 'My address' }); console.log(address);

TRX and Token Withdrawal

You can send native TRX and TERC20 tokens with the .sendMany() method. However, TRX transactions support sending to only 1 recipient.

1 2 3 4 5 6 7 8 9 10 11 12 const coin = 'ttrx:usdc'; // coin can be ttrx, trx or token name const basecoin = bitgo.coin(coin); const transaction = yield walletInstance.sendMany({ recipients: [ { amount: '10341234', address: 'TMtA4FQRddJaQ37yrdMmNsuC3jbkCs2Brt', }, ], walletPassphrase: walletPassphrase, type: 'TokenTransfer', });

Balances

Tronix (TRX) is the native asset of the TRON blockchain. The base unit of Tronix is sun:

  • 1 sun is (10-6) or 0.000001 Tronix.
  • 1 Tronix is (106) or 1000000 sun (1 million).

Balances are supported in string format: balanceString, confirmedBalanceString, and spendableBalanceString.

To obtain TRX and token balances for an entire wallet using BitGoJS:

1 2 3 const basecoin = bitgo.coin(coin); const walletInfo = basecoin.wallets().get({ id: walletId, allTokens: true }); // walletInfo.tokens() will return complete Tron Token information, including balances

You can also get balances (both native and tokens) based solely off address:

1 2 3 const address = yield walletInstance.getAddress({ address: 'TTwW9apvyVL9EBqDVeTVDft15hf1Jnkpzy' }); const bal = address.balance; return bal;

Fees

Tron uses a resource model based on bandwidth and energy to handle the cost of TRX transfer and smart contract transactions.

Bandwidth is the unit that measures the size of the transaction bytes stored in the blockchain database.

An account receives 600 free bandwidth points per day. When the available bandwidth is not enough to pay for the transaction, TRX is burned.

Energy is the unit that measures the computational resources required to execute smart contracts.

Energy can only be obtained by staking TRX. When energy is not available, TRX is burned. The energy quantity is calculated when the contract is executed. The energy consumption is also affected by the contract's energy_factor, which is determined by the complexity of the contract.

Because exact fee calculation involves several variables and the system also burns the TRX paid if the transaction fails to execute successfully, BitGo uses a maximum fee approach to ensure transactions do not fail due to insufficient fees. The network calculates and burns only the cost of the transaction.

  • Transfer fee:
    • 2100000 sun (2.1 TRX) for TRX transactions
    • 35834875 sun (35.834875 TRX) for USDT token transactions
    • 17021500 sun (17.0215 TRX) for USDC token transactions
  • Wallet initialization fee:
    • 100000000 sun (100 TRX)

How to do a consolidation for TRX and TRON Tokens

To consolidate your receive address balances into the root address, enter the coin as TRX, or a Tron Token (trx:usdt, trx:usdc).

Note: It's recommended to consolidate tokens and then consolidate the remaining TRX in order to minimize the dust left on the address.

1 2 3 4 5 6 7 8 9 10 const consolidationTxes = await wallet.buildAccountConsolidations(); try { for (const unsignedConsolidation of consolidationTxes) { const res = await wallet.sendAccountConsolidation({ walletPassphrase, prebuildTx: unsignedConsolidation }); console.dir(res, { depth: 6 }); } } catch (e) { console.error(e); }