# Tron and Sui

Swap TRX, USDT on Tron or SUI with BTC, both ways. It is for wallets and routers whose users hold coins on Tron or Sui. No settler runs on either chain, so each swap is two legs between the user's own wallets, with LI.FI carrying the leg on the Tron or Sui side and ETH on Base between the legs. The Maxy app swaps these coins the same way. Tron and Sui are offered while their LI.FI leg answers: when it does not, `GET /pairs` lists those pairs under `unavailable` (the reason and when to ask again) and a price or quote answers `503 service_unavailable` with `Retry-After`; `/health` reads degraded meanwhile (`lifiLegs`).

## How the two legs run

| Direction | Leg 1 | Leg 2 | Route |
| --- | --- | --- | --- |
| Tron or Sui coin to BTC | LI.FI bridges the coin into ETH on Base, paid to the user's EVM wallet | That wallet opens the BTC escrow on Base, as on [Buy BTC](https://maxy.co/docs/buy-btc) | `evm-btc-bridge` |
| BTC to a Tron or Sui coin | The settler pays ETH on Base to the user's EVM wallet, as on [Sell BTC](https://maxy.co/docs/sell-btc) | That wallet sends LI.FI's bridge to the user's Tron or Sui address | `btc-evm` |

Three wallets of the user's own take part: the Bitcoin wallet, the EVM wallet named by `evmAddress`, and the Tron or Sui wallet. Maxy holds nothing between the legs. Buying BTC, the EVM wallet signs the BTC order before any coin moves; a leg that fails is returned by LI.FI to the wallet that paid it, and the signed order lapses unused.

## Quote

Pass `evmAddress` beside `fromAddress` and `toAddress`. Coins are written `TRX`, `USDT on tron`, `SUI`, or by address: a Tron token by its `T…` address, a Sui coin by its type (`0x2::sui::SUI`).

```sh
curl -s "https://openapi.maxy.co/v1/quote?from=USDT%20on%20tron&to=BTC&amount=100\
&fromAddress=TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE&toAddress=bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq\
&evmAddress=0x5Ad7CF25B2e4C9ad0dcA1C0b62abd3e1f8C1b2A4" -H "x-maxy-key: $MAXY_API_KEY"
```

Selling Tron USDT, the steps are `intent` (EIP-712, the EVM wallet), `order`, `approve` (USDT only, when the allowance is short), `bridge` and `escrow`. Buying a Tron or Sui coin, they are `intent`, `order`, `deposit` and `bridge`.

## Send the Tron or Sui leg

`POST /orders` answers the leg's transactions, checked before they reach you:

- **Tron:** `transactions` holds `rawDataHex`, `txID` and `expiration` for the approval (when needed) and the leg, each with a fresh reference block. The call is decoded and checked: one contract call from your Tron address to the Tron LI.FI Diamond, paying your EVM wallet on Base. Sign `txID` with the Tron wallet (TronWeb: `trx.sign`) and broadcast it, from the wallet or with `POST https://openapi.maxy.co/x/tron/wallet/broadcasttransaction` (TronGrid's shape: the signed transaction as JSON).
- **Sui:** `transactions` holds `txBytes`, LI.FI's transaction as Sui wallets sign it. Sign and execute it with the wallet, or send it through `https://openapi.maxy.co/x/sui`, Sui's GraphQL API (`POST`, a GraphQL body).

Then `POST /orders/submit` with `bridgeTxHash` (the Tron transaction id or the Sui digest), follow `GET /orders/{id}/bridge` until `ready: true`, send the escrow from the EVM wallet, and `POST /orders/submit` with its `txHash`.

Selling BTC for a Tron or Sui coin, the `bridge` step's path answers LI.FI's transaction for the EVM wallet once the settler has paid it, checked the same way: the LI.FI Diamond on Base, your address on Tron or Sui as receiver, no destination call.

## With the SDK and the command line

```ts
import { createMaxyClient, evmSignerFromPrivateKey, tronSignerFromKey } from 'maxy-labs';

const maxy = createMaxyClient();
const done = await maxy.swap.execute({
  from: 'USDT on tron', to: 'BTC', amount: '100',
  evm: evmSignerFromPrivateKey(process.env.EVM_KEY!), tron: tronSignerFromKey(process.env.TRON_KEY!),
  btcAddress: 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq',
});
```

`suiSignerFromKey` takes a Sui key (`suiprivkey1…`). A browser wallet plugs in as a `TronSigner` or `SuiSigner`: an address and a `signTransaction`. From a terminal: `maxy price 100 usdt tron`, `maxy swap 0.002 btc to trx tron --to-address T… --yes`.

## Errors on this page

| Code | When |
| --- | --- |
| `invalid_input` | `evmAddress` is missing, or an address is not a Tron or Sui one |
| `service_unavailable` | 503, retryable: a refused Tron or Sui leg. `Retry-After` says when; the pair moves to `/pairs` `unavailable` until it answers again |
| `idempotency_in_progress` | 409, retryable: a request with the same `Idempotency-Key` is still running |
| `unsupported_route` | LI.FI has no route for this size right now; nothing was sent |
| `verification_failed` | LI.FI's transaction failed a check; nothing was signed |

---
Source: https://maxy.co/docs/tron-and-sui (Maxy Docs › User flows and examples › Swaps)
