Setup the Swing SDK

Swing enables secure, any blockchain to any blockchain communication to power multi-chain liquidity for applications.

The Swing SDK enables easy access to the Swing API, which allows you to find and execute the best multi-chain routes across major cross-chain bridges and exchanges.

Install @swing.xyz/sdk

The Swing SDK can be installed into your app using your favorite package manager.

yarn add @swing.xyz/sdk

# OR

npm install @swing.xyz/sdk

Create a client

Import the SwingSDK class from the package and create a new instance of the SwingSDK client.

import SwingSDK from '@swing.xyz/sdk'

const sdk = new SwingSDK({
  // Optionally enable debug mode for verbose logging
  // debug: true,
})

Initialize the client

This method loads the SDK with all available chains, tokens and bridges.

await sdk.init()

Add Project Identifier

Project Identifier is used to identify the application integrated with Swing SDK. Using a swing project identifier allows you to manage your configuration in the Swing Platform. With Swing Platform, you and your team can instantly deploy configurations, see live transaction metrics and more. Learn more about Swing Platform.

How to get a project identifier

  1. Create your account with Swing Platform
  2. Create your project and get your unique project Identifier.

How to use a project identifier

Add your swing project identifier when creating a client like this:

const swingSdk = new SwingSDK({
  projectId: "swing-project-id",
});