How to Send/Transfer USDT/USDD/USDC Tokens on Tron Blockchain using Tronweb (Javascript)?
On Tron blockchain, the USDT, USDD or USDC token are TRC-20 contracts. You can use the following Javascript function to send over the USDT/USDD/USDC Token from one address to another on the Tron Blockchain. The network parameter can be “nile”, “shasta” test net, or the main net otherwise.
You also need to specify the amount, the private key, the APP key (which is optional in nile or shasta test net), and also the corresponding USDT/USDC/USDD TRC-20 contract address. The function will invoke the “transfer” method on the contract (USDT, USDC or USDD).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
async function sendTRC20Token(network, fromAddress, toAddress, amount, privateKey, AppKey, CONTRACT) let url = null; if (network === "shasta") url = "https://api.shasta.trongrid.io"; > else if (network === "nile") url = "https://nile.trongrid.io"; > else url = "https://api.trongrid.io"; > const tronWeb = new TronWeb( fullHost: url, headers: "TRON-PRO-API-KEY": AppKey >, privateKey: privateKey, >); const options = feeLimit: 10000000, callValue: 0 >; const tx = await tronWeb.transactionBuilder.triggerSmartContract( CONTRACT, 'transfer(address,uint256)', options, [ type: 'address', value: toAddress >, type: 'uint256', value: amount * 1000000 >], tronWeb.address.toHex(fromAddress) ); const signedTx = await tronWeb.trx.sign(tx.transaction); const broadcastTx = await tronWeb.trx.sendRawTransaction(signedTx); return broadcastTx; >
async function sendTRC20Token(network, fromAddress, toAddress, amount, privateKey, AppKey, CONTRACT) < let url = null; if (network === "shasta") < url = "https://api.shasta.trongrid.io"; >else if (network === "nile") < url = "https://nile.trongrid.io"; >else < url = "https://api.trongrid.io"; >const tronWeb = new TronWeb(< fullHost: url, headers: < "TRON-PRO-API-KEY": AppKey >, privateKey: privateKey, >); const options = < feeLimit: 10000000, callValue: 0 >; const tx = await tronWeb.transactionBuilder.triggerSmartContract( CONTRACT, 'transfer(address,uint256)', options, [< type: 'address', value: toAddress >, < type: 'uint256', value: amount * 1000000 >], tronWeb.address.toHex(fromAddress) ); const signedTx = await tronWeb.trx.sign(tx.transaction); const broadcastTx = await tronWeb.trx.sendRawTransaction(signedTx); return broadcastTx; >
1 2 3 4 5 6 7 8 9 10
(async function() const fromAddress = "TL. "; const toAddress = "TN. "; const amount = 1.2; const privateKey = "key"; const AppKey = "Tron Pro API Key - Optional"; const usdt_contract = "USDT contract see below"; const network = "shasta, nile or main"; await sendTRC20Token(network, fromAddress, toAddress, amount, privateKey, AppKey, usdt_contract); >)();
(async function() < const fromAddress = "TL. "; const toAddress = "TN. "; const amount = 1.2; const privateKey = "key"; const AppKey = "Tron Pro API Key - Optional"; const usdt_contract = "USDT contract see below"; const network = "shasta, nile or main"; await sendTRC20Token(network, fromAddress, toAddress, amount, privateKey, AppKey, usdt_contract); >)();
You can use the TronWeb library to send USDT (TRC-20) smart tokens using NodeJS. TronWeb is a JavaScript library that allows you to interact with the Tron blockchain. It provides an easy-to-use API for developers to build decentralized applications (dApps) on the Tron network.
To send USDT (TRC-20) smart tokens using NodeJS, you will need to create a TronWeb instance, get the address of the recipient, and then use the sendToken() method to send the tokens. The sendToken() method takes the recipient address, the amount of tokens to be sent, and the token name as parameters.
For example, the following code snippet shows how to send 10 USDT (TRC-20) tokens to a recipient address:
1 2 3 4 5 6 7 8 9 10 11 12
// Create a TronWeb instance const tronWeb = new TronWeb( fullHost: 'https://api.trongrid.io' >); // Get the recipient address const recipientAddress = 'Txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // Send 10 USDT (TRC-20) tokens tronWeb.sendToken(recipientAddress, 10, 'USDT').then(result => console.log(result); >);
// Create a TronWeb instance const tronWeb = new TronWeb(< fullHost: 'https://api.trongrid.io' >); // Get the recipient address const recipientAddress = 'Txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // Send 10 USDT (TRC-20) tokens tronWeb.sendToken(recipientAddress, 10, 'USDT').then(result => < console.log(result); >);
Smart Contract Addresses (TRC-20 Token) on Tron Blockchain for Stable coins (USDD, USDC and USDT) can be found below:
USDT TRC-20 Contract Addresses
USDT is the official stablecoin issued by Tether on the TRON network.
- Shasta TestNet: TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs
- Nile TestNet: TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf
- Main Net: TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t
USDD TRC-20 Contract Addresses
USDD is a fully decentralized over-collateralization stablecoin.
- Shasta TestNet: TVMZYcbjpjaGqmciUjzuRWzANTXfHxrRCs
- Nile TestNet: TFT7sNiNDGZcqL7z7dwXUPpxrx1Ewk8iGL
- Main Net: TPYmHEhy5n8TCEfYGqW2rPxsghSfzghPDn
USDC TRC-20 Contract Addresses
USDC is a fully collateralized US Dollar stablecoin developed by CENTRE, the open source project with Circle being the first of several forthcoming issuers.
- Shasta TestNet: TSdZwNqpHofzP6BsBKGQUWdBeJphLmF6id
- Nile TestNet: TEMVynQpntMqkPxP6wXTW2K7e4sM3cRmWz
- Main Net: TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8
Tron Blockchain
- TRON Blockchain: How to Send the USDT (TRC-20) Transacton using Python tronpy?
- How to Get Balance of TRX or USDT/USDD/USDC (TRC-20) Smart Contract Tokens on TRON Blockchain?
- Function to Return the USDT/USDD/USDC Contract Address on Tron Blockchain (Main Net, Nile, Shasta)
- How to Send/Transfer USDT/USDD/USDC on Tron Blockchain using Tronweb?
- Javascript Function to Send Trx on Tron Blockchain based on TronWeb
- How to Generate an Account on Tron Blockchain using Python SDK?
- How to Claim the Witness (Super Representative) Voting Rewards on Tron Blockchain using Node Js (Javascript)?
- Automate Freeze Balance on Tron Blockchain using NodeJs with TronWeb/TronGrid
- Python Tool of Base58 Decode Check
- TRON Blockchain: How to Check the Number of Peers the Tron Node is Connected to?
- TRON Blockchain: How to Check If a Node is synchronized and Fully Functional?
- How to Activate a TRON (TRX) Blockchain Wallet Address?
- Delayed Swap due to Numeric Underflow Bug by using Tron’s triggerSmartContract Method