Skip to main content
This page shows you how to convert USDT amounts on BOT Chain correctly. USDT uses 6 decimals, and treating it like an 18-decimal token is one of the most common bugs in token code.
Everything on this page uses testnet (chain 968). Get free test tokens from the faucet.

How decimals work

Tokens store amounts as whole numbers called base units. The decimals value says where the decimal point goes when you show the amount to a person. The USDT addresses are in Contract addresses: 0xaBabc7Ddc03e501d190C676BF3d92ef0e6e87a3C on mainnet and 0x75edC9335175Fc0552D51D48439F229c10420fe3 on testnet.
Testnet also has another token named “USDT” with 18 decimals. Always identify tokens by address, never by symbol.

Prerequisites

  • Node.js 22 or later.

Steps

1

Create the project

2

Convert amounts

usdt-decimals.ts
  • parseUnits(text, decimals) turns what a user typed into base units. Use it before every contract call.
  • formatUnits(value, decimals) turns base units into text. Use it before you show a value.
  • Both work with bigint, so you don’t lose precision.
3

Run it

Verify it worked

Output
The last line shows the bug: an 18-decimal conversion asks for a trillion times more USDT than you meant. The transaction would fail for lack of balance, or worse, succeed against a large allowance.

Common mistakes

  • Hardcoding 18. parseEther and formatEther assume 18 decimals. Never use them for USDT.
  • Using JavaScript numbers. Number(balance) / 1e6 loses precision for large values. Keep amounts as bigint and format at the end.
  • Mixing tokens in math. A V2 quote for WBOT to USDT returns USDT base units (6 decimals) for an input in WBOT base units (18 decimals). Format each side with its own decimals.
  • Assuming USDT has the same decimals everywhere. USDT on BNB Smart Chain has 18 decimals. Ethereum and Tron use 6. Convert when you bridge. See Bridge overview.
  • Trusting the symbol. Anyone can deploy a token called USDT. Check the address.

Troubleshooting

You formatted a 6-decimal value with 18 decimals. Read decimals from the token and pass it to formatUnits.
Check the amount you passed. If it came from parseEther, it’s 10^12 times too large for USDT.

Next steps

Wrap BOT

Turn native BOT into the WBOT token.

Swap on BDEX V2

Swap WBOT for USDT.
Last modified on October 2, 2026