Did you know ... Search Documentation:
Pack usdt_network -- README.md

usdt_network

You copy a USDT deposit address, pick a network in your wallet and press send. If the address is a TRON address and you picked Ethereum, the wallet usually refuses. If you picked BNB Smart Chain and the address is a `0x` address that the receiver only watches on Ethereum, the wallet happily sends it and the money sits somewhere nobody is looking.

This pack does the boring check before you press send. It runs offline and never talks to a node.

?- pack_install(usdt_network).
?- use_module(library(usdt_network)).

?- address_networks("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", Ns).
Ns = [tron, solana].            % 34-char Base58 starting with T

?- address_check("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", tron, S).
S = checksum_ok.

?- address_check("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6u", tron, S).
S = checksum_bad.               % one character changed

?- send_check(ethereum, "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", V).
V = mismatch([tron, solana]).

?- send_check(polygon, "0xdAC17F958D2ee523a2206206994597C13D831ec7", V).
V = ambiguous_evm([ethereum, bnb_smart_chain, polygon, arbitrum,
                   optimism, base, avalanche_c]).

?- network_info(tron, Standard, Gas).
Standard = 'TRC-20', Gas = 'TRX'.

What it checks

FormatNetworksChecksum verified
T + 33 Base58 charsTRON (TRC-20)yes, Base58Check
`0x` + 40 hexEthereum, BNB Smart Chain, Polygon, Arbitrum, Optimism, Base, Avalanche C-Chainno (EIP-55 needs Keccak-256)
`1... / 3...` Base58Bitcoin legacy / P2SHyes, Base58Check
`bc1q...`Bitcoin SegWit v0yes, Bech32
`bc1p...`Bitcoin Taprootyes, Bech32m
32-44 Base58 charsSolana (SPL)no checksum in the format
EQ / UQ + 46 charsTONnot verified
`lnbc...`Lightning invoicenot verified

Things it cannot tell you

  • A `0x` address looks the same on every EVM chain. Only the receiver knows which chain they watch, so send_check/3 answers ambiguous_evm and you should ask, or read the deposit page again.
  • A valid checksum means the address was copied correctly. It does not mean it belongs to the person you think it does. Clipboard malware swaps whole addresses, so compare the first and last five characters by eye.
  • You need the network's own coin for the fee: TRX on TRON, ETH on Ethereum and the ETH layer 2s, BNB on BNB Smart Chain, POL on Polygon, SOL on Solana. network_info/3 lists them. An empty TRX balance is the most common reason a TRC-20 USDT transfer will not go through.

Why we wrote it

We run CryptoeSIM.io, a travel eSIM shop where you pay in BTC, ETH or USDT on TRC-20 or ERC-20. Our own checkout page says it plainly: wrong-network sends are the one thing we cannot always recover. So before you buy an eSIM with crypto, from us or from anyone else, run the deposit address through this first.

Tests

swipl -g run_tests -t halt test/test_usdt_network.pl

The tests use public, well-known addresses only: the USDT contract on TRON and Ethereum, the Bitcoin genesis address and the BIP-173 / BIP-350 vectors.

MIT licence.