@t402/wdk-tron-gasfree
v2.9.0
Published
Gas-free USDT payments on TRON with Tether WDK
Downloads
70
Maintainers
Readme
@t402/wdk-tron-gasfree
Gas-free TRC-20 USDT payments on TRON using the WDK's relay.
Installation
pnpm add @t402/wdk-tron-gasfreeUsage
import { createWdkTronGasfreeClient } from '@t402/wdk-tron-gasfree';
const client = await createWdkTronGasfreeClient({
wdkInstance: myTronGasfreeWallet, // from @tetherto/wdk-wallet-tron-gasfree
});
// Check balance
const balance = await client.getBalance();
console.log('USDT:', client.getFormattedBalance(balance));
// Execute gas-free payment (no TRX needed for bandwidth/energy)
const result = await client.pay({
to: 'TAddress...',
amount: 1000000n, // 1 USDT (6 decimals)
});
console.log('Transaction ID:', result.txId);
console.log('Gas-free:', result.sponsored); // trueAPI
createWdkTronGasfreeClient(config)
Creates a WdkTronGasfreeClient from a WdkTronGasfreeConfig.
WdkTronGasfreeClient
| Method | Returns | Description |
|--------|---------|-------------|
| pay(params) | Promise<GasfreePaymentResult> | Execute a gas-free TRC-20 transfer |
| getBalance(token?) | Promise<bigint> | Get USDT or USDT0 balance |
| getFormattedBalance(balance, decimals?) | string | Human-readable balance (e.g. "1.5") |
| getAddress() | Promise<string> | Wallet address |
| canSponsor(params) | Promise<boolean> | Check if gas-free transfer is available |
Adapter Layer
The package auto-detects the upstream @tetherto/wdk-wallet-tron-gasfree interface and adapts alternative method signatures:
adaptTronGasfreeWallet(instance)-- Wrap any compatible WDK instanceisUpstreamTronGasfreeWallet(instance)-- Type guard for upstream interfacetryLoadUpstreamModule()-- Dynamically load the upstream module
Supported Tokens
| Token | Network | Address |
|-------|---------|---------|
| USDT | Mainnet | TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t |
| USDT0 | Mainnet | TKiUqMmnCBPqRfREwNExNYKG2KQqj5Gd2m |
| USDT | Shasta | TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs |
Constants
TRON_USDT_ADDRESS/TRON_USDT0_ADDRESS-- Mainnet token addressesTRON_USDT_TESTNET_ADDRESS-- Shasta testnet USDTTRON_USDT_DECIMALS-- 6TOKEN_ADDRESSES-- Lookup by network and token typegetTokenAddress(token, network?)-- Resolve token type to address
Related Packages
@t402/wdk-- Core WDK wallet toolkit@t402/wdk-ton-gasless-- Gasless TON payments@t402/core-- Protocol types and utilities
License
Apache-2.0
Trademark Notice
T402 is an independent open-source project. It is not affiliated with, endorsed by, sponsored by, or in any way officially connected with Tether Operations Limited, Tether Holdings, or any of their affiliates.
"Tether", "USDT", "USDT0", "USDC", and other token names and trademarks referenced are the property of their respective owners and are used nominatively to describe token interoperability or to reference public open-source products (Apache 2.0). Compatibility with Tether's open-source WDK is at the user's option and does not represent a formal partnership.
