Swapping
Integrations
Javascript SDK
Quick Start

Quick Start

Installation

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

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

The options object accepts the following properties:

ParamDescriptionData type
network(optional)The Chainflip network to interact with. Defaults to perseverance. See Supported Chains & Assets.'sisyphos' | 'perseverance' | 'mainnet'
backendServiceUrl(optional)The URL of the backend service. Defaults to the backend service run by Chainflip for the given network.string
signer(optional)An instance of an ethers signer. Only needed for calls that use smart contracts.Signer
broker(optional)Optional configuration to use a different broker than provided by Chainflip.Object
rpcUrl(optional)The URL of the state chain rpc node. Defaults to the public rpc node operated by Chainflip for the given network.String