How to Decode a USDT TRC-20 Transfer Event From Raw TRON Data
Decode a USDT transfer on TRON: input data a9059cbb, the Transfer log from gettransactioninfobyid, TronGrid decoded events and a tested Node.js script.
- Category
- Guides
- Published
- Reading time
- 7 min

A USDT transfer on TRON can be read in two places. The input in raw_data.contract[0].parameter.value.data is a9059cbb, then the recipient and the amount as two 32-byte words: what the sender asked for. The Transfer log from gettransactioninfobyid has topics[0] = ddf252ad...b3ef, topics[1] and topics[2] = sender and recipient, and data = the amount in units of 0.000001 USDT: what actually happened. To show an address, take its last 20 bytes, put 41 in front and encode in Base58Check.
Below, one real transfer decoded by hand, a decoder in plain Node.js, TronGrid’s ready-made view, and two transactions where input and log tell different stories.
Where the transfer is recorded
| Place | Call | What it holds | Can you trust it for crediting? |
|---|---|---|---|
| Input data | wallet/gettransactionbyid |
function selector and arguments as signed | no: it is a request |
ret[0].contractRet |
same | SUCCESS, OUT_OF_ENERGY, REVERT… | needed, not enough on its own |
| Event log | wallet/gettransactioninfobyid |
one entry per event the contract emitted | yes, filtered by contract |
| Decoded events | TronGrid /v1/transactions/{id}/events |
the same log, already decoded | yes, if the indexer is trusted |
Our example is 6cfb8f53…b336, a plain USDT transfer in block 88,160,500 (Nov 20, 2026, 06:19:51 UTC). We read it through the public TronGrid API.
Decoding the input data
The data field of the transaction, split into its parts:
| Bytes | Hex | Meaning |
|---|---|---|
| 0 to 3 | a9059cbb |
selector of transfer(address,uint256) |
| 4 to 35 | 000...0095dca292f5d69fecd796ebfe31322d116e242172 |
recipient: 12 zero bytes, then 20 address bytes |
| 36 to 67 | 000...00144f47a0 |
amount: 0x144f47a0 = 340,740,000 |
USDT has 6 decimals, so 340,740,000 units are 340.74 USDT. The recipient’s 20 bytes with 41 in front give 4195dca2...2172, which is TPdbzd…ZorjP in Base58. The checksum step is the same as in our TRON address validation guide.
The sender is not in data at all. It is owner_address next to it (410b35cb...3d2c), and the token is contract_address (41a614f8...d13c, the USDT contract).
Decoding the Transfer log
gettransactioninfobyid for the same hash returned a receipt with result SUCCESS, 64,285 energy and 345 bandwidth, and one log entry:
| Field | Value | Meaning |
|---|---|---|
address |
a614f803b6fd780986a42c78ec9c7f77e6ded13c |
contract that emitted the event: USDT, without the 41 |
topics[0] |
ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef |
event signature |
topics[1] |
000...000b35cb995374111effd4be67be0c762cae883d2c |
from, indexed |
topics[2] |
000...0095dca292f5d69fecd796ebfe31322d116e242172 |
to, indexed |
data |
000...00144f47a0 |
value, not indexed: 340.74 USDT |
The USDT ABI, read with wallet/getcontract, declares the event as Transfer(address indexed from, address indexed to, uint256 value). Indexed parameters go to topics, the rest to data. topics[0] is the Keccak-256 hash of Transfer(address,address,uint256).
Node.js has no Keccak-256 among its built-in hashes: crypto.getHashes() on version 22.23.2 lists sha3-256, which is the standardized SHA-3 with different padding. It gives c17a9d92...07a1 for the same string, not ddf252ad.... So store the topic as a constant, as below, or compute it with a library.
One more trap in the receipt: contractResult was 32 zero bytes. The ABI says transfer returns a bool, so a strict decoder reads “false”, yet the transfer happened and the log is there. Decide by receipt.result and the log, never by the return value.
A decoder in plain Node.js
Illustrative example; we ran it on Node.js 22.23.2 against TronGrid:
// illustrative example: decode a USDT TRC-20 transfer with Node.js 18+ built-ins only
const { createHash } = require('node:crypto');
const API = 'https://api.trongrid.io';
const USDT_HEX = 'a614f803b6fd780986a42c78ec9c7f77e6ded13c'; // TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t without 41
const TRANSFER_TOPIC = 'ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';
const ABC = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
const sha256 = (b) => createHash('sha256').update(b).digest();
function toBase58(hex20) { // 20-byte hex -> T... address
const body = Buffer.from('41' + hex20, 'hex');
const full = Buffer.concat([body, sha256(sha256(body)).subarray(0, 4)]);
let n = BigInt('0x' + full.toString('hex')), s = '';
while (n > 0n) { s = ABC[Number(n % 58n)] + s; n /= 58n; }
return s;
}
const usdt = (hex) => { const v = BigInt('0x' + hex); return `${v / 1000000n}.${String(v % 1000000n).padStart(6, '0')}`; };
const post = async (path, body) =>
(await fetch(API + path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) })).json();
async function decode(txid) {
const tx = await post('/wallet/gettransactionbyid', { value: txid });
const c = tx.raw_data.contract[0];
const v = c.parameter.value;
const d = v.data || '';
console.log('status', tx.ret[0].contractRet, '| contract', v.contract_address, '| selector', d.slice(0, 8));
if (v.contract_address === '41' + USDT_HEX && d.startsWith('a9059cbb')) {
console.log('input: to', toBase58(d.slice(32, 72)), 'amount', usdt(d.slice(72, 136)));
}
await new Promise((r) => setTimeout(r, 5000)); // keep public API calls apart
const info = await post('/wallet/gettransactioninfobyid', { value: txid });
const logs = (info.log || []).filter((l) => l.address === USDT_HEX && l.topics[0] === TRANSFER_TOPIC);
console.log('receipt', info.receipt?.result ?? 'none', '| USDT Transfer logs', logs.length);
for (const l of logs) {
console.log('log: from', toBase58(l.topics[1].slice(24)), 'to', toBase58(l.topics[2].slice(24)), 'amount', usdt(l.data));
}
}
decode(process.argv[2]).catch(console.error);
For our transfer it printed:
status SUCCESS | contract 41a614f803b6fd780986a42c78ec9c7f77e6ded13c | selector a9059cbb
input: to TPdbzdjNWqDLPUSfmfWVotDV3dRK5ZorjP amount 340.740000
receipt SUCCESS | USDT Transfer logs 1
log: from TAzUsw3oPMmB8nLmLZMHriWdFMUdi2LsF7 to TPdbzdjNWqDLPUSfmfWVotDV3dRK5ZorjP amount 340.740000
The amount stays a BigInt all the way: USDT values above 9,007,199,254 USDT do not fit a JavaScript number exactly, and rounding errors in crediting are worse than an extra line of code.

TronGrid’s decoded view
The events by transaction ID call returns the same log already decoded. For our hash, as of Nov 21, 2026:
| Raw log | TronGrid event | Note |
|---|---|---|
address a614f8…d13c |
contract_address TR7NHq…Lj6t |
Base58 here |
topics[0] ddf252ad… |
event_name Transfer, event with parameter names |
signature as text |
topics[1] |
result.from 0x0b35cb...3d2c |
hex with 0x, no 41 |
topics[2] |
result.to 0x95dca2...2172 |
same |
data |
result.value “340740000” |
a string, still in units |
position in log |
event_index 0 |
for deduplication |
The same values also sit under the keys "0", "1" and "2". Unconfirmed items carry _unconfirmed: true. The decoded view saves work, but it is an indexer’s interpretation; the raw log comes from the node itself. How to use these streams for incoming payments is a separate topic, covered in monitoring incoming USDT.
When input and log disagree
Two other transactions from the same block show why the log decides.
Input says yes, log says nothing. In 90f6da29…1474 the input is a regular a9059cbb call for 834,391 USDT. The decoder printed status OUT_OF_ENERGY and USDT Transfer logs 0. Nothing moved, yet the receipt still shows 345 bandwidth used by the sender. A parser that reads only the input would report a large payment that never happened. Why this error occurs is in the out-of-energy guide, and the other result codes in USDT TRC-20 transaction statuses.
Input is not a USDT call, log says two transfers. In 8f8240c1…a90d the signer called contract 4139dd12...d510 with selector 6f21b898, not the USDT contract. The receipt holds three log entries: two Transfer events emitted by USDT (1.5 and 12 USDT, both from the same address) and one event of the calling contract with its own signature fe6f7f85.... The decoder skips the input check and prints both USDT transfers. Filtering by log.address is what keeps the third entry out.

Decoding checklist
- Fetch the receipt with
gettransactioninfobyid; stop unlessreceipt.resultis SUCCESS. - Loop over every log entry, not only the first.
- Keep entries where
addressisa614f803...d13candtopics[0]isddf252ad...b3ef. - Decode
topics[1]andtopics[2]from their last 40 hex characters,41in front, Base58Check. - Read the amount from
dataas a big integer; divide by 1,000,000 only for display. - Store transaction ID plus log index as the deduplication key.
If your system then sends USDT onward, energy planning and ordering from code are on the API page.
FAQ
Why do topics have 24 extra zeros before the address? Topics are 32-byte words. An address takes 20 bytes, so it is padded with 12 zero bytes (24 hex characters) on the left.
Is the event signature the same as on Ethereum?
Yes. TRON’s virtual machine uses the same Keccak-256 event topics, so ddf252ad... marks a Transfer on both. Only the address encoding differs.
Can I decode the transfer without gettransactioninfobyid? You can read the input, but it shows the request, not the result. Without the receipt you cannot tell a delivered transfer from a failed one.
Does reading transactions through TronGrid cost energy? No. These are read calls; they create no transaction.