prepare_tron_trc20_approve
Build an unsigned TRC-20 approve transaction to set allowance for a spender, enabling token transfers via transferFrom. Requires exact amount; decimal auto-resolution for canonical tokens.
Instructions
Build an unsigned TRC-20 approve(spender, amount) tx — sets allowance so a third party can pull tokens via transferFrom. Primary use: authorize the LiFi Diamond on TRON (TU3ymitEKCWQFtASkEeHaPb8NfZcJtCHLt) before running prepare_tron_lifi_swap with a TRC-20 source token (LiFi's quote response assumes the approve already exists; insufficient allowance reverts the swap on-chain). Accepts ANY TRC-20 contract — not just the canonical set. Decimals are auto-resolved for canonical USDT/USDC/USDD/TUSD; for any other TRC-20 you MUST pass decimals explicitly. We REFUSE to default decimals on approve because an off-by-power-of-ten allowance silently authorizes a 10^12-fold larger spend than intended, with no UX recovery on a Ledger blind-sign flow. amount is a human decimal string ("100" = 100 tokens at the resolved decimals). "max" / unbounded approvals are NOT supported — pass exactly the amount you intend to swap. Returns a preview + opaque handle for send_transaction.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from | Yes | Base58 TRON owner address — the wallet that holds the tokens. | |
| token | Yes | Base58 TRC-20 contract address. Any TRC-20 is accepted; non-canonical tokens require `decimals`. | |
| spender | Yes | Base58 TRON address authorized to pull tokens via transferFrom. Typical use: the LiFi Diamond on TRON (TU3ymitEKCWQFtASkEeHaPb8NfZcJtCHLt) for `prepare_tron_lifi_swap` flows. | |
| amount | Yes | Allowance amount as a human-readable decimal string. Pass exactly the amount you intend to swap, NOT "max" / unbounded — TRC-20 unbounded approvals are a known griefing vector and we don't expose them by default. | |
| decimals | No | Token decimals. OPTIONAL when `token` is in the canonical TRC-20 set (USDT/USDC=6, USDD/TUSD=18 — auto-resolved). REQUIRED for any other TRC-20 contract; we refuse to guess decimals when an off-by-power-of-ten allowance could authorize a 10^12-fold larger spend than intended. | |
| feeLimitTrx | No | Optional fee-limit override in TRX. Defaults to 100 TRX (TronLink/Ledger Live standard). |