the quote request without requesting the gas on the destination chain:
curl --request GET \
--url 'https://li.quest/v1/quote?fromChain=POL&toChain=1151111081099710&fromToken=0x2791bca1f2de4661ed88a30c99a7a9449aa84174&toToken=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&fromAddress=0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0&toAddress=S5ARSDD3ddZqqqqqb2EUE2h2F1XQHBk7bErRW1WPGe4&fromAmount=2000000&slippage=0.03' \
--header 'accept: application/json'
the routes request with the gas on the destination chain:
curl --request GET \
--url 'https://li.quest/v1/quote?fromChain=137&toChain=SOL&fromToken=0x2791bca1f2de4661ed88a30c99a7a9449aa84174&toToken=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&fromAddress=0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0&toAddress=S5ARSDD3ddZqqqqqb2EUE2h2F1XQHBk7bErRW1WPGe4&fromAmount=2000000&slippage=0.03&fromAmountForGas=284126' \
--header 'accept: application/json'
From SOL to EVM:
the quote request without requesting the gas on the destination chain:
curl --request GET \
--url 'https://li.quest/v1/quote?fromChain=1151111081099710&toChain=POL&toToken=0x2791bca1f2de4661ed88a30c99a7a9449aa84174&fromToken=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&toAddress=0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0&fromAddress=S5ARSDD3ddZqqqqqb2EUE2h2F1XQHBk7bErRW1WPGe4&fromAmount=2000000&slippage=0.03' \
--header 'accept: application/json'
the routes request with the gas on the destination chain:
curl --request GET \
--url 'https://li.quest/v1/quote?fromChain=1151111081099710&toChain=POL&toToken=0x2791bca1f2de4661ed88a30c99a7a9449aa84174&fromToken=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&toAddress=0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0&fromAddress=S5ARSDD3ddZqqqqqb2EUE2h2F1XQHBk7bErRW1WPGe4&fromAmount=2000000&slippage=0.03&fromAmountForGas=37376' \
--header 'accept: application/json'
Solana
LI.FI is live on Solana!
LI.FI REST API offers seamless integration with the Solana blockchain through Allbridge Core. This integration enables users to perform USDC and USDT transfers between Solana and other supported Ethereum Virtual Machine (EVM) compatible chains, including ETH, POL, BSC (only USDT), OPT, AVA, ARB, and BAS.
Note: currently, Solana chain supports only USDC token.
In this documentation, we will explore how to use the API for requesting quotes, executing transactions, getting routes, and checking the status of transactions.
Requesting a Quote
To request a quote for a transaction between Solana and another blockchain, you can use the provided guide. Below is an example of a request to get a quote for transferring 10 USDC from Solana to POL:
constrequest= { fromChain:'SOL', toChain:'POL', fromToken:'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',// USDC on SOL toToken:'0x2791bca1f2de4661ed88a30c99a7a9449aa84174',// USDC on POL fromAmount:'10000000', fromAddress:YOUR_SOL_WALLET_ADDRESS, toAddress:YOUR_EVM_WALLET_ADDRESS, fromAmountForGas:37376// amount in fromToken}
The key difference between EVM -> SOL and SOL -> EVM transfers is the structure of the transactionRequest. For SOL -> EVM transfers, it contains only a data parameter, which represents base64 encoded Solana transaction data:
To execute the transaction, you will need to perform several steps:
Decode your Solana private key.
Create a connection to the Solana network.
Decode the transaction data received from the /quotes response.
Deserialize the decoded transaction data into a VersionedTransaction.
Sign the transaction with your Solana keypair.
Send the transaction to the Solana network.
Confirm the transaction's status.
import solanaWeb3, { BlockheightBasedTransactionConfirmationStrategy, VersionedTransaction,} from'@solana/web3.js'import base64 from'ethers/lib/utils'import bs58 from'bs58'constkeypair=solanaWeb3.Keypair.fromSecretKey(bs58.decode(YOUR_SOLANA_PRIVATE_KEY)) // get Solana keypairconstconnection=newsolanaWeb3.Connection(RPC_PROVIDER_URL,'confirmed') // create a connectionconstdecodedTx=base64.decode(transactionRequest.data.toString()) // decode tx dataconst deserializedTx = VersionedTransaction.deserialize(decodedTx) // deserialize decoded tx data into VersionedTransaction
deserializedTx.sign([keypair]) // sign the tx with your keypairconsttxid=awaitconnection.sendTransaction(deserializedTx, { maxRetries:5, skipPreflight:true,}) // send the txawaitconnection.confirmTransaction( { signature: txid, } asBlockheightBasedTransactionConfirmationStrategy,'confirmed') // confirm the tx
Getting Routes
Routes provide the necessary information to initiate a transaction request. Here are two guides on how to request the route and execute it. Here's an example of a typical /routes request from POL to SOL:
{"fromChainId": "POL","fromAmount": "2000000","fromTokenAddress": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",// USDC on POL,"toChainId": "SOL","toTokenAddress": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",// USDC on SOL,"fromAddress": YOUR_EVM_WALLET_ADDRESS,"toAddress": YOUR_SOLANA_WALLET_ADDRESS,"fromAmountForGas": 284126,"options": {"slippage":0.03 }}
You can set the fromAmountForGas parameter in /routes or /quotes requests to receive gas on the destination chain. Please note that this value is limited by the Allbridge API, and if it exceeds the limit, the error with the suggested maximum value will be returned.
The maximum limit you can receive on the destination chain can be found by calling the Allbridge token-info endpoint. The txCostAmount.maxAmount parameter dictates the max amount that can be received in native token.
To execute the route, you need to pick one step from routes with the lifi type and make a /stepTransaction call.
Getting a Transaction to execute
To obtain transaction data for execution, you need to provide a full Step object. Typically, this object is retrieved by calling the /routes endpoint and selecting the most suitable route. Afterward, you can retrieve the transaction data for each required step using the /stepTransaction endpoint.
The response from such a call will have the same type as the /quote response.
Checking the Status of a Transaction
To check the status of a Solana transaction, you can follow the provided guide, which will help you monitor the progress and confirmation of your transaction on the Solana blockchain.