If you accept TRON addresses from users (a withdrawal form, a payout config, an admin panel), a regex like ^T[1-9A-HJ-NP-Za-km-z]{33}$ is the first thing everyone writes. It is also the least useful part. A TRON address carries its own checksum, and the network will tell you things about it that no regex can: whether it is a contract, and whether it exists on chain at all.
This post builds the check in three layers, each one run against the public TronGrid node on Dec 2, 2026:
- offline: Base58Check decoding with nothing but
node:crypto; - node-side:
wallet/validateaddress; - on-chain:
wallet/getaccount, to tell a person's wallet from a contract or from an address nobody has ever used.
What is inside the 34 characters
Decode a TRON address from Base58 and you get exactly 25 bytes:
41 1 byte version prefix, always 0x41 a614f803b6fd780986a42c78ec9c7f77e6ded13c 20 bytes account ID xxxxxxxx 4 bytes checksum The checksum is the first 4 bytes of SHA-256 applied twice to the first 21 bytes. The 20-byte account ID is derived from the public key (the accounts page has the details), and the example above is the USDT contract, TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t.
Because every address starts with the byte 0x41, the Base58 text always starts with T. Running the encoder over the two extremes shows the whole range: 20 zero bytes encode to T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb, 20 bytes of ff to TZJozAg1ruapycCicgz31GxvYJ1FraLjZa. And because Base58 treats a and A as different digits, addresses are case-sensitive: lowercasing one destroys it.
You will meet the same address in three spellings. Node APIs return 41... hex unless you pass visible: true. Event logs and ABI parameters carry only the 20 bytes, left-padded to 32. Users see Base58. Store at least the hex next to the Base58 form; matching logs against your records gets much simpler.
Layer 1: offline, with Node built-ins
SHA-256 is all the checksum needs, so there is no reason to pull a dependency in just for this. The function below returns null for a good address and a short reason otherwise, which is handy for form errors. Tested on Node.js 22.23.2:
// Node 18+ built-ins only: offline TRON address check and hex <-> Base58 conversion const { createHash } = require('node:crypto'); const B58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; const checksum = (buf) => createHash('sha256').update(createHash('sha256').update(buf).digest()).digest().subarray(0, 4); function fromBase58(text) { let n = 0n; for (const ch of text) { const digit = B58.indexOf(ch); if (digit < 0) return null; // 0, O, I, l and anything non-Base58 n = n * 58n + BigInt(digit); } const hex = n.toString(16); return hex.length > 50 ? null : Buffer.from(hex.padStart(50, '0'), 'hex'); } function toBase58(hex21) { // '41' + 40 hex chars -> T... const payload = Buffer.from(hex21, 'hex'); let n = BigInt('0x' + Buffer.concat([payload, checksum(payload)]).toString('hex')); let out = ''; while (n > 0n) { out = B58[Number(n % 58n)] + out; n /= 58n; } return out; } // returns null when the address is fine, otherwise a reason you can show to the user function tronAddressError(input) { if (input.length !== 34) return 'length'; if (input[0] !== 'T') return 'prefix'; const bytes = fromBase58(input); if (!bytes) return 'encoding'; if (bytes[0] !== 0x41) return 'version byte'; if (!checksum(bytes.subarray(0, 21)).equals(bytes.subarray(21))) return 'checksum'; return null; } module.exports = { tronAddressError, fromBase58, toBase58 }; What it says about a few inputs:
| Input | Result |
|---|---|
TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t | null (valid) |
same, last t → T | checksum |
| same, last character dropped | length |
same, 6 → letter O | encoding |
| same, all lowercase | prefix |
toBase58('41a614f803b6fd780986a42c78ec9c7f77e6ded13c') gives back the USDT address, so the pair also works as a hex/Base58 converter without TronWeb.
Is the checksum actually worth it?
We tested it the brute-force way. Starting from the USDT address, we replaced each character in positions 2 to 34 with every other Base58 digit: 1,881 one-character typos. The function rejected all 1,881: 1,847 on the checksum, 34 because the change pushed the first byte away from 0x41. Then we swapped every pair of neighbouring characters that differ: 32 variants, all rejected (31 on the checksum, 1 on the version byte).
That matches the theory. A random string survives a 4-byte checksum about once in 2^32, roughly 4.3 billion tries. For a human typo, that is as good as certain.
Layer 2: ask the node
wallet/validateaddress does the same job server-side and accepts several encodings. Answers from TronGrid on Dec 2, 2026:
| Input | result | message |
|---|---|---|
TR7NHq...Lj6t | true | Base58check format |
| same with a broken checksum | false | Invalid address |
41a614f8...d13c (42 hex chars) | true | Hex string format |
0xa614f8...d13c (EVM style) | false | Invalid address |
a614f8...d13c (40 hex, no 41) | false | Length error |
| the USDT address lowercased | false | Illegal character l at 22 |
Two things to wire correctly. Every one of these came back with HTTP 200, so do not wait for an error status: branch on the result boolean. And treat message as a debugging hint, not a contract; the reference says it may be absent.
Which layer to use? The offline one costs nothing and works without network access; the node call is fine when you already talk to a node. Neither one knows anything about the chain.
Layer 3: what actually lives at the address
A valid checksum proves the string was copied intact. It does not prove that a person controls it. To show that, we generated an account ID from 20 random bytes and encoded it: TFUzvufuC7qqUPwwjwYW6YnvGoMJcTAfTq. Both the offline check and validateaddress accept it. Nobody has a key for it.
wallet/getaccount separates the cases that matter for a payout form. Here is a small classifier on top of the Layer 1 function:
const { tronAddressError } = require('./validate.js'); async function getAccount(address) { const res = await fetch('https://api.trongrid.io/wallet/getaccount', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ address, visible: true }), }); return res.json(); } // what a payout form should know before it accepts a recipient async function classifyRecipient(address) { const formatError = tronAddressError(address.trim()); if (formatError) return { verdict: 'reject', reason: formatError }; const account = await getAccount(address.trim()); if (Object.keys(account).length === 0) return { verdict: 'warn', reason: 'not activated on chain' }; if (account.type === 'Contract') return { verdict: 'confirm', reason: 'this is a smart contract' }; return { verdict: 'ok', createdAt: new Date(account.create_time).toISOString().slice(0, 10) }; } Run against four inputs, one request every few seconds (output condensed):
TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t confirm this is a smart contract T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb ok created 2018-12-30 TFUzvufuC7qqUPwwjwYW6YnvGoMJcTAfTq warn not activated on chain TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6T reject checksum Why these branches:
-
{}means the account does not exist yet. The address is valid but has never been activated. It can still receive funds, and the first TRX sent to it activates it: as of Oct 13, 2026 the sender pays 1.1 TRX for that. Show a warning rather than an error; how activation works and why USDT alone does not trigger it is in our guide to activating a TRON address. -
"type": "Contract"means code lives there. Regular accounts simply omittype, because the default value is not serialized. The most common way users hit this is by pasting the USDT token address itself as the recipient. If you need the ABI or the deployer,wallet/getcontractreturns them for contracts and{}for everything else. - "ok" is not the same as "safe".
T9yD14...is the all-zero account ID. It is activated, holds about 774,000 TRX as of Dec 2, 2026, and passes every check here. Validation tells you the address is well-formed and what kind of account it is, nothing about who is behind it.
What none of the layers can catch
Look-alike addresses. Address poisoning works precisely because the fake address is valid. Right after a user pays someone, a bot sends them dust from an address that shares the first and last characters of the real recipient, hoping it gets copied from history later. In one case we traced on the blog, 22 of 23 such dust transfers matched the last two characters of the address just paid. The only defence in a UI is to show the full address before confirming, not a shortened TR7N...j6t. The mechanics are described in address poisoning on TRON.
Cross-network confusion. An EVM 0x... address fails validation, which is good. But if your code "helpfully" converts it by prepending 41, the result is a valid TRON address that the user never meant. Never convert user input between networks.
A routine for a payout form
- Trim whitespace. Never change the case.
- Run the offline check; on failure, show the reason.
- Store the hex form alongside the Base58 one.
- Call
getaccount: warn on{}, ask for confirmation on"type": "Contract". - Echo the full address back before the user confirms.
All of these are read calls: none of them creates a transaction or costs energy or TRX.
I work on UsdtPull, a TRON energy rental service, and this post is based on our blog article about TRON address validation.
