> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Bridge & Swap with Li.Fi

> Learn how to bridge and swap tokens across multiple chains using Portal's React Native SDK with Li.Fi integration.

Portal's React Native SDK provides comprehensive cross-chain bridging and swapping capabilities through the `portal.trading.lifi` API. This guide covers getting quotes, finding routes, executing swaps and bridges, and tracking transaction status.

## Overview

The Li.Fi functionality allows you to:

* **Get quotes** for bridging or swapping tokens across chains
* **Find routes** to discover the best paths for your cross-chain transfers
* **Execute swaps and bridges** by signing and submitting transactions
* **Track transaction status** for cross-chain transfers

<Note>
  **Supported Chains:** Li.Fi integration currently supports EVM-compatible chains (Ethereum, Base, Arbitrum, Polygon, etc.) and Solana. Other non-EVM chains may not be supported for Li.Fi operations.
</Note>

## Prerequisites

Before using Li.Fi operations, ensure you have:

* A properly initialized Portal client
* An active wallet with the required token(s) on the source network (see [Create a wallet](./create-a-wallet))
* Li.Fi integration enabled in your Portal Dashboard (see [Li.Fi Integration](../../../integrations/Trading/lifi))

## Getting a Quote

```ts theme={null}
import { LifiQuoteRequest } from '@portal-hq/trading'

async function getQuote(portal: Portal) {
  const addresses = await portal.addresses
  const fromAddress = addresses?.eip155

  if (!fromAddress) {
    throw new Error('No EVM address found')
  }

const request: LifiQuoteRequest = {
  fromChain: 'eip155:8453',
  toChain: 'eip155:42161',
  // Amount in wei (1 ETH = 1e18 wei)
  // 1_000_000_000_000 wei = 0.000001 ETH
  fromAmount: '1000000000000',
  fromToken: 'ETH',
  toToken: 'USDC',
  fromAddress,
}


  const response = await portal.trading.lifi.getQuote(request)
  const quote = response.data?.rawResponse

  if (!quote) return

  console.log('To amount:', quote.estimate?.toAmount)

  if (quote.transactionRequest) {
    await executeTransaction(
      portal,
      quote.transactionRequest,
      request.fromChain
    )
  }
}
```

***

## Finding Routes

```ts theme={null}
import { LifiRoutesRequest } from '@portal-hq/trading'

async function getRoutes(portal: Portal) {
  const addresses = await portal.addresses
  const fromAddress = addresses?.eip155

  if (!fromAddress) {
    throw new Error('No EVM address found')
  }

const request: LifiRoutesRequest = {
  fromChainId: 'eip155:8453',
  toChainId: 'eip155:42161',
  fromTokenAddress: 'ETH',
  toTokenAddress: 'USDC',

  // Amount in wei (1 ETH = 1e18 wei)
  // 1_000_000_000_000 wei = 0.000001 ETH
  fromAmount: '1000000000000',

  fromAddress,
}

  const response = await portal.trading.lifi.getRoutes(request)
  const routes = response.data?.rawResponse?.routes ?? []

  const route =
    routes.find(r => r.tags?.includes('RECOMMENDED')) ?? routes[0]

  if (!route) return

  await processRouteSteps(portal, route.steps, request.fromChainId)
}
```

***

## Getting Route Step Details

```ts theme={null}
import { LifiStep, LifiStepTransactionRequest } from '@portal-hq/trading'

async function getRouteStep(
  portal: Portal,
  step: LifiStep
): Promise<LifiStep | null> {
  const response = await portal.trading.lifi.getRouteStep(
    step as LifiStepTransactionRequest
  )

  return response.data?.rawResponse ?? null
}
```

***

## Executing Transactions

```ts theme={null}
import { ETHTransactionParam } from '@portal-hq/provider'
import { LifiTransactionRequest } from '@portal-hq/trading'

async function executeTransaction(
  portal: Portal,
  transactionRequest: LifiTransactionRequest,
  chainId: string
) {
  const ethTx: ETHTransactionParam = {
    from: transactionRequest.from,
    to: transactionRequest.to,
    value: transactionRequest.value ?? '0x0',
    data: transactionRequest.data,
  }

  const response = await portal.request(
    'eth_sendTransaction',
    [ethTx],
    chainId
  )

  console.log('Tx hash:', response.result)
}

```

> **Note**
> `LifiTransactionRequest` may include `gasLimit` and `gasPrice`.
> You can omit these fields to let Portal estimate gas automatically,
> or include them if you prefer to use Li.Fi's suggested values.

***

## Processing Multi-Step Routes

```ts theme={null}
async function processRouteSteps(
  portal: Portal,
  steps: LifiStep[],
  chainId: string
) {
  for (const step of steps) {
    const stepWithTx = await getRouteStep(portal, step)
    if (!stepWithTx?.transactionRequest) {
      throw new Error('Missing transactionRequest')
    }

    await executeTransaction(
      portal,
      stepWithTx.transactionRequest,
      chainId
    )
  }
}
```

***

## Tracking Transaction Status

```ts theme={null}
import { LifiStatusRequest } from '@portal-hq/trading'

async function getStatus(
  portal: Portal,
  txHash: string,
  fromChain: string
) {
  const request: LifiStatusRequest = {
    txHash,
    fromChain,
  }

  const response = await portal.trading.lifi.getStatus(request)
  const status = response.data?.rawResponse

  console.log('Status:', status?.status)
}
```

***

## Polling Until Completion

```ts theme={null}
async function pollUntilDone(
  portal: Portal,
  txHash: string,
  fromChain: string
) {
  while (true) {
    const response = await portal.trading.lifi.getStatus({
      txHash,
      fromChain,
    })

    const status = response.data?.rawResponse?.status
    if (status === 'DONE') return true
    if (status === 'FAILED') return false

    await new Promise(r => setTimeout(r, 2000))
  }
}
```

***

## Supported Networks

Portal's Li.Fi integration supports the following mainnet networks:

* Monad (`eip155:143`)
* Ethereum (`eip155:1`)
* Optimism (`eip155:10`)
* BSC (`eip155:56`)
* Gnosis (`eip155:100`)
* Unichain (`eip155:130`)
* Polygon (`eip155:137`)
* Sonic (`eip155:146`)
* Mantle (`eip155:5000`)
* Base (`eip155:8453`)
* Arbitrum (`eip155:42161`)
* Celo (`eip155:42220`)
* Avalanche (`eip155:43114`)
* Linea (`eip155:59144`)
* Berachain (`eip155:80094`)
* Katana (`eip155:747474`)
* Solana (`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`)
* Bitcoin (`bip122:000000000019d6689c085ae165831e93-p2wpkh`)

For the complete list of networks Li.Fi supports across its ecosystem, refer to the [Li.Fi documentation](https://docs.li.fi). If you need a chain that isn't listed above, contact Portal support.

<Note>
  **Testnets are not supported.**
</Note>

## Next Steps

* Learn about [signing Ethereum transactions](./sign-a-transaction)
* Explore [sending tokens](./send-tokens)
* Check out the [Client API Li.Fi endpoints](../../../apis/client/api-reference-link)
