Integration
Swapping and Aggregation
Javascript SDK
Quick Start

Quick Start

Installation

The Chainflip SDK is a lightweight npm package. You can install it here:

npm install --save @chainflip-io/chainflip-sdk

Set up

To start using the Chainflip SDK, you'll first need to import it and create an instance with the appropriate options:

import { SwapSDK } from "@chainflip-io/chainflip-sdk/swap";
import { Wallet } from "ethers";
 
const options = {
  network: "perseverance", // Testnet
  backendServiceUrl: "https://example.chainflip.io", // optional
  signer: Wallet.fromMnemonic(process.env.WALLET_MNEMONIC), // optional
  broker: {
    url: 'https://my.broker.io',
    commissionBps: 0, // basis points, i.e. 100 = 1%
  }, // optional
};
 
const swapSDK = new SwapSDK(options);

The options object accepts the following properties:

ParamDescriptionData type
networkThe Chainflip network to interact with. Defaults to perseverance. See Supported Chains & Assets.'sisyphos' | 'perseverance' | 'mainnet' |
backendServiceUrlThe URL of the backend service. Defaults to the backend service run by Chainflip for the given network.string
signerAn instance of an ethers signer. Only needed for calls that use smart contracts.Signer
brokerOptional configuration to use a different broker than provided by Chainflip.Object
;