LI.FI REST API offers seamless integration with the Solana blockchain through Mayan, Allbridge and Jupiter.
Mayan integration
Enables users to perform blue chip coins transfer between Solana and EVM chains supported by Mayan. This integration also supports the native USDC bridge CCTP.
We support the most popular tokens on SOL chain:
SOL, USDC, USDT, WETH, WBTC, wSOL, MSOL, DRIFT, JUP, JTO, PYTH, BSOL, BONK, HAWK, JITOSOL, JSOL, MNGO, MIMO,
Allbridge integration
Allbridge enables users to perform cost efficient stable coin transfers between Solana (USDC) and other supported Ethereum Virtual Machine (EVM) compatible chains, including ETH, POL, BSC (only USDT), OPT, AVA, ARB, and BAS.
Jupiter integration
Enables users to perform Solana swaps of wide range of tokens.
Note: We only support single step transactions per ecosystem at this point. Currently expanding to support two step transactions across the two ecosystems.
The native SOL is represented using the System Program address 11111111111111111111111111111111 when making requests to the backend. Native Solana doesn’t really have an address, so this is a representation specific to our system. Wrapped Solana should use the wSOL address So11111111111111111111111111111111111111112
In this documentation, we will explore how to use the API for Solana related requests, executing transactions, getting routes, and checking the status of transactions.
Requesting Solana specific information via the API
Chains
curl --request GET \
--url 'https://li.quest/v1/chains?chainTypes=SVM' \
--header 'accept: application/json'
Tokens
curl --request GET \--url 'https://li.quest/v1/tokens?chains=SOL&chainTypes=SVM' \--header 'accept: application/json'
Token details
curl --request GET \
--url 'https://li.quest/v1/token?chain=SOL&token=BONK' \
--header 'accept: application/json'
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 /quote 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 }}
Another request example using Mayan.
{"fromChainId": "ARB","fromAmount": "1000000000","fromTokenAddress": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",// USDC on ARB,"toChainId": "SOL","toTokenAddress": "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs",// ETH on SOL,"fromAddress": YOUR_EVM_WALLET_ADDRESS,"toAddress": YOUR_SOLANA_WALLET_ADDRESS,}
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.
Note: Li.Fuel is currenly only enabled via Allbridge
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.