跳到正文
DEV Community· Veriql Team·· 45 分鐘前AI 評分57

如何用 Node.js 檢查 USDT 或 USDC 地址是否被列入黑名單(Ethereum、Tron,無需依賴套件)

How to check if an address is blacklisted on USDT or USDC (Node.js, Ethereum and Tron, no dependencies)

AI 導讀

Veriql Team 提供 Node.js 範例,示範如何以合約讀取檢查 Ethereum 上 USDT、USDC,以及 Tron 上 USDT 地址的凍結狀態;讀取結果為 1 即代表地址被凍結,不能轉出該代幣。

正文

Tether and Circle keep their freeze lists inside the token contracts, so you can check any address with one read call and no API key. On Ethereum, call isBlackListed(address) on USDT or isBlacklisted(address) on USDC (note the lowercase "l"). On Tron, call getBlackListStatus(address) on the USDT contract through TronGrid's triggerconstantcontract. A result of 1 means frozen: that address can't send the token, and transfers out of it revert.

The code below runs on Node 18 or newer with no packages. Every snippet was run against public endpoints on 27 Nov 2026 before publishing.

Quick reference

Token / chain Contract Read function Selector Freeze events
USDT, Ethereum 0xdAC17F958D2ee523a2206206994597C13D831ec7 isBlackListed(address) or getBlackListStatus(address) 0xe47d6060 / 0x59bf1abe AddedBlackList, RemovedBlackList, DestroyedBlackFunds
USDC, Ethereum 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 (proxy) isBlacklisted(address) 0xfe575a87 Blacklisted, UnBlacklisted
USDT, Tron TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t getBlackListStatus(address) via TronGrid AddedBlackList, RemovedBlackList

The spelling difference is the most common bug: isBlacklisted on USDT or isBlackListed on USDC is a different selector, and the call reverts (we tried both mix-ups: execution reverted).

Ethereum: one eth_call per token

A read is a plain JSON-RPC eth_call: the 4-byte selector followed by the address left-padded to 32 bytes.

const ETH_RPC = "https://ethereum-rpc.publicnode.com"; // any Ethereum JSON-RPC URL
const USDT_ETH = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
const USDC_ETH = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";

async function rpc(method, params) {
  const res = await fetch(ETH_RPC, {
    method: "POST",
    headers: { "content-type": "application/json" },
    body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
  });
  const j = await res.json();
  if (j.error) throw new Error(`${method}: ${j.error.message}`);
  return j.result;
}

const word = (addr) => addr.toLowerCase().replace(/^0x/, "").padStart(64, "0");

async function readFlag(token, selector, address) {
  const out = await rpc("eth_call", [{ to: token, data: selector + word(address) }, "latest"]);
  return BigInt(out) === 1n;
}

// USDT: isBlackListed(address) -> 0xe47d6060
// USDC: isBlacklisted(address) -> 0xfe575a87 (USDC is a proxy; calling the proxy address is fine)
const usdtFrozenOnEthereum = (a) => readFlag(USDT_ETH, "0xe47d6060", a);
const usdcFrozenOnEthereum = (a) => readFlag(USDC_ETH, "0xfe575a87", a);

A known true to test with: Circle has blacklisted the USDC contract's own address in USDC, which is why approving or sending USDC to the token contract fails with Blacklistable: account is blacklisted.

$ node freeze-check.mjs 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
{ usdt: false, usdc: true }
$ node freeze-check.mjs 0x1111111111111111111111111111111111111111
{ usdt: false, usdc: false }

Tron: triggerconstantcontract, with two traps

On Tron the call looks different. TronGrid's /wallet/triggerconstantcontract takes the function signature as a string and the ABI-encoded parameter as hex. Trap one: the parameter must be the 20-byte hex form of the address, not the T... string, so you have to base58check-decode it. Trap two: owner_address is the caller of the read; passing a fixed, existing account (here the USDT contract itself) avoids depending on whether the queried address has ever been activated.

import { createHash } from "node:crypto";

const TRONGRID = "https://api.trongrid.io";
const USDT_TRON = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t";
const B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
const sha256 = (b) => createHash("sha256").update(b).digest();

// "T..." -> 20-byte hex, with the checksum verified
function tronToHex20(address) {
  let n = 0n;
  for (const c of address) {
    const i = B58.indexOf(c);
    if (i < 0) throw new Error("not a base58 address");
    n = n * 58n + BigInt(i);
  }
  const bytes = Buffer.from(n.toString(16).padStart(50, "0"), "hex"); // 21 bytes + 4 checksum
  const payload = bytes.subarray(0, 21);
  const ok = payload[0] === 0x41 && sha256(sha256(payload)).subarray(0, 4).equals(bytes.subarray(21));
  if (!ok) throw new Error("invalid Tron address");
  return payload.subarray(1).toString("hex");
}

async function usdtFrozenOnTron(address) {
  const res = await fetch(`${TRONGRID}/wallet/triggerconstantcontract`, {
    method: "POST",
    headers: { "content-type": "application/json" }, // add "TRON-PRO-API-KEY" for higher limits
    body: JSON.stringify({
      owner_address: USDT_TRON, // any existing account works as the caller of a read
      contract_address: USDT_TRON,
      function_selector: "getBlackListStatus(address)",
      parameter: tronToHex20(address).padStart(64, "0"),
      visible: true,
    }),
  });
  const j = await res.json();
  if (!j.result?.result) throw new Error("TronGrid: " + JSON.stringify(j).slice(0, 200));
  return BigInt("0x" + j.constant_result[0]) === 1n;
}

Without an API key, TronGrid allows a small burst and then answers with a rate-limit error instead of a result, which is why the function throws rather than returning false on a bad response. Treating an error as "not frozen" is the bug to avoid here.

A tiny CLI wrapper so you can run it as node freeze-check.mjs <address>:

const addr = process.argv[2];
if (/^0x[0-9a-fA-F]{40}$/.test(addr)) {
  console.log({ usdt: await usdtFrozenOnEthereum(addr), usdc: await usdcFrozenOnEthereum(addr) });
} else if (/^T[1-9A-HJ-NP-Za-km-z]{33}$/.test(addr)) {
  console.log({ usdt: await usdtFrozenOnTron(addr) });
} else {
  console.error("pass a 0x... or T... address");
  process.exit(1);
}

When was it frozen? Reading the events

The status call tells you the state now. For "since when" (or "was it ever frozen and released"), read the events. The three contracts differ in a way that matters:

  • USDC (Ethereum): Blacklisted(address indexed _account) and UnBlacklisted(address indexed _account). The address is indexed, so you can filter by it directly in eth_getLogs.
  • USDT (Ethereum): AddedBlackList(address _user) and RemovedBlackList(address _user). The address is not indexed. It sits in the log's data, so you cannot filter by it in the query; you fetch the events and filter them yourself.
  • USDT (Tron): same events, served by TronGrid's events API, which pages through the whole history.

USDC, filtered by address:

const BLACKLISTED = "0xffa4e6181777692565cf28528fc88fd1516ea86b56da075235fa575af6a4b855";
const UNBLACKLISTED = "0x117e3210bb9aa7d9baff172026820255c6f6c30ba8999d1c2fd88e2848137c4e";

const usdcLogs = (address, fromBlock, toBlock) =>
  rpc("eth_getLogs", [{
    address: USDC_ETH,
    topics: [[BLACKLISTED, UNBLACKLISTED], "0x" + word(address)], // either event, this address
    fromBlock: "0x" + fromBlock.toString(16),
    toBlock: "0x" + toBlock.toString(16),
  }]);

USDT on Ethereum, scanning recent blocks in chunks and decoding data:

const ADDED_BLACKLIST = "0x42e160154868087d6bfdc0ca23d96a1c1cfa32f1b72ba9ba27b69b98a0d819dc";

async function recentUsdtFreezes(blocks = 3000, chunk = 1000) {
  const latest = BigInt(await rpc("eth_blockNumber", []));
  const found = [];
  for (let to = latest; to > latest - BigInt(blocks); to -= BigInt(chunk)) {
    const from = to - BigInt(chunk) + 1n;
    const logs = await rpc("eth_getLogs", [{
      address: USDT_ETH,
      topics: [ADDED_BLACKLIST],
      fromBlock: "0x" + from.toString(16),
      toBlock: "0x" + to.toString(16),
    }]);
    for (const l of logs) found.push({ user: "0x" + l.data.slice(26), block: parseInt(l.blockNumber, 16), tx: l.transactionHash });
  }
  return found;
}

Free public RPCs limit eth_getLogs hard. When we tested, one endpoint accepted about 1,000 recent blocks per call but refused wide or old ranges without a token, and two others capped a call at 100 and 50 blocks. For full Ethereum history, use a provider with archive access or an indexer, and keep the chunking.

Tron, full history for one address:

const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

// Every AddedBlackList / RemovedBlackList event for one Tron address.
// TronGrid returns the user as 20-byte hex ("0x..."), so compare hex, not "T..." strings.
async function tronFreezeHistory(address, maxPages = 50) {
  const want = "0x" + tronToHex20(address);
  const hits = [];
  for (const event_name of ["AddedBlackList", "RemovedBlackList"]) {
    let url = `${TRONGRID}/v1/contracts/${USDT_TRON}/events?event_name=${event_name}&limit=200&order_by=block_timestamp,desc`;
    for (let page = 0; url && page < maxPages; page++) {
      const j = await (await fetch(url)).json();
      if (!j.success) throw new Error("TronGrid: " + JSON.stringify(j).slice(0, 200));
      for (const e of j.data) {
        if (e.result._user.toLowerCase() === want) {
          hits.push({ event: event_name, at: new Date(e.block_timestamp).toISOString(), tx: e.transaction_id });
        }
      }
      url = j.meta?.links?.next; // undefined on the last page
      await sleep(400); // stay under the keyless rate limit
    }
  }
  return hits.sort((a, b) => a.at.localeCompare(b.at));
}

For scale: on 27 Nov 2026 the full AddedBlackList history on Tron was 9,421 events, 48 pages of 200, going back to June 2020. That is about 50 requests per event type for a full scan, so if you check many addresses, page through once, build your own set, and keep it updated from the newest page.

Things that bite in production

  • false is a snapshot. An address can be frozen between your check and your transfer. Check right before you send, not when the payee was onboarded, and re-check on retries.
  • An issuer freeze is not an exchange freeze. This list only covers Tether's and Circle's contract-level blacklist. An exchange or custodian can lock an account without anything changing on chain.
  • Frozen funds can be destroyed. On Ethereum USDT, DestroyedBlackFunds(address, uint256) records Tether burning a frozen balance. If you see it in an address's history, the balance you saw earlier is gone.
  • Don't treat errors as "clear". Rate limits, timeouts and reverts all have to surface as "unknown", never as "not frozen".
  • Other chains, other contracts. USDT and USDC exist on many chains with different addresses, and on some chains a different freeze mechanism. Look up the contract for each chain you support instead of reusing the Ethereum selectors blindly.

If you'd rather not run it yourself

Disclosure: we run Veriql, which sells these checks, so weigh this section accordingly.

For a one-off lookup, the free USDT freeze checker does the same reads for Tether and Circle on Tron and Ethereum (USDC also on Base, Polygon and Arbitrum), plus the balance and fee for a send.

For code and AI agents, the same checks are paid per call over x402 with no account or key: /api/v1/payee ($0.01) returns do_not_pay, no_known_risk or incomplete for a recipient, and /api/v1/freeze-watch ($1.00) watches up to 100 Ethereum or Tron addresses for 30 days and sends a signed webhook when Tether freezes one. Details: veriql.app/api.

Everything above works without us, though; the contracts are public, and that's the point.


This article was drafted with AI assistance. All code was run against live public endpoints on 27 Nov 2026 and the results above are from those runs.

來源:DEV Community · dev.to