Skip to main content
The Chain Service provides functions for fetching and caching supported blockchain networks. It uses the LI.FI API with built-in caching (30 minute TTL) and fallback support.

Exports


Functions

getChains(cache?)

Fetch all supported source chains for bridging.
Returns: ChainsResponse Throws: ChainFetchError if API fails and no cache available. Example:

getDestinationChains()

Get destination chains (currently only HyperEVM).
Returns: Array containing the HyperEVM chain. Example:

getChainsByRoutes(toChainId?, cache?)

Get chains that have valid bridge routes to a specific destination.
Example:

getChainById(chainId, cache?)

Get a specific chain by its ID.
Example:

invalidateChainCache(cache?)

Manually invalidate the chain cache.
Example:

createChainCache()

Factory function to create a new cache instance.
Example:

Types

ChainsResponse

Chain

ChainFetchError


Constants

HYPEREVM_CHAIN

Pre-defined HyperEVM chain data.

ChainCache Class

The ChainCache class manages caching for chain data with a 30-minute TTL.

Methods

Example Usage