EN
  • English
  • Русский
  • ქართულიsoon
  • Українськаsoon
  • Shqipsoon
  • Azərbaycancasoon
  • Türkçesoon
Get in touch
Crypto exchangersCrypto security

TRON Node for an Exchange: Verify USDT Without Outside APIs

TRON node for a crypto exchange: when you need your own, java-tron under systemd, closed ports, USDT TRC20 credited from confirmed blocks, and monitoring.

Читать на русском →

On this page

An exchange that checks incoming USDT through someone else's API depends on that API's rate limits and uptime, and a home-made check that looks at the token name credits fakes. After these steps you will have a TRON node on a server in a data center whose API only your accounting system can reach, a script that credits USDT only from confirmed blocks, only from the real contract and only once, and a Telegram alert when the node falls behind the network.

Plan

Step What we do Time
1 Decide whether you need your own node 10 min
2 Rent a server 1 day
3 Install java-tron 30 min
4 Run it under systemd as a dedicated user 15 min
5 Close the ports: only P2P is open to the internet 15 min
6 Wait for sync and check several hours or more
7 Install the USDT crediting script 40 min
8 Set up lag and disk monitoring 20 min
9 Prepare for updates and a fallback 15 min

What real breaches have shown

  • Exposed JSON-RPC on Ethereum nodes (2018, about $20 million according to Qihoo 360 Netlab): attackers scanned the internet for nodes with port 8545 open and drained wallets that were unlocked on the node itself.
  • Fake tokens named USDT (see the guide How to verify USDT TRC20): a system that looks at the name instead of the contract credits the fake.

What follows from this:

  1. Exposed node APIs are found by scanning → only P2P is open to the internet, the API is reachable only by the accounting system (step 5).
  2. Funds get stolen from a node when keys live on it → no wallet keys on the node, it only reads the blockchain (steps 4, 9).
  3. A fake token passes a name check → credit only by contract address (step 7).
  4. An unconfirmed block can be rolled back → credit only from confirmed (solidity) blocks (step 7).
  5. The same transfer gets credited twice when the script restarts → the transaction hash is unique in the credits database (step 7).
  6. The node silently falls behind and the cash desk "doesn't see" transfers → lag monitoring (step 8).
  7. A node on an old version drops off the network after a mandatory upgrade → subscribe to releases (step 9).
  8. A tampered release file → verify the checksum before running it (step 3).

Step 1. Decide whether you need your own node

Situation What to choose
Up to a dozen transfers a day, a cashier checks them manually TronScan, following a written procedure (guide on verifying USDT)
Dozens of transfers, you need a "check" button in the accounting system a provider API (TronGrid and similar) with a key — the script from the same guide
Hundreds of transfers, separate addresses per client, you can't depend on someone else's rate limits and uptime your own node — this guide

Your own node also means maintenance: mandatory network upgrades several times a year, disk space, monitoring. If nobody can take care of it, use a paid API with a key and a backup provider.

Done when: the decision is written down; if it is "own node," someone is responsible for maintaining it.

Step 2. Rent a server

How. java-tron requirements for a FullNode according to the official documentation:

Minimum Recommended
CPU 8 cores 16 cores
Memory 16 GB 32 GB
Disk 3 TB SSD 3.5 TB SSD or more
Bandwidth 100 Mbps 100 Mbps
  • A dedicated server or a cloud instance in a data center, not in the office: you need stable network and power, and a server in the office gets carried off in a robbery.
  • Disk — SSD or NVMe: on an HDD the node can't keep up with the network.
  • If you don't need the full history — Lite FullNode: according to the documentation it stores the current state, the genesis block and the last 65,536 blocks. That is enough for crediting new deposits. Limitations: history before the snapshot is unavailable, and some APIs are disabled (they can be enabled with node.openHistoryQueryWhenLiteFN = true, but that won't bring old blocks back). It needs less disk at the start than a full node, but the database then grows at the same rate — prune it periodically with the Lite FullNode Pruning Tool from the documentation.

Done when: you have a server running Ubuntu 24.04, with at least the minimum specs and SSH key access.

Step 3. Install java-tron

How.

  1. Java: on x86_64 java-tron supports only JDK 8, on arm64 — only JDK 17.
sudo apt update && sudo apt install -y openjdk-8-jre-headless jq python3
java -version        # should be 1.8

If the openjdk-8 package isn't in the repository, use JDK 8 from a vendor (Temurin, Zulu).

  1. User and directories:
sudo useradd --system --create-home --home-dir /opt/tron --shell /usr/sbin/nologin tron
sudo -u tron mkdir -p /opt/tron/output-directory
  1. FullNode.jar and config.conf (main_net_config.conf) — only from the official release on GitHub (tronprotocol/java-tron → Releases). Compare the checksum with the one listed in the release:
sha256sum /opt/tron/FullNode.jar
  1. To speed things up — a data snapshot from the Public Backup Data section of the official documentation (the Backup & Restore page): it lists the official servers with snapshots for FullNode and Lite FullNode. Snapshots come in LevelDB and RocksDB — take the same engine as storage.db.engine in your config.conf: the data is not compatible, and arm64 supports only RocksDB. A full snapshot is larger than 3 TB, so download it straight to the server. If a checksum is published next to the archive, verify it. Extract it into /opt/tron/output-directory before the first start.

Done when: java -version shows 1.8, and the FullNode.jar checksum matches the release.

Step 4. Run it under systemd as a dedicated user

How. The file /etc/systemd/system/java-tron.service:

[Unit]
Description=java-tron FullNode
After=network-online.target
Wants=network-online.target

[Service]
User=tron
WorkingDirectory=/opt/tron
ExecStart=/usr/bin/java -Xmx24g -jar /opt/tron/FullNode.jar -c /opt/tron/config.conf -d /opt/tron/output-directory
Restart=on-failure
NoNewPrivileges=true
ProtectSystem=full
PrivateTmp=true
LimitNOFILE=500000

[Install]
WantedBy=multi-user.target

-Xmx — roughly three quarters of the server's memory (24g for 32 GB).

sudo systemctl daemon-reload && sudo systemctl enable --now java-tron
sudo -u tron tail -f /opt/tron/logs/tron.log

Don't keep wallet keys on the node server: the node only reads the blockchain.

Done when: systemctl status java-tron shows active (running), and block numbers keep growing in the log.

Step 5. Close the ports: only P2P is open to the internet

Why: the node's HTTP API has no built-in authentication — an open port 8090 means everyone can use your node.

How.

  1. Check the ports in your config.conf (defaults):
Service Parameter in config.conf Port Who can reach it
P2P node.listen.port 18888 the internet
HTTP API node.http.fullNodePort 8090 accounting system only
HTTP API for confirmed data node.http.solidityPort 8091 accounting system only
gRPC node.rpc.port 50051 closed
gRPC for confirmed data node.rpc.solidityPort 50061 closed
JSON-RPC node.jsonrpc.httpFullNodeEnable 8545 disabled (false)
  1. Firewall:
sudo ufw default deny incoming
sudo ufw allow 18888/tcp comment "TRON P2P"
sudo ufw allow 18888/udp comment "TRON P2P discovery"
sudo ufw allow from <accounting_system_IP> to any port 8090,8091 proto tcp comment "API only for accounting"
sudo ufw allow from <admin_or_VPN_IP> to any port 22 proto tcp
sudo ufw enable

If the accounting system is elsewhere with a changing IP, connect it to the node over WireGuard and allow 8090/8091 only from the tunnel address.

Check — from a mobile connection:

nmap -Pn -p 18888,8090,8091,50051,50061,8545 <node_IP>

Only 18888 is open; the rest are filtered.

Done when: the API responds only to the accounting system.

Step 6. Wait for sync and check

How. From the accounting system server:

curl -s -X POST http://<node>:8090/wallet/getnowblock | jq '.block_header.raw_data.number'
curl -s -X POST http://<node>:8091/walletsolidity/getnowblock | jq '.block_header.raw_data.number'

Compare the first number with the latest block on tronscan.org: while the gap is more than a hundred, the node is still catching up. The confirmed (second) number trails the latest one by dozens of blocks — that is expected.

Done when: the node is no more than a few blocks behind TronScan. Write down how long the sync took — you will need it when replacing the server.

Step 7. Install the USDT crediting script

Why: to credit only confirmed transfers, only from the real USDT contract, only to your addresses and only once.

How it works. The script reads confirmed blocks in order, takes the transaction event logs from each one and looks for a Transfer event from the USDT contract (TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t, in hex — a614f803b6fd780986a42c78ec9c7f77e6ded13c) where the recipient is your address. Each hash is written to the database once.

  1. A dedicated user and the list of your addresses — /opt/credit/addresses.txt, one per line:
sudo useradd --system --create-home --home-dir /opt/credit --shell /usr/sbin/nologin credit
sudo touch /var/log/credit.log && sudo chown credit /var/log/credit.log
sudo -u credit nano /opt/credit/addresses.txt
  1. /opt/credit/credit.py:
# credit.py — credit USDT TRC20 from confirmed blocks of your own node
import json, sqlite3, hashlib, urllib.request

NODE = "http://<node>:8091"
USDT = "a614f803b6fd780986a42c78ec9c7f77e6ded13c"      # TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t
TRANSFER = "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"

def b58_to_hex(addr):                                   # T... -> 20 bytes in hex
    n = 0
    for ch in addr:
        n = n * 58 + B58.index(ch)
    raw = n.to_bytes(25, "big")
    assert hashlib.sha256(hashlib.sha256(raw[:21]).digest()).digest()[:4] == raw[21:], addr
    return raw[1:21].hex()

def post(path, body=None):
    req = urllib.request.Request(NODE + path, json.dumps(body or {}).encode(), {"Content-Type": "application/json"})
    return json.load(urllib.request.urlopen(req, timeout=30))

ours = {b58_to_hex(a.strip()): a.strip() for a in open("/opt/credit/addresses.txt") if a.strip()}
db = sqlite3.connect("/opt/credit/credit.db")
db.execute("CREATE TABLE IF NOT EXISTS credits (txid TEXT PRIMARY KEY, block INTEGER, to_addr TEXT, usdt REAL)")
db.execute("CREATE TABLE IF NOT EXISTS state (k TEXT PRIMARY KEY, v INTEGER)")
row = db.execute("SELECT v FROM state WHERE k='last'").fetchone()
solid = post("/walletsolidity/getnowblock")["block_header"]["raw_data"]["number"]
last = row[0] if row else solid - 1

for num in range(last + 1, solid + 1):
    for info in post("/walletsolidity/gettransactioninfobyblocknum", {"num": num}) or []:
        if info.get("receipt", {}).get("result") != "SUCCESS":
            continue
        for log in info.get("log", []):
            t = log.get("topics", [])
            if log.get("address") == USDT and len(t) == 3 and t[0] == TRANSFER and t[2][-40:] in ours:
                usdt = int(log["data"], 16) / 1_000_000
                cur = db.execute("INSERT OR IGNORE INTO credits VALUES (?,?,?,?)",
                                 (info["id"], num, ours[t[2][-40:]], usdt))
                if cur.rowcount:
                    print(f"CREDIT {usdt} USDT to {ours[t[2][-40:]]}, tx {info['id']}, block {num}")
    db.execute("INSERT OR REPLACE INTO state VALUES ('last', ?)", (num,))
    db.commit()

Replace the print line with a call to your accounting system: credit against the client's order and record the hash in the transaction log (guide on the AML log).

  1. Run it every minute:
echo "* * * * * credit flock -n /tmp/credit.lock python3 /opt/credit/credit.py >> /var/log/credit.log 2>&1" | sudo tee /etc/cron.d/credit

flock prevents a second copy from starting until the first one finishes.

Check (on the Nile network, with a test node):

Action Expected
Send 1 test USDT to your address within 1–2 minutes the log shows "CREDIT 1.0 USDT"
Send a fake token named USDT nothing
Send USDT to someone else's address nothing
Restart the script no second credit

On Nile the test USDT has its own contract: TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf, in hex — eca9bc828a3005b9a3b909f2cc5c2a54794de05f. Put it into USDT for the duration of the test, then switch back to the mainnet address.

Done when: all four rows match.

Step 8. Set up lag and disk monitoring

How. /opt/credit/watch.sh on the accounting system server:

#!/bin/bash
BOT="<bot_token>"; CHAT="<chat_id>"; NODE="http://<node>:8090"
alert() { curl -s -X POST "https://api.telegram.org/bot$BOT/sendMessage" -d chat_id="$CHAT" --data-urlencode text="$1" >/dev/null; }

OURS=$(curl -s -m 10 -X POST "$NODE/wallet/getnowblock" | jq -r '.block_header.raw_data.number // 0')
NET=$(curl -s -m 10 -X POST https://api.trongrid.io/wallet/getnowblock | jq -r '.block_header.raw_data.number // 0')
[ "$OURS" = "0" ] && { alert "TRON NODE is not responding"; exit; }
LAG=$((NET - OURS))
[ "$LAG" -gt 100 ] && alert "TRON NODE is $LAG blocks behind (~$((LAG * 3 / 60)) min)"
STALE=$(( $(date +%s) - $(stat -c %Y /var/log/credit.log) ))
[ "$STALE" -gt 600 ] && alert "Crediting script hasn't written to its log for $((STALE / 60)) min"

A lag of 100 blocks is about 5 minutes. On the node server — an hourly disk check:

echo '0 * * * * root [ $(df --output=pcent /opt/tron | tail -1 | tr -dc 0-9) -gt 85 ] && curl -s -X POST "https://api.telegram.org/bot<token>/sendMessage" -d chat_id=<chat_id> -d text="TRON node disk is more than 85% full"' | sudo tee /etc/cron.d/tron-disk

And watch.sh every 5 minutes: */5 * * * * root /opt/credit/watch.sh.

Check: stop the node (sudo systemctl stop java-tron) — within 5 minutes you get "not responding"; start it again.

Done when: the node-stopped alert has arrived.

Step 9. Prepare for updates and a fallback

How.

  1. Updates. Subscribe to releases: GitHub tronprotocol/java-tron → Watch → Custom → Releases. Mandatory network upgrades come out several times a year; a node on an old version falls behind. Order: read the release notes → stop the node → replace FullNode.jar (verify the checksum) → start it → run the check from step 6.
  2. Fallback. If the node goes down, the cash desk keeps working: the cashier checks deposits following the procedure from the guide on verifying USDT, or the accounting system temporarily switches to a provider API.
  3. Wallet keys — not on the node and not on the accounting system server with an open API: a separate signing host or hardware wallets (guide on storing USDT).

Done when: the release subscription is on, and the fallback procedure is written into the business continuity plan (guide on the plan).

Checklist

# What to check How to confirm ☐
1.1 The decision is written down the documents contain the option chosen from the step 1 table and the reason ☐
1.2 The node has an owner and a backup person ask both who updates the node and where alerts go — they give the same answer ☐
2.1 Server meets the minimum nproc — 8 or more; free -g — 16 or more; df -h /opt/tron — at least the space required for FullNode or Lite FullNode ☐
2.2 Disk is SSD or NVMe lsblk -d -o NAME,ROTA — the disk holding /opt/tron has 0 in the ROTA column ☐
2.3 Server is in a data center, key-only login the server is not in the office; ssh -o PubkeyAuthentication=no <user>@<IP> — "Permission denied (publickey)" ☐
3.1 Correct Java version java -version — 1.8 on x86_64 or 17 on arm64 ☐
3.2 FullNode.jar from the official release sha256sum /opt/tron/FullNode.jar matches the checksum on the tronprotocol/java-tron release page ☐
3.3 Snapshot uses the same database engine the snapshot's engine matches storage.db.engine in config.conf ☐
4.1 The node starts on its own systemctl is-enabled java-tron — enabled; systemctl status java-tron — active (running) ☐
4.2 The node doesn't run as root ps -o user= -C java — tron ☐
4.3 No wallet keys on the node server ask the admin where the keys are — the right answer is "on a separate signing host or in a hardware wallet" ☐
5.1 Only P2P is open to the outside the nmap from step 5 over a mobile connection — only 18888 is open ☐
5.2 The API is reachable from the accounting system from the accounting system server, getnowblock on 8090 and 8091 returns a block number ☐
5.3 JSON-RPC is disabled grep httpFullNodeEnable /opt/tron/config.conf — false ☐
6.1 The node has caught up with the network the number from getnowblock differs from the latest block on tronscan.org by no more than a few blocks ☐
6.2 Sync time is recorded the node documentation has the date and duration of the sync ☐
7.1 The script uses the mainnet contract grep '^USDT' /opt/credit/credit.py — a614f803…, not the Nile test contract ☐
7.2 All four Nile checks passed the step 7 check table matched on all four rows ☐
7.3 The script runs every minute ls -l /var/log/credit.log — modification time no older than a couple of minutes ☐
7.4 No double credits sqlite3 /opt/credit/credit.db "SELECT txid FROM credits GROUP BY txid HAVING COUNT(*)>1" — empty ☐
8.1 Stopping the node triggers an alert sudo systemctl stop java-tron — within 5 minutes "TRON NODE is not responding" arrives; start the node again ☐
8.2 Disk usage is monitored /etc/cron.d/tron-disk is in place; df -h /opt/tron is currently below 85% ☐
8.3 A stopped crediting script gets noticed watch.sh is in cron every 5 minutes; with the script stopped, "Crediting script hasn't written…" arrives after 10 minutes ☐
9.1 Release subscription is on on GitHub, tronprotocol/java-tron is set to Watch → Custom → Releases; an email about the latest release has arrived ☐
9.2 The node runs the latest version the FullNode.jar checksum matches the latest release, not an older one ☐
9.3 The fallback procedure is written down and the cash desk knows it the continuity plan covers what to do if the node stops; the cashier can explain it without prompting ☐

Questions

Can I use TronGrid instead of my own node?

Yes, for most exchanges that's a reasonable option: with an API key, error handling and a backup provider.

Do I need a node for every asset?

One per network: for USDT on TRON — a TRON node, for USDT on other networks — nodes for those networks or their APIs.

How much disk space does a TRON node need?

According to the official documentation, a FullNode needs a 3 TB SSD or more, 3.5 TB or more recommended, and the database keeps growing. A Lite FullNode takes less at the start but grows at the same rate, so it gets pruned periodically (step 2).

Is a Lite FullNode enough for an exchange?

For crediting new deposits — yes. If you need to look up a client's old transfers (a dispute, a request from an inspector), it has no history before the snapshot — look such transfers up on TronScan.

How long does a node take to sync?

With a snapshot from the official documentation — several hours or more after the snapshot is downloaded and extracted. From scratch, according to the same documentation, sync takes a significant amount of time, so start from a snapshot (step 3) and record how long it took (step 6).

Can I run a TRON node in Docker?

Yes, the project has an official image, tronprotocol/java-tron. But ports published by Docker bypass ufw rules (as the Docker documentation states), so publish only 18888 to the outside, bind the API to 127.0.0.1 or the address of the tunnel to the accounting system, and verify the result with the scan from step 5.

Why credit only from confirmed blocks — isn't that slower?

An unconfirmed block can be rolled back, and a transfer credited from it will disappear. A confirmed block trails the latest one by dozens of blocks — in the step 7 check that's 1–2 minutes before crediting.

The node was down for several hours. Will transfers from that period be lost?

No. The script stores the number of the last processed block and, once the node catches up, reads the missed blocks in order. While the node is down, the cash desk works by the fallback procedure (step 9).

Can I send USDT to clients through my own node?

Yes: a signed transaction can be broadcast to the network through the node's API. Sign it on a separate host or a hardware wallet — there must be no keys on the node or on the accounting system server (step 9).

A client sent USDT on another network, or a different token. What will the script do?

Nothing: it credits only the Transfer event of the real USDT contract on TRON to your addresses. Handle such transfers manually, following your USDT verification procedure.

What happens if I skip a mandatory java-tron upgrade?

A node on an old version falls behind the network, the cash desk stops "seeing" transfers, and the step 8 monitoring sends a lag alert. Upgrade following the order in step 9.


Note: Hardware and JDK requirements are per the official java-tron documentation as of the check date.

Sources

  1. TRON Docs — Deploying java-tron (hardware requirements, JDK, startup)
  2. TRON Docs — Lite FullNode
  3. TRON Docs — Backup & Restore (Public Backup Data: FullNode and Lite FullNode snapshots)
  4. Nile TronScan — test USDT (TetherToken) on the Nile network
  5. Docker Hub — tronprotocol/java-tron (official image)
  6. Docker Docs — Packet filtering and firewalls (Docker and ufw)
↑