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

[
  {
    "chain": "Ethereum",
    "evmChainId": 1,
    "isMainnet": true,
    "maxRetryDurationBlocks": 10,
    "name": "Ethereum",
    "requiredBlockConfirmations": 2
  },
  {
    "chain": "Polkadot",
    "evmChainId": null,
    "isMainnet": true,
    "maxRetryDurationBlocks": 20,
    "name": "Polkadot",
    "requiredBlockConfirmations": null
  },
  {
    "chain": "Bitcoin",
    "evmChainId": null,
    "isMainnet": true,
    "maxRetryDurationBlocks": 30,
    "name": "Bitcoin",
    "requiredBlockConfirmations": 3
  }
]

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

[
  {
    "chain": "Ethereum",
    "evmChainId": 1,
    "isMainnet": true,
    "maxRetryDurationBlocks": 10,
    "name": "Ethereum",
    "requiredBlockConfirmations": 2
  },
  {
    "chain": "Polkadot",
    "evmChainId": null,
    "isMainnet": true,
    "maxRetryDurationBlocks": 20,
    "name": "Polkadot",
    "requiredBlockConfirmations": null
  }
]