Skip to content
SwapDK is a powerful suite of tools for building blockchain applications.

Getting started with SwapDK

SwapDK is a powerful suite of tools for building blockchain applications. It provides a modular framework for integrating with multiple blockchains, wallet providers, and DeFi protocols.

SwapDK offers two implementation approaches to suit your needs:

Quick and Simple

The all-in-one solution that bundles Core with all available plugins and wallet integrations.

Perfect for developers who want to get started quickly with minimal configuration.

Pros:

  • Simplicity and convenience
  • Reduced setup time
  • Pre-configured with all available plugins and wallets
  • Faster implementation for multi-chain applications

Cons:

  • Larger bundle size
  • Less flexibility for specific customizations
Start with SDK

The fastest way to integrate SwapDK into your application.

  1. Install the SDK

    Choose your package manager:

    bash bun add @swapdk/sdk
  2. Initialize SwapDK

    import { createSwapKit } from "@swapdk/sdk";
    const defaultSwapDK = createSwapKit();
    const swapDK = createSwapKit({
    config: {
    apiKeys: {
    swapKit: "your-swapdk-api-key",
    },
    },
    });
  3. Start Using SwapDK

    Connect a wallet:

    import { createSwapKit, Chain } from "@swapdk/sdk";
    const swapDK = createSwapKit({
    config: { apiKeys: { swapKit: "your-swapdk-api-key" } },
    });
    const wallet = await swapDK.connectKeystore(
    [Chain.Ethereum],
    "your mnemonic phrase here"
    );
    const address = swapDK.getAddress(Chain.Ethereum);

For developers who need more control and custom configurations.

  1. Install Core Package

    Start with the core package:

    bash bun add @swapdk/core
  2. Install Required Components

    Add only the components you need:

    Terminal window
    bun add @swapdk/wallets

    Install to add integrations with specific wallets. Import specific wallet integrations as needed (e.g., keystoreWallet from @swapdk/sdk). Supports around 20+ wallets, including Ledger, Trezor, Coinbase, WalletConnect and more.

  3. Configure SwapDK

    import { SwapKit, Chain, ThorchainPlugin, EVMPlugin, keystoreWallet, ledgerWallet } from '@swapdk/sdk';
    const swapDK = SwapKit({
    config: {
    apiKeys: { swapKit: 'your-swapdk-api-key' }
    },
    plugins: { ...ThorchainPlugin, ...EVMPlugin },
    wallets: { ...keystoreWallet, ...ledgerWallet },
    });
    await swapDK.connectKeystore([Chain.Ethereum], 'your mnemonic phrase here');
    const wallet = swapDK.getWallet(Chain.Ethereum);

No matter which implementation you choose, you can use these common patterns:

Check Balances

import { SwapKit, Chain } from '@swapdk/sdk';
const swapDK = SwapKit({
config: { apiKeys: { swapKit: 'your-swapdk-api-key' } },
});
const balance = await swapDK.getBalance(Chain.Bitcoin, true);
const allWallets = swapDK.getAllWallets();

Transfer Assets

import { AssetValue, Chain, SwapKit, keystoreWallet } from '@swapdk/sdk';
const swapDK = SwapKit({
config: { apiKeys: { swapKit: 'your-swapdk-api-key' }, wallets: { ...keystoreWallet } },
});
await swapDK.connectKeystore([Chain.Ethereum], 'your mnemonic phrase here');
const assetValue = AssetValue.from({
chain: Chain.Ethereum,
symbol: 'ETH',
decimal: 18,
value: '0.1',
});
const txHash = await swapDK.transfer({
assetValue,
recipient: '0xRecipientAddressHere',
memo: 'Optional memo',
});

Perform Swaps

import { AssetValue, Chain, SwapKitApi, SwapKit, keystoreWallet } from '@swapdk/sdk';
const swapDK = SwapKit({
config: { apiKeys: { swapKit: 'your-swapdk-api-key' }, wallets: { ...keystoreWallet } },
});
await swapDK.connectKeystore([Chain.Ethereum], 'your mnemonic phrase here');
const quoteResponse = await SwapKitApi.getSwapQ({
fromAsset: AssetValue.from({
chain: Chain.Ethereum,
symbol: 'ETH',
value: '0.1'
}),
toAsset: AssetValue.from({
chain: Chain.Bitcoin,
symbol: 'BTC'
}),
});
const swapTx = await swapDK.swap({ route: quoteResponse.routes[0] });

API Reference

Explore detailed documentation of all SwapDK components and APIs. View References

Guides

Learn how to implement specific use cases with SwapDK. Browse Guides

Toolboxes

Discover blockchain-specific toolboxes for extended functionality. Explore Toolboxes

Wallets

Integrate with different wallet providers using SwapDK. View Wallets