Swapping
Integrations
Javascript SDK
Get Chains

Get Chains

getChains

Returns the list of available chains or destination chains for the provided sourceChain.

getChains(sourceChain?: Chain): Promise<ChainData[]>
ParamDescriptionData type
sourceChain(optional)Chain ID that allows to filter the returned chainsChain

Example

If no sourceChain is provided, it returns an array of supported chains.

console.log(await swapSDK.getChains());

Sample Response

[
  {
    "id": "Ethereum",
    "name": "Ethereum",
    "isMainnet": true
  },
  {
    "id": "Polkadot",
    "name": "Polkadot",
    "isMainnet": true
  },
  {
    "id": "Bitcoin",
    "name": "Bitcoin",
    "isMainnet": true
  }
]

Example

If a sourceChain is provided, it returns the supported swap destination chains for that specific source chain.

import { Chains } from "@chainflip/sdk/swap";
 
console.log(await swapSDK.getChains(Chains.Polkadot));

Sample Response

[
  {
    "id": "Ethereum",
    "name": "Ethereum",
    "isMainnet": true
  },
  {
    "id": "Bitcoin",
    "name": "Bitcoin",
    "isMainnet": true
  }
]