LI.FI Documentation
LI.FI WebsiteAPI ReferenceHelp / FAQ / Create support ticketRequest API Key
  • 🏡Getting Started
    • ❓What is LI.FI
    • 🌟Why LI.FI?
    • 🆚LI.FI vs Aggregators/DEXs/Bridges
    • 📖LI.FI Terminology
    • ❓FAQ
    • 💡Use Cases
      • Mobile/Gaming Wallets
    • 🏹LI.FI vs. Other Aggregators
    • 🤝Partnership
    • 🌐Powered by LI.FI
  • 🔐Security First
  • ✅List: Chains, Bridges, DEX Aggregators, Solvers
  • 💲Monetization / Take Fees
  • 🔎Transaction Explorer
  • 🔏Rate Limits & API Key
  • How to get integrated by LI.FI?
    • For Bridges
    • For DEXs/Aggregators/Solvers
  • 🆘Technical FAQ
  • LI.FI PRODUCTS
    • Glacis
    • LI.FI Solver
    • LI.FI Intents System
  • LI.FI API
    • ⚙️LI.FI API
      • Transferring Tokens (Example)
      • Requesting supported Chains
      • Requesting all supported Tools
      • Requesting all known Tokens
      • Getting Token Information
      • Getting all possible Connections
      • Requesting a Quote
        • Token Transfer
        • Optimizing quote response timing
        • Cross-Chain Contract Calls
        • Possible Tool Errors
        • Testing your integration
      • Status of a Transaction
      • Requesting Analytics Data
    • ⚔️TX-Batching aka "Zaps"
    • 🏄Solana
      • Request examples
    • 🪙Bitcoin
      • Request examples
    • ⛽LI.Fuel
  • Integrate LI.FI SDK
    • 🚀LI.FI SDK Overview
    • 📦Install LI.FI SDK
    • ⚙️Configure SDK
    • 🪐Configure SDK Providers
    • 📜Request Routes/Quotes
    • 🎯Execute Routes/Quotes
    • ⛓️Chains and Tools
    • 💰Token Management
    • 🕵️Testing Integration
    • 🚗Migrate from v2 to v3
  • INTEGRATE LI.FI WIDGET
    • 🧩LI.FI Widget Overview
    • 📦Install Widget
    • 🎮Select Widget Variants
    • ⚙️Configure Widget
    • 🎨Customize Widget
    • ⚡Widget Events
    • 👛Wallet Management
    • 🌍Internationalization
    • ⚛️Compatibility with Next.js, Remix, Nuxt, etc.
    • 🛣️React Router Compatibility
    • 📖Widget API Reference
    • 🚗Migrate from v2 to v3
  • Smart Contracts
    • Overview
    • Deployments/Contract Addresses
    • Audits
  • Support & Misc.
    • API Status
    • Technical Help Desk & FAQ
    • Create a Partner Ticket
    • Discord Support
    • Telegram Support
    • Twitter
    • Github
    • Licenses
Powered by GitBook
LogoLogo

Connect with us

  • Github
  • Twitter
  • Discord
  • LinkedIn

More Information

  • Help Desk / FAQ
  • API Reference
  • Website
On this page
  • Create config
  • Parameters
  • Update SDK configuration
  • Configuration Methods

Was this helpful?

Export as PDF
  1. Integrate LI.FI SDK

Configure SDK

Get started and set up LI.FI SDK in just a few lines of code.

Create config

To get started, you need to create an initial configuration for the LI.FI SDK. This configuration contains the shared settings and data required for the proper functioning of other SDK features that developers will use. Additionally, the configuration can be updated later as needed.

import { createConfig } from '@lifi/sdk'

createConfig({
  integrator: 'Your dApp/company name',
})

Parameters

integrator (string, required)

LI.FI SDK requires an integrator option to identify partners and allows them to monitor their activity on the partner dashboard, such as the transaction volume, enabling better management and support.

Usually, the integrator option is your dApp or company name.

This string must consist only of letters, numbers, hyphens, underscores, and dots and be a maximum of 23 characters long.

apiKey (string, optional)

Unique API key for accessing LI.FI API services. Necessary for higher rate limits. Read more Rate Limits & API Key

apiUrl (string, optional)

Default: https://li.quest/v1

The base URL for the LI.FI API. This is the endpoint through which all API requests are routed. It can be changed to the staging environment to test new features, for example.

userId (string, optional)

A unique identifier for the user of your application. This can be used to track user-specific data and interactions within the LI.FI.

routeOptions (RouteOptions, optional)

Custom options for routing, applied when using getQuote, getRoutes, and getContractCallsQuote endpoints. These options can be configured once during SDK initialization or passed each time those functions are called. Read more Request Routes/Quotes

rpcUrls (RPCUrls, optional)

A mapping of chain IDs to arrays of RPC URLs. These URLs might be used for transaction execution and data retrieval.

import { createConfig, ChainId } from '@lifi/sdk'

createConfig({
  integrator: 'Your dApp/company name',
  rpcUrls: {
    [ChainId.ARB]: ['https://arbitrum-example.node.com/'],
    [ChainId.SOL]: ['https://solana-example.node.com/'],
  },
})

In a production app, it is recommended to pass through your authenticated RPC provider URL (Alchemy, Infura, Ankr, etc).

If no RPC URLs are provided, LI.FI SDK will default to public RPC providers.

chains (ExtendedChain[], optional)

Default: fetched from LI.FI API during initialization.

An array of chains that the SDK will support. Each chain must be configured with necessary details like chain ID, name, RPCs, etc. This information is used during the quote and route execution.

When createConfig is called, the SDK preloads available chains from the LI.FI API. Developers can disable chain preloading to specify the chains themselves.

preloadChains (boolean, optional)

Default: true

A flag indicating whether to preload chain configurations. By default, the SDK will load chain details during initialization.

disableVersionCheck (boolean, optional)

Default: false

A flag to disable version checking of the SDK. By default, the SDK checks its version on initialization and logs a message in the console if a new version is available, prompting the user to update the SDK.

providers (SDKProvider[], optional)

An array of provider configurations is used by the SDK. Providers are optional and only necessary if you plan to execute quotes or routes through the SDK. Read more Configure SDK Providers.

Setting up providers is not required if you are using the SDK solely to access the LI.FI API without quote/route SDK execution functionality and plan to handle the execution independently.

Read more Configure SDK Providers.

Update SDK configuration

LI.FI SDK provides various methods to manage and manipulate the SDK settings dynamically. To update the configuration, you need to import the global configuration object and use its methods.

import { config } from '@lifi/sdk';

After creating your configuration with the createConfig function, config acts as a global configuration object.

Configuration Methods

get()

Returns the current SDK configuration.

set(options: SDKConfig)

Sets the SDK configuration with the provided options.

setProviders(providers: SDKProvider[])

Sets the providers in the SDK configuration. If a provider already exists, it will be updated with the new information.

getChains()

Returns a promise that resolves to the list of configured chains. If the configuration is still loading, the promise will wait until the loading is complete.

setChains(chains: ExtendedChain[])

Sets the chains in the SDK configuration and updates chains RPC URLs. This method also clears the loading state.

getChainById(chainId: ChainId)

Returns a promise that resolves to the chain configuration for the specified chain ID. If the configuration is still loading, the promise will wait until the loading is complete.

getRPCUrls()

Returns a promise that resolves to the list of RPC URLs for the configured chains. If the configuration is still loading, the promise will wait until the loading is complete.

setRPCUrls(rpcUrls: RPCUrls)

Sets the RPC URLs for the chains in the SDK configuration. If some RPC URLs already exist for a chain, the new URLs will be appended to the existing ones.

Last updated 11 months ago

Was this helpful?

If you are interested in a dedicated API endpoint for your service, reach out via our or file an issue in our repository .

⚙️
Discord
here
🪐Configure SDK Providers