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

Getting Started with SwapKit

SwapKit is a comprehensive SDK that unifies blockchain interactions across 20+ chains. This guide will walk you through installation, setup, and building your first cross-chain application.

Before starting, ensure you have:

  • Node.js 18+ or Bun installed
  • Basic knowledge of JavaScript/TypeScript
  • A code editor (VS Code recommended)
bun add @swapkit/sdk
import { 
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
} from '@swapkit/sdk';
// Create a SwapKit instance with default configuration const
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
();

For production applications, you’ll want to add your own API keys and custom settings. See our Configuration Guide for detailed setup:

import { 
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
} from '@swapkit/sdk';
const
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
({
config?: SKConfigState | undefinedconfig: {
apiKeys?: Partial<{
    blockchair: string;
    keepKey: string;
    swapKit: string;
    walletConnectProjectId: string;
}> | undefined
apiKeys
: {
walletConnectProjectId?: string | undefinedwalletConnectProjectId: 'your-project-id', // Get from cloud.walletconnect.com blockchair?: string | undefinedblockchair: 'your-blockchair-key', // Get from blockchair.com/api swapKit?: string | undefinedswapKit: 'your-swapkit-key', // Get from api.swapkit.dev }, rpcUrls?: Partial<Record<Chain | StagenetChain, string>> | undefinedrpcUrls: { ETH?: string | undefinedETH: 'https://eth-mainnet.g.alchemy.com/v2/your-key', AVAX?: string | undefinedAVAX: 'https://api.avax.network/ext/bc/C/rpc', } } });

SwapKit has several fundamental concepts you should understand. For a detailed explanation, see our Core Concepts guide.

SwapKit supports 20+ blockchain networks with a unified Chain identifier system:

import { enum ChainChain } from '@swapkit/sdk';

// Examples of supported chains
const const ethereum: Chain.Ethereumethereum = enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum;   // "ETH"
const const bitcoin: Chain.Bitcoinbitcoin = enum ChainChain.function (enum member) Chain.Bitcoin = "BTC"Bitcoin;     // "BTC"
const const cosmos: Chain.Cosmoscosmos = enum ChainChain.function (enum member) Chain.Cosmos = "GAIA"Cosmos;       // "GAIA"
const const thorchain: Chain.THORChainthorchain = enum ChainChain.function (enum member) Chain.THORChain = "THOR"THORChain; // "THOR"

AssetValue is SwapKit’s way of representing amounts of any asset:

import { class AssetValueAssetValue } from '@swapkit/sdk';

// Native assets
const const eth: AssetValueeth = class AssetValueAssetValue.
AssetValue.from<{
    asset: "ETH.ETH";
    value: number;
}>({ value, fromBaseDecimal, asyncTokenLookup, ...fromAssetOrChain }: {
    asset: "ETH.ETH";
    value: number;
} & AssetValueFromParams): AssetValue
from
({ asset: "ETH.ETH"asset: 'ETH.ETH', value: numbervalue: 1 }); // 1 ETH
const const btc: AssetValuebtc = class AssetValueAssetValue.
AssetValue.from<{
    asset: "BTC.BTC";
    value: number;
}>({ value, fromBaseDecimal, asyncTokenLookup, ...fromAssetOrChain }: {
    asset: "BTC.BTC";
    value: number;
} & AssetValueFromParams): AssetValue
from
({ asset: "BTC.BTC"asset: 'BTC.BTC', value: numbervalue: 0.1 }); // 0.1 BTC
// Tokens include the contract address const const usdc: AssetValueusdc = class AssetValueAssetValue.
AssetValue.from<{
    asset: "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
    value: number;
}>({ value, fromBaseDecimal, asyncTokenLookup, ...fromAssetOrChain }: {
    asset: "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
    value: number;
} & AssetValueFromParams): AssetValue
from
({
asset: "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"asset: 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', value: numbervalue: 1000 }); // 1000 USDC on Ethereum

SwapKit supports 20+ wallet types:

import { enum WalletOptionWalletOption } from '@swapkit/sdk';

// Browser extension wallets
const const metamask: WalletOption.METAMASKmetamask = enum WalletOptionWalletOption.function (enum member) WalletOption.METAMASK = "METAMASK"METAMASK;
const const keplr: WalletOption.KEPLRkeplr = enum WalletOptionWalletOption.function (enum member) WalletOption.KEPLR = "KEPLR"KEPLR;

// Hardware wallets
const const ledger: WalletOption.LEDGERledger = enum WalletOptionWalletOption.function (enum member) WalletOption.LEDGER = "LEDGER"LEDGER;

// Software wallets
const const keystore: WalletOption.KEYSTOREkeystore = enum WalletOptionWalletOption.function (enum member) WalletOption.KEYSTORE = "KEYSTORE"KEYSTORE;
import { 
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
, enum ChainChain, enum WalletOptionWalletOption } from '@swapkit/sdk';
const
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
();
// Connect Keystore wallet (mnemonic phrase) await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
connectKeystore: (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
    ARB?: DerivationPathArray | undefined;
    AVAX?: DerivationPathArray | undefined;
    ... 21 more ...;
    TRX?: DerivationPathArray | undefined;
} | undefined) => Promise<boolean>
connectKeystore
(
[enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum, enum ChainChain.function (enum member) Chain.Bitcoin = "BTC"Bitcoin], 'your twelve word mnemonic phrase here' ); // Connect MetaMask (EVM chains only) await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.connectEVMWallet: (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>connectEVMWallet([enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum], enum WalletOptionWalletOption.function (enum member) WalletOption.METAMASK = "METAMASK"METAMASK);
// Connect Keplr (Cosmos chains) await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.connectKeplr: (chains: Chain[], walletType?: WalletOption.KEPLR | WalletOption.LEAP | undefined) => Promise<boolean>connectKeplr([enum ChainChain.function (enum member) Chain.Cosmos = "GAIA"Cosmos, enum ChainChain.function (enum member) Chain.THORChain = "THOR"THORChain]);
// Connect Cosmostation (Cosmos chains) await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
Property 'connectCosmostation' does not exist on type '{ chainflip: { supportedSwapkitProviders: ProviderName[]; } & { swap: (swapParams: RequestSwapDepositAddressParams) => Promise<string>; }; ... 5 more ...; near: { ...; } & { ...; }; } & { ...; } & { ...; }'.
connectCosmostation
([enum ChainChain.function (enum member) Chain.Cosmos = "GAIA"Cosmos, enum ChainChain.function (enum member) Chain.THORChain = "THOR"THORChain]);
// Get all connected wallets const
const wallets: {
    ARB: ChainWallet<Chain.Arbitrum> & {
        estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
            feeOption: FeeOption;
            chain: EVMChain;
        }) => Promise<...>;
        ... 20 more ...;
        validateAddress: (address: string) => boolean;
    };
    ... 22 more ...;
    TRX: ChainWallet<...> & {
        ...;
    };
}
wallets
=
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
getAllWallets: () => {
    ARB: ChainWallet<Chain.Arbitrum> & {
        estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
            feeOption: FeeOption;
            chain: EVMChain;
        }) => Promise<...>;
        ... 20 more ...;
        validateAddress: (address: string) => boolean;
    };
    ... 22 more ...;
    TRX: ChainWallet<...> & {
        ...;
    };
}
getAllWallets
();
import { 
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
, enum ChainChain } from '@swapkit/sdk';
const
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
();
// Get balance for a specific chain const const ethBalance: AssetValue[]ethBalance = await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getBalance: <Chain.Ethereum, boolean>(chain: Chain.Ethereum, refresh?: boolean | undefined) => AssetValue[] | Promise<AssetValue[]>getBalance(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum);
const const btcBalance: AssetValue[]btcBalance = await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getBalance: <Chain.Bitcoin, boolean>(chain: Chain.Bitcoin, refresh?: boolean | undefined) => AssetValue[] | Promise<AssetValue[]>getBalance(enum ChainChain.function (enum member) Chain.Bitcoin = "BTC"Bitcoin);
// Force refresh balance (bypass cache) const const freshBalance: AssetValue[]freshBalance = await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getBalance: <Chain.Ethereum, true>(chain: Chain.Ethereum, refresh?: true | undefined) => Promise<AssetValue[]>getBalance(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum, true);
// Get wallet with balance const
const walletWithBalance: ((ChainWallet<Chain.Arbitrum> & {
    estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
        feeOption: FeeOption;
        chain: EVMChain;
    }) => Promise<...>;
    ... 20 more ...;
    validateAddress: (address: string) => boolean;
}) | ... 22 more ... | ChainWallet<...>) & {
    ...;
}
walletWithBalance
= await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
getWalletWithBalance: <Chain.Ethereum>(chain: Chain.Ethereum, scamFilter?: boolean) => Promise<((ChainWallet<Chain.Arbitrum> & {
    estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
        feeOption: FeeOption;
        chain: EVMChain;
    }) => Promise<...>;
    ... 20 more ...;
    validateAddress: (address: string) => boolean;
}) | ... 22 more ... | ChainWallet<...>) & {
    ...;
}>
getWalletWithBalance
(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`Address: ${
const walletWithBalance: ((ChainWallet<Chain.Arbitrum> & {
    estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
        feeOption: FeeOption;
        chain: EVMChain;
    }) => Promise<...>;
    ... 20 more ...;
    validateAddress: (address: string) => boolean;
}) | ... 22 more ... | ChainWallet<...>) & {
    ...;
}
walletWithBalance
.address: stringaddress}`);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`Balance: ${
const walletWithBalance: ((ChainWallet<Chain.Arbitrum> & {
    estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
        feeOption: FeeOption;
        chain: EVMChain;
    }) => Promise<...>;
    ... 20 more ...;
    validateAddress: (address: string) => boolean;
}) | ... 22 more ... | ChainWallet<...>) & {
    ...;
}
walletWithBalance
.balance: AssetValue[]balance}`);

Use the SwapKit API to get quotes and execute swaps:

import { 
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
, enum ChainChain, enum FeeOptionFeeOption,
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getNameDetails: (name: string) => Promise<THORNameDetails>;
        getNamesByAddress: (address: string) => Promise<...>;
        getNamesByOwner: (address: string) => Promise<...>;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
} from '@swapkit/sdk';
const
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
();
// Step 1: Get a quote const
const quoteParams: {
    sellAsset: string;
    sellAmount: string;
    buyAsset: string;
    sourceAddress: string;
    destinationAddress: string;
    slippage: number;
}
quoteParams
= {
sellAsset: stringsellAsset: 'ETH.ETH', sellAmount: stringsellAmount: '1000000000000000000', // 1 ETH in wei buyAsset: stringbuyAsset: 'BTC.BTC', sourceAddress: stringsourceAddress:
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getAddress: <Chain.Ethereum>(chain: Chain.Ethereum) => stringgetAddress(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum),
destinationAddress: stringdestinationAddress:
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getAddress: <Chain.Bitcoin>(chain: Chain.Bitcoin) => stringgetAddress(enum ChainChain.function (enum member) Chain.Bitcoin = "BTC"Bitcoin),
slippage: numberslippage: 3, // 3% slippage tolerance }; const {
const routes: {
    providers: ProviderName[];
    sellAsset: string;
    sellAmount: string;
    buyAsset: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    sourceAddress: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}[]
routes
} = await
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getNameDetails: (name: string) => Promise<THORNameDetails>;
        getNamesByAddress: (address: string) => Promise<...>;
        getNamesByOwner: (address: string) => Promise<...>;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
.
function getSwapQuote(json: QuoteRequest): Promise<{
    quoteId: string;
    routes: {
        providers: ProviderName[];
        sellAsset: string;
        sellAmount: string;
        buyAsset: string;
        expectedBuyAmount: string;
        ... 14 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}>
getSwapQuote
(
const quoteParams: {
    sellAsset: string;
    sellAmount: string;
    buyAsset: string;
    sourceAddress: string;
    destinationAddress: string;
    slippage: number;
}
quoteParams
);
// Step 2: Review the quote const
const bestRoute: {
    providers: ProviderName[];
    sellAsset: string;
    sellAmount: string;
    buyAsset: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    sourceAddress: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}
bestRoute
=
const routes: {
    providers: ProviderName[];
    sellAsset: string;
    sellAmount: string;
    buyAsset: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    sourceAddress: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}[]
routes
[0];
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`Expected output: ${
const bestRoute: {
    providers: ProviderName[];
    sellAsset: string;
    sellAmount: string;
    buyAsset: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    sourceAddress: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}
bestRoute
.expectedBuyAmount: stringexpectedBuyAmount}`);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`Fees:`,
const bestRoute: {
    providers: ProviderName[];
    sellAsset: string;
    sellAmount: string;
    buyAsset: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    sourceAddress: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}
bestRoute
.
Property 'fee' does not exist on type '{ providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; sourceAddress: string; ... 12 more ...; estimatedTime?: { ...; } | undefined; }'. Did you mean 'fees'?
fee
);
// Step 3: Execute the swap const const txHash: anytxHash = await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
swap: <"chainflip" | "evm" | "mayachain" | "thorchain" | "radix" | "solana" | "near">({ route, pluginName, ...rest }: SwapParams<"chainflip" | "evm" | "mayachain" | "thorchain" | "radix" | "solana" | "near", {
    providers: ProviderName[];
    ... 18 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}>) => any
swap
({
route: {
    providers: ProviderName[];
    sellAsset: string;
    sellAmount: string;
    buyAsset: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    sourceAddress: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}
route
:
const bestRoute: {
    providers: ProviderName[];
    sellAsset: string;
    sellAmount: string;
    buyAsset: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    sourceAddress: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}
bestRoute
,
feeOptionKey?: FeeOption | undefinedfeeOptionKey: enum FeeOptionFeeOption.function (enum member) FeeOption.Fast = "fast"Fast }); console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`Swap transaction: ${const txHash: anytxHash}`);
import { 
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
, class AssetValueAssetValue, enum FeeOptionFeeOption, enum ChainChain } from '@swapkit/sdk';
const
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
();
// Simple ETH transfer const const ethAmount: AssetValueethAmount = class AssetValueAssetValue.
AssetValue.from<{
    asset: "ETH.ETH";
    value: string;
}>({ value, fromBaseDecimal, asyncTokenLookup, ...fromAssetOrChain }: {
    asset: "ETH.ETH";
    value: string;
} & AssetValueFromParams): AssetValue
from
({ asset: "ETH.ETH"asset: 'ETH.ETH', value: stringvalue: '0.1' });
const const txHash: anytxHash = await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.transfer: ({ assetValue, ...params }: GenericTransferParams | EVMTransferParams) => Promise<any>transfer({
assetValue: AssetValueassetValue: const ethAmount: AssetValueethAmount, recipient: stringrecipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f6E321', memo?: string | undefinedmemo: 'Payment for services', // Optional feeOptionKey?: FeeOption | undefinedfeeOptionKey: enum FeeOptionFeeOption.function (enum member) FeeOption.Fast = "fast"Fast }); // Bitcoin transfer with custom fee const const btcAmount: AssetValuebtcAmount = class AssetValueAssetValue.
AssetValue.from<{
    asset: "BTC.BTC";
    value: string;
}>({ value, fromBaseDecimal, asyncTokenLookup, ...fromAssetOrChain }: {
    asset: "BTC.BTC";
    value: string;
} & AssetValueFromParams): AssetValue
from
({ asset: "BTC.BTC"asset: 'BTC.BTC', value: stringvalue: '0.001' });
const const btcTxHash: anybtcTxHash = await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.transfer: ({ assetValue, ...params }: GenericTransferParams | EVMTransferParams) => Promise<any>transfer({
assetValue: AssetValueassetValue: const btcAmount: AssetValuebtcAmount, recipient: stringrecipient: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh', feeOptionKey?: FeeOption | undefinedfeeOptionKey: enum FeeOptionFeeOption.function (enum member) FeeOption.Average = "average"Average }); // Ripple (XRP) transfer const const xrpAmount: AssetValuexrpAmount = class AssetValueAssetValue.
AssetValue.from<{
    asset: string;
    value: string;
}>({ value, fromBaseDecimal, asyncTokenLookup, ...fromAssetOrChain }: {
    asset: string;
    value: string;
} & AssetValueFromParams): AssetValue
from
({ asset: stringasset: 'XRP.XRP', value: stringvalue: '10' });
const const xrpTxHash: anyxrpTxHash = await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.transfer: ({ assetValue, ...params }: GenericTransferParams | EVMTransferParams) => Promise<any>transfer({
assetValue: AssetValueassetValue: const xrpAmount: AssetValuexrpAmount, recipient: stringrecipient: 'rBaaxNpAKxELKXkJpSCCJQTkQMTYrcPQPv', memo?: string | undefinedmemo: 'Invoice #12345', // Optional destination tag or memo feeOptionKey?: FeeOption | undefinedfeeOptionKey: enum FeeOptionFeeOption.function (enum member) FeeOption.Fast = "fast"Fast });

For smaller bundle sizes, use only the components you need:

import { 
function SwapKit<Plugins extends ReturnType<typeof createPlugin>, Wallets extends ReturnType<typeof createWallet>>({ config, plugins, wallets, }?: {
    config?: SKConfigState;
    plugins?: Plugins;
    wallets?: Wallets;
}): { [key in keyof Plugins]: ReturnType<...>; } & ... 1 more ... & {
    ...;
}
SwapKit
,
const ThorchainPlugin: {
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 11 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
}
ThorchainPlugin
,
const keystoreWallet: {
    connectKeystore: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
            ARB?: DerivationPathArray | undefined;
            ... 22 more ...;
            TRX?: DerivationPathArray | undefined;
        } | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 19 more ... | Chain.Tron)[];
    };
}
keystoreWallet
,
const ledgerWallet: {
    connectLedger: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], derivationPath?: DerivationPathArray | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 13 more ... | Chain.THORChain)[];
    };
}
ledgerWallet
} from '@swapkit/sdk';
const
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | undefined;
            assetTx: string | undefined;
        }>;
        ... 11 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
SwapKit<{
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 11 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
}, {
    ...;
}>({ config, plugins, wallets, }?: {
    ...;
}): {
    ...;
} & ... 1 more ... & {
    ...;
}
SwapKit
({
plugins?: {
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 11 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
} | undefined
plugins
: {
...
const ThorchainPlugin: {
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 11 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
}
ThorchainPlugin
,
},
wallets?: {
    connectLedger: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], derivationPath?: DerivationPathArray | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 13 more ... | Chain.THORChain)[];
    };
    connectKeystore: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
            ARB?: DerivationPathArray | undefined;
            ... 22 more ...;
            TRX?: DerivationPathArray | undefined;
        } | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 19 more ... | Chain.Tron)[];
    };
} | undefined
wallets
: {
...
const keystoreWallet: {
    connectKeystore: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
            ARB?: DerivationPathArray | undefined;
            ... 22 more ...;
            TRX?: DerivationPathArray | undefined;
        } | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 19 more ... | Chain.Tron)[];
    };
}
keystoreWallet
,
...
const ledgerWallet: {
    connectLedger: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], derivationPath?: DerivationPathArray | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 13 more ... | Chain.THORChain)[];
    };
}
ledgerWallet
,
}, });

For low-level blockchain operations:

import { function getToolbox<T extends Chain.Radix | Chain.Ripple | Chain.Solana | Chain.Tron | EVMChain | UTXOChain | CosmosChain | SubstrateChain>(chain: T, params?: ToolboxParams[T]): Promise<Toolboxes[T]>getToolbox, enum ChainChain } from '@swapkit/sdk';

const const address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"address = 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh';
const 
const btcToolbox: Promise<{
    accumulative: ({ inputs, outputs, feeRate: initialFeeRate, chain, }: UTXOCalculateTxSizeParams & {
        outputs: TargetOutput[];
        chain: UTXOChain;
    }) => {
        ...;
    } | {
        ...;
    };
    ... 13 more ...;
    estimateMaxSendableAmount: ({ from, memo, feeRate, feeOptionKey, recipients, }: {
        from: string;
        memo?: string;
        feeRate?: number;
        feeOptionKey?: FeeOption;
        recipients?: number | TargetOutput[];
    }) => Promise<...>;
} | {
    ...;
}>
btcToolbox
=
getToolbox<Chain.Bitcoin>(chain: Chain.Bitcoin, params?: undefined): Promise<{
    accumulative: ({ inputs, outputs, feeRate: initialFeeRate, chain, }: UTXOCalculateTxSizeParams & {
        outputs: TargetOutput[];
        chain: UTXOChain;
    }) => {
        ...;
    } | {
        ...;
    };
    ... 13 more ...;
    estimateMaxSendableAmount: ({ from, memo, feeRate, feeOptionKey, recipients, }: {
        from: string;
        memo?: string;
        feeRate?: number;
        feeOptionKey?: FeeOption;
        recipients?: number | TargetOutput[];
    }) => Promise<...>;
} | {
    ...;
}>
getToolbox
(enum ChainChain.function (enum member) Chain.Bitcoin = "BTC"Bitcoin);
const const isValid: anyisValid =
const btcToolbox: Promise<{
    accumulative: ({ inputs, outputs, feeRate: initialFeeRate, chain, }: UTXOCalculateTxSizeParams & {
        outputs: TargetOutput[];
        chain: UTXOChain;
    }) => {
        ...;
    } | {
        ...;
    };
    ... 13 more ...;
    estimateMaxSendableAmount: ({ from, memo, feeRate, feeOptionKey, recipients, }: {
        from: string;
        memo?: string;
        feeRate?: number;
        feeOptionKey?: FeeOption;
        recipients?: number | TargetOutput[];
    }) => Promise<...>;
} | {
    ...;
}>
btcToolbox
.
Property 'validateAddress' does not exist on type 'Promise<{ accumulative: ({ inputs, outputs, feeRate: initialFeeRate, chain, }: UTXOCalculateTxSizeParams & { outputs: TargetOutput[]; chain: UTXOChain; }) => { inputs: (UTXOType | UTXOInputWithScriptType)[]; outputs: TargetOutput[]; fee: number; } | { ...; }; ... 13 more ...; estimateMaxSendableAmount: ({ from, memo...'.
validateAddress
(const address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"address);
const const balance: anybalance = await
const btcToolbox: Promise<{
    accumulative: ({ inputs, outputs, feeRate: initialFeeRate, chain, }: UTXOCalculateTxSizeParams & {
        outputs: TargetOutput[];
        chain: UTXOChain;
    }) => {
        ...;
    } | {
        ...;
    };
    ... 13 more ...;
    estimateMaxSendableAmount: ({ from, memo, feeRate, feeOptionKey, recipients, }: {
        from: string;
        memo?: string;
        feeRate?: number;
        feeOptionKey?: FeeOption;
        recipients?: number | TargetOutput[];
    }) => Promise<...>;
} | {
    ...;
}>
btcToolbox
.
Property 'getBalance' does not exist on type 'Promise<{ accumulative: ({ inputs, outputs, feeRate: initialFeeRate, chain, }: UTXOCalculateTxSizeParams & { outputs: TargetOutput[]; chain: UTXOChain; }) => { inputs: (UTXOType | UTXOInputWithScriptType)[]; outputs: TargetOutput[]; fee: number; } | { ...; }; ... 13 more ...; estimateMaxSendableAmount: ({ from, memo...'.
getBalance
(const address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"address);

Create your own plugin to extend SwapKit:

import { 
function SwapKit<Plugins extends ReturnType<typeof createPlugin>, Wallets extends ReturnType<typeof createWallet>>({ config, plugins, wallets, }?: {
    config?: SKConfigState;
    plugins?: Plugins;
    wallets?: Wallets;
}): { [key in keyof Plugins]: ReturnType<...>; } & ... 1 more ... & {
    ...;
}
SwapKit
} from '@swapkit/sdk';
const
const MyCustomPlugin: {
    myCustomMethod: (params: any) => Promise<{
        success: boolean;
    }>;
    getCustomData: () => Promise<{
        data: string;
    }>;
}
MyCustomPlugin
= {
myCustomMethod: (params: any) => Promise<{
    success: boolean;
}>
myCustomMethod
: async (params: anyparams: any) => {
// Your custom logic here return { success: booleansuccess: true }; }, // Add custom functionality
getCustomData: () => Promise<{
    data: string;
}>
getCustomData
: async () => {
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Fetching custom data');
return { data: stringdata: 'custom-data' }; } }; const
const swapKit: {
    [x: string]: {
        supportedSwapkitProviders?: (ProviderName | string)[];
    } & Record<string, unknown>;
} & {
    [x: string]: (...params: any[]) => Promise<boolean>;
} & {
    ...;
}
swapKit
=
SwapKit<{
    [x: string]: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders?: (ProviderName | string)[];
    } & Record<...>;
}, {
    ...;
}>({ config, plugins, wallets, }?: {
    ...;
}): {
    ...;
} & ... 1 more ... & {
    ...;
}
SwapKit
({
Type '{ myCustomMethod: (params: any) => Promise<{ success: boolean; }>; getCustomData: () => Promise<{ data: string; }>; }' is not assignable to type '{ [x: string]: (pluginParams: SwapKitPluginParams) => { supportedSwapkitProviders?: string[] | undefined; } & Record<string, unknown>; }'. Property 'myCustomMethod' is incompatible with index signature. Type '(params: any) => Promise<{ success: boolean; }>' is not assignable to type '(pluginParams: SwapKitPluginParams) => { supportedSwapkitProviders?: string[] | undefined; } & Record<string, unknown>'. Type 'Promise<{ success: boolean; }>' is not assignable to type '{ supportedSwapkitProviders?: string[] | undefined; } & Record<string, unknown>'. Type 'Promise<{ success: boolean; }>' is not assignable to type 'Record<string, unknown>'. Index signature for type 'string' is missing in type 'Promise<{ success: boolean; }>'.
plugins
: {
...
const MyCustomPlugin: {
    myCustomMethod: (params: any) => Promise<{
        success: boolean;
    }>;
    getCustomData: () => Promise<{
        data: string;
    }>;
}
MyCustomPlugin
,
}, }); // Use your custom method await
const swapKit: {
    [x: string]: {
        supportedSwapkitProviders?: (ProviderName | string)[];
    } & Record<string, unknown>;
} & {
    [x: string]: (...params: any[]) => Promise<boolean>;
} & {
    ...;
}
swapKit
.
{
    supportedSwapkitProviders?: (ProviderName | string)[];
} & Record<string, unknown> & ((...params: any[]) => Promise<boolean>)
myCustomMethod
({ customParam: stringcustomParam: 'value' });
await
const swapKit: {
    [x: string]: {
        supportedSwapkitProviders?: (ProviderName | string)[];
    } & Record<string, unknown>;
} & {
    [x: string]: (...params: any[]) => Promise<boolean>;
} & {
    ...;
}
swapKit
.
{
    supportedSwapkitProviders?: (ProviderName | string)[];
} & Record<string, unknown> & ((...params: any[]) => Promise<boolean>)
getCustomData
();

SwapKit uses typed errors for better debugging:

import { 
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
, class SwapKitErrorSwapKitError, enum FeeOptionFeeOption } from '@swapkit/sdk';
const
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
();
try { // Example: attempting a swap with a route object const
const route: {
    sellAsset: string;
    buyAsset: string;
    expectedBuyAmount: string;
}
route
= {
sellAsset: stringsellAsset: 'ETH.ETH', buyAsset: stringbuyAsset: 'BTC.BTC', expectedBuyAmount: stringexpectedBuyAmount: '0.001', // ... other route properties }; await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
swap: <"chainflip" | "evm" | "mayachain" | "thorchain" | "radix" | "solana" | "near">({ route, pluginName, ...rest }: SwapParams<"chainflip" | "evm" | "mayachain" | "thorchain" | "radix" | "solana" | "near", {
    providers: ProviderName[];
    ... 18 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}>) => any
swap
({
Type '{ sellAsset: string; buyAsset: string; expectedBuyAmount: string; }' is missing the following properties from type '{ providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; sourceAddress: string; ... 12 more ...; estimatedTime?: { ...; } | undefined; }': providers, sellAmount, expectedBuyAmountMaxSlippage, sourceAddress, and 6 more.
route
,
feeOptionKey?: FeeOption | undefinedfeeOptionKey: enum FeeOptionFeeOption.function (enum member) FeeOption.Fast = "fast"Fast }); } catch (var error: unknownerror) { if (var error: unknownerror instanceof class SwapKitErrorSwapKitError) { console.Console.error(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
error
('SwapKit Error:', var error: SwapKitErrorerror.Error.message: stringmessage);
// Error may have additional properties console.Console.error(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
error
('Full error:', var error: SwapKitErrorerror);
} else { console.Console.error(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr ``` If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilinspectobject-options) is called on each argument and the resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
error
('Unexpected error:', var error: unknownerror);
} }

Now that you understand the basics:

  1. Core Concepts - Master AssetValue, error handling, and types
  2. Configuration - Set up API keys and customize settings
  3. API Reference - Explore all available API methods
  1. Connect Wallets - Deep dive into wallet integration
  2. Perform Swaps - Implement cross-chain swaps
  3. Send Transactions - Handle transfers and tracking
  1. THORChain Features - Liquidity, and THORNames
  2. Advanced Features - Multi-chain ops and synthetics
  3. Toolbox Usage - Direct blockchain operations
  1. Create Custom Plugin - Add new protocols
  2. Create Custom Wallet - Integrate new wallets
  3. Framework Integration - Use with Next.js, Vite, etc.

Happy building with SwapKit! 🚀