How to Send USDT TRC-20 with TronWeb 6: A Minimal Tested Script
Send USDT TRC-20 with TronWeb 6.x: simulate, set feeLimit, build with triggerSmartContract, sign locally, broadcast. A script dry-run tested on Nov 23, 2026.
- Category
- Guides
- Published
- Reading time
- 7 min

To send USDT TRC-20 with TronWeb 6.x, call transactionBuilder.triggerSmartContract on the USDT contract TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t with the function transfer(address,uint256) and the amount in 6-decimal units, sign the result with trx.sign, and send it with trx.sendRawTransaction. Before building, simulate the same call to catch a revert and to learn the energy it needs, and set feeLimit from that number.
Below is a minimal script in five steps. We ran it with TronWeb 6.5.1 on Nov 23, 2026 through signing, with a private key generated on the spot; the broadcast step is in the code but was not executed.
What you need before the first line
- Node.js 18 or newer and the
tronwebpackage, version 6.x. We used 6.5.1. - A node endpoint. The script uses the public TronGrid host
https://api.trongrid.io. For production traffic use your own node or provider credentials; TronWeb adds any request headers you pass in theheadersoption of the constructor. - A private key outside the code, read from an environment variable or a secrets store. TronWeb signs locally; the key is never sent to the node.
- Resources on the sending address: USDT to send, energy or TRX for the contract call, and bandwidth or TRX for the transaction bytes. A never-used address cannot send at all: java-tron rejects a transaction whose owner account does not exist on chain.
Amounts are integers in the token’s smallest unit. USDT has 6 decimals, so 1.5 USDT is 1500000; the details are in USDT decimals and the minimum amount.
The script
Illustrative example; run on Node.js 22.23.2 (in our copy the import line loads the same TronWeb 6.5.1 through createRequire, nothing else differs):
// illustrative example: simulate, build and sign a USDT TRC-20 transfer with TronWeb 6.x
import { TronWeb } from 'tronweb';
const USDT = 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t';
const DRY_RUN = true; // true: sign but never broadcast
const tronWeb = new TronWeb({ fullHost: 'https://api.trongrid.io' });
const pause = () => new Promise((ok) => setTimeout(ok, 5000)); // keep public API calls apart
async function sendUsdt(privateKey, to, usdt) {
const from = tronWeb.address.fromPrivateKey(privateKey);
const amount = (BigInt(Math.round(usdt * 100)) * 10000n).toString(); // USDT has 6 decimals
const params = [{ type: 'address', value: to }, { type: 'uint256', value: amount }];
// 1. Simulate: TronWeb throws if the call would revert (no USDT, bad recipient...)
let energy;
try {
const sim = await tronWeb.transactionBuilder.triggerConstantContract(
USDT, 'transfer(address,uint256)', {}, params, from);
energy = sim.energy_used;
} catch (err) {
if (!DRY_RUN) throw err;
console.log('simulation failed:', err.message ?? err);
energy = 130285; // dry run: plan for a new recipient
}
await pause();
// 2. Fee limit: the most TRX (in SUN) the network may burn for this call
const chain = await tronWeb.trx.getChainParameters();
const energyFee = chain.find((p) => p.key === 'getEnergyFee').value; // SUN per unit
const feeLimit = Math.ceil(energy * energyFee * 1.2);
await pause();
// 3. Build on a node; TronWeb checks the answer matches what we asked for
const { transaction } = await tronWeb.transactionBuilder.triggerSmartContract(
USDT, 'transfer(address,uint256)', { feeLimit }, params, from);
const raw = transaction.raw_data;
console.log('built', { txID: transaction.txID, feeLimit, rawBytes: transaction.raw_data_hex.length / 2,
validForSec: (raw.expiration - raw.timestamp) / 1000 });
// 4. Sign locally: the key never leaves this process
const signed = await tronWeb.trx.sign(transaction, privateKey);
console.log('signed', { sameTxID: signed.txID === transaction.txID, sigBytes: signed.signature[0].length / 2 });
// 5. Broadcast, then look the txID up (skipped in a dry run)
if (DRY_RUN) return signed;
const res = await tronWeb.trx.sendRawTransaction(signed);
console.log('broadcast', res.result, res.txid);
return signed;
}
const key = process.env.TRON_PRIVATE_KEY ?? (await TronWeb.createAccount()).privateKey;
await sendUsdt(key, process.argv[2], 1.5);
We started it with no TRON_PRIVATE_KEY, so TronWeb.createAccount() made a fresh local key, and with a public recipient address as the argument.
What each step does, with our dry run
| Step | Call | What we got on Nov 23, 2026 |
|---|---|---|
| 1. Simulate | wallet/triggerconstantcontract |
REVERT opcode executed: the new address holds no USDT |
| 2. Fee limit | wallet/getchainparameters |
getEnergyFee 100 SUN, so 130,285 × 100 × 1.2 = 15,634,200 SUN, about 15.63 TRX |
| 3. Build | wallet/triggersmartcontract |
txID 0493afe4…04614, raw_data 211 bytes, valid for 58.7 seconds |
| 4. Sign | local, no network | one 65-byte signature, txID unchanged |
| 5. Broadcast | wallet/broadcasttransaction |
not run |
Step 1. The simulation runs the call on the node without creating a transaction. In TronWeb 6.5.1, triggerConstantContract throws when the node reports a revert, which is what happened for our empty address; a funded sender gets back energy_used instead. As of Nov 23, 2026 a standard transfer used 64,285 energy and a transfer to an address with no USDT 130,285. How to read the estimate, and when it disagrees with the receipt, is in estimating energy with triggerconstantcontract.
Step 2. feeLimit caps the TRX the network may burn for energy; set too tight, the call fails and still costs TRX, as explained in the OUT OF ENERGY error. If you pass nothing, TronWeb 6.5.1 uses its built-in default of 150,000,000 SUN (150 TRX); the chain accepts at most 15,000 TRX.
Step 3. The node builds the unsigned transaction and fills in the reference block, expiration and timestamp. TronWeb then rebuilds the transaction from your own arguments and throws Invalid transaction if the node’s version differs, so a node cannot slip in another recipient or amount. Our raw_data came out at 211 bytes and the expiration about 60 seconds after the newest block; what expiration means is in can you cancel a USDT transaction.
Step 4. trx.sign checks that the key belongs to owner_address, recomputes the txID from raw_data_hex, and adds the signature. The txID is the same before and after, so you can save it before sending; why is explained in how a TRON transaction ID is calculated.
Step 5. sendRawTransaction posts the signed JSON to wallet/broadcasttransaction. A result: true answer means the node accepted it into its pool, not that the transfer succeeded. Look the txID up with gettransactioninfobyid until a receipt appears and check that receipt.result is SUCCESS; what the other results mean is in USDT transaction statuses.

Errors you may see
| Message | Where | Usual cause |
|---|---|---|
REVERT opcode executed |
step 1 | The sender has less USDT than the amount, or the call is invalid |
Private key does not match address in transaction |
step 4 | The key is not the key of from |
Invalid transaction |
step 3 or 4 | The transaction does not match your arguments or its txID |
| An error that the owner account does not exist | step 5 | The sending address was never activated |
OUT_OF_ENERGY in the receipt |
after step 5 | feeLimit too low for the energy the sender lacked |
| Expiration error | step 5 | Broadcast more than about a minute after building; build again |
Where the energy comes from
Without energy on the sending address, the network burns TRX for the call: 6.43 TRX for a standard transfer at 100 SUN per unit. Renting 65,000 energy for 1 hour costs 1.95 TRX at 30 SUN on Dec 3, 2026; the rate changes, the exact price is shown in the service before you pay, and reference prices are on the pricing page. For a script like this one, energy can be ordered from code before step 3: the flow is described in the TRON energy rental API and on the API page.

A checklist before you switch DRY_RUN off
- Run the dry run with your real sending address and a small amount; the simulation should return energy instead of a revert.
- Check the resources of the sending address and add energy or TRX for the shortfall.
- Keep the key in the environment, never in the source or in logs.
- Store the txID from step 3 before step 5, so a timeout never turns into a second payment.
- Confirm by receipt, not by the broadcast answer. To decode the USDT
Transferevent from that receipt, see decoding a USDT transfer event.
FAQ
Can I use tronWeb.contract().at() and transfer().send() instead?
Yes. In TronWeb 6.5.1 send() builds, signs and broadcasts in one call. The explicit steps above let you simulate first and keep the txID before broadcasting.
Do I need TRX on the address if it has energy? Usually a little: the 345 bytes of a USDT transfer are paid from bandwidth, and when free bandwidth is used up the network burns about 0.345 TRX.
Does the amount change the energy? No. The same function runs for 1 USDT and for 100,000 USDT. What changes the energy is whether the recipient already holds USDT.
Is a dry run with a random key safe? Yes. The key is created locally, the address holds nothing, and nothing is broadcast; the node only builds an unsigned transaction.