Quickstart

Let's get started with building our dApp! This guide is for developers primarily building on the Bitcoin network or developers looking to integrate liquidity routes to and from any EVM chain to the Bitcoin network.

Check supported chains, bridges and liquidity.

In this guide, we will be using thirdweb's SDK to connect to a user's wallet via xDefi and sending a cross-chain transaction using Swing's Cross-Chain API. The process/steps for executing a BTC to ETH transaction, and vice versa, are as follows:

Although not essential for executing a swap transaction, providing your users with real-time updates on the transaction's status by polling the status can significantly enhance the user experience.

Installing xDEFI Wallet

To install xDefi, navigate over to https://www.xdefi.io/

btc project filesystem

Be sure to use a browser that supports chrome extensions.

Then follow the steps to install xDefi and setup your wallet on their official website.

Cloning The Examples Repository

Before we begin, we'll have to clone the Swing examples repository

git clone https://github.com/swing-xyz/examples.git

Running our dApp

Once you've cloned the examples repo, the next step is to install the necessary packages required for the project to run.

Open the examples repo in VS Code or any code editor of your choice.

yarn install

The example's repo is a Turbo monorepo containing multiple example projects. The example used in this guide can be found at examples/swaps-api-nextjs-bitcoin:

btc project filesystem

Once the packages are installed, we can then run our app:

yarn dev --filter=swaps-api-nextjs-bitcoin

The references for Swing's Cross-Chain and Platform APIs used in this guide can be found here.