Portal’s Enclave MPC API provides comprehensive cross-chain bridging and swapping capabilities through the Li.Fi integration. This guide covers getting quotes, finding routes, executing swaps and bridges, and tracking transaction status.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.
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
- Get available tokens supported by Li.Fi across chains
Prerequisites
Before using Li.Fi operations, ensure you have:- A properly initialized Portal client (see Create a client)
- An active wallet with the required token(s) on the source network (see Create a wallet)
- Li.Fi integration enabled in your Portal Dashboard (see Li.Fi Integration)
Getting a Quote
Use thePOST /api/v3/clients/me/integrations/lifi/quote endpoint to get a quote for bridging or swapping tokens across chains.
For complete API documentation, see the Client API reference.
transactionRequest object with the transaction details (from, to, value, data) that you’ll need to sign and submit.
Finding Routes
Use thePOST /api/v3/clients/me/integrations/lifi/routes endpoint to discover available routes for your cross-chain transfer.
For complete API documentation, see the Client API reference.
RECOMMENDED, CHEAPEST, or FASTEST.
Getting Route Step Details
Use thePOST /api/v3/clients/me/integrations/lifi/route-step-details endpoint to get detailed transaction information for a specific route step, including an unsigned transaction that you can then sign and submit to an RPC provider (the transactionRequest field).
For complete API documentation, see the Client API reference.
transactionRequest object with the transaction details you’ll need to sign and submit.
Getting Available Tokens
Use theGET /api/v3/clients/me/integrations/lifi/tokens endpoint to retrieve all tokens supported by Li.Fi. You can filter results by chain, chain type, minimum price, or tag.
For complete API documentation, see the Client API reference.
Executing a Swap or Bridge
After getting a quote or route step details, you’ll receive atransactionRequest object. Extract the from, to, value, and data fields to sign and submit the transaction.
Step 0: Approve the ERC-20 fromToken (if needed)
If yourfromToken is an ERC-20, the Li.Fi router cannot move it on your behalf until you grant an on-chain allowance. Skip this step when the fromToken is the chain’s native asset (its address is 0x0000000000000000000000000000000000000000).
Extract the following values from the quote response:
- chainId: the
fromChainyou sent into the quote request. - approvalAddress:
data.rawResponse.estimate.approvalAddress. - fromTokenAddress:
data.rawResponse.action.fromToken.address. - amount: the
fromAmountyou sent into the quote request, divided by10^data.rawResponse.action.fromToken.decimals(use a BigInt util for this). Pass it as a string in the token’s primary denomination (e.g."0.01"for 0.01 USDC).
transactions array. Sign each entry with the eth_sendTransaction flow shown in Step 1 before continuing on to sign the swap transaction itself.
For complete endpoint documentation, see the Client API reference.
Step 1: Sign the Transaction
Use the Enclave MPC API to sign the transaction:The
transactionRequest from Li.Fi may include gasPrice and gasLimit fields. You can remove these if you want Portal to estimate the gas for you, or include them if you want to use Li.Fi’s estimates.Step 2: Track Transaction Status
After signing and broadcasting the transaction, use theGET /api/v3/clients/me/integrations/lifi/status endpoint to track the status of your cross-chain transfer.
For complete API documentation, see the Client API reference.
Example Flow
Here’s a complete example of executing a cross-chain bridge:Best Practices
- Compare quotes/routes before signing and submitting the transaction(s) to find the best option for your use case
- Handle network errors gracefully and provide user feedback
- Monitor transaction status for cross-chain transfers, as they may take longer than single-chain transactions
- Validate user balances before initiating swaps or bridges
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)
Testnets are not supported.
Next Steps
- Learn about signing Ethereum transactions
- Explore sending tokens
- Check out the Client API Li.Fi endpoints