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

Migrate to v4

import { 
function getUtxoToolbox<T extends keyof UTXOToolboxes>(chain: T, params?: UtxoToolboxParams[T] | {
    phrase?: string;
    derivationPath?: DerivationPathArray;
    index?: number;
}): Promise<UTXOToolboxes[T]>
getUtxoToolbox
} from "@swapkit/toolboxes/utxo"
import {
function getEvmToolbox<T extends EVMChain>(chain: T, params?: EVMToolboxParams): Promise<{
    estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
        feeOption: FeeOption;
        chain: EVMChain;
    }) => Promise<...>;
    ... 20 more ...;
    validateAddress: (address: string) => boolean;
} | {
    ...;
} | {
    ...;
}>
getEvmToolbox
} from "@swapkit/toolboxes/evm"
import { enum ChainChain,
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    kado: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        createPopover: (url: string) => HTMLDivElement;
        ... 5 more ...;
        swap: ({ route }: SwapParams<"evm", QuoteResponseRoute>) => {
            ...;
        };
    };
    ... 5 more ...;
    thorchain: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
, const DerivationPath: Record<Chain, string>DerivationPath } from "@swapkit/sdk"
const
const btc: {
    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<...>;
}
btc
= await
getUtxoToolbox<Chain.Bitcoin>(chain: Chain.Bitcoin, params?: {
    phrase?: string;
    derivationPath?: DerivationPathArray;
    index?: number;
} | {
    signer: ChainSigner<Psbt, Psbt>;
} | undefined): Promise<...>
getUtxoToolbox
(enum ChainChain.function (enum member) Chain.Bitcoin = "BTC"Bitcoin)
const
const eth: {
    estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
        feeOption: FeeOption;
        chain: EVMChain;
    }) => Promise<...>;
    ... 20 more ...;
    validateAddress: (address: string) => boolean;
} | {
    ...;
} | {
    ...;
}
eth
= await
getEvmToolbox<Chain.Ethereum>(chain: Chain.Ethereum, params?: EVMToolboxParams): Promise<{
    estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
        feeOption: FeeOption;
        chain: EVMChain;
    }) => Promise<...>;
    ... 20 more ...;
    validateAddress: (address: string) => boolean;
} | {
    ...;
} | {
    ...;
}>
getEvmToolbox
(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum)
const
const avax: {
    estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
        feeOption: FeeOption;
        chain: EVMChain;
    }) => Promise<...>;
    ... 20 more ...;
    validateAddress: (address: string) => boolean;
} | {
    ...;
} | {
    ...;
}
avax
= await
getEvmToolbox<Chain.Avalanche>(chain: Chain.Avalanche, params?: EVMToolboxParams): Promise<{
    estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
        feeOption: FeeOption;
        chain: EVMChain;
    }) => Promise<...>;
    ... 20 more ...;
    validateAddress: (address: string) => boolean;
} | {
    ...;
} | {
    ...;
}>
getEvmToolbox
(enum ChainChain.function (enum member) Chain.Avalanche = "AVAX"Avalanche)
const const avaxNetwork: NetworkParams | undefinedavaxNetwork =
const avax: {
    estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
        feeOption: FeeOption;
        chain: EVMChain;
    }) => Promise<...>;
    ... 20 more ...;
    validateAddress: (address: string) => boolean;
} | {
    ...;
} | {
    ...;
}
avax
.getNetworkParams: () => NetworkParams | undefinedgetNetworkParams()
const const btcKeys: ECPairInterfacebtcKeys = await
const btc: {
    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<...>;
}
btc
.
createKeysForPath: (params: {
    wif?: string;
    phrase?: string;
    derivationPath?: string;
}) => ECPairInterface
createKeysForPath
({
phrase?: string | undefinedphrase: "...", derivationPath?: string | undefinedderivationPath: `${const DerivationPath: Record<Chain, string>DerivationPath.type BTC: stringBTC}/0`, }) const const publicKey: Buffer<ArrayBufferLike> | undefinedpublicKey = const btcKeys: ECPairInterfacebtcKeys.Signer.getPublicKey?(): BuffergetPublicKey?.(); const
const skClient: {
    kado: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        createPopover: (url: string) => HTMLDivElement;
        getAssets: () => Promise<{
            _id: string;
            name: string;
            ... 9 more ...;
            priority: number;
        }[]>;
        ... 4 more ...;
        swap: ({ route }: SwapParams<"evm", QuoteResponseRoute>) => {
            ...;
        };
    };
    ... 5 more ...;
    thorchain: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
skClient
=
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    kado: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        createPopover: (url: string) => HTMLDivElement;
        ... 5 more ...;
        swap: ({ route }: SwapParams<"evm", QuoteResponseRoute>) => {
            ...;
        };
    };
    ... 5 more ...;
    thorchain: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
()
const skClient: {
    kado: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        createPopover: (url: string) => HTMLDivElement;
        getAssets: () => Promise<{
            _id: string;
            name: string;
            ... 9 more ...;
            priority: number;
        }[]>;
        ... 4 more ...;
        swap: ({ route }: SwapParams<"evm", QuoteResponseRoute>) => {
            ...;
        };
    };
    ... 5 more ...;
    thorchain: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
skClient
.
  • approveAssetValue
  • chainflip
  • connectBitget
  • connectCoinbaseWallet
  • connectCtrl
  • connectEVMWallet
  • connectExodusWallet
  • connectKeepkey
  • connectKeepkeyBex
  • connectKeplr
  • connectKeystore
  • connectLedger
  • connectOkx
  • connectOnekeyWallet
  • connectPhantom
  • connectPolkadotJs
  • connectRadixWallet
  • connectTalisman
  • connectTrezor
  • connectWalletconnect
  • disconnectAll
  • disconnectChain
  • estimateTransactionFee
  • evm
  • getAddress
  • getAllWallets
  • getBalance
  • getExplorerAddressUrl
  • getExplorerTxUrl
  • getWallet
  • getWalletWithBalance
  • isAssetValueApproved
  • kado
  • mayachain
  • radix
  • signMessage
  • solana
  • swap
  • thorchain
  • transfer
  • verifyMessage
swap: <T extends "kado" | "chainflip" | "radix" | "solana" | "evm" | "mayachain" | "thorchain">({ route, pluginName, ...rest }: SwapParams<T, {
    providers: ProviderName[];
    sellAsset: string;
    sellAmount: string;
    buyAsset: string;
    ... 15 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}>) => any
swap

[!IMPORTANT]Read before continue We migrated to combined functionality packages to simplify developer experience. You will have to change imports to use the new version of the packages.

To help with migration we noted how imports changed in the following sections with the format:

swapkitPackage => migratedSwapkitPackage

before

# Toolboxes
$ bun install @swapkit/toolbox-cosmos @swapkit/toolbox-evm @swapkit/toolbox-radix @swapkit/toolbox-solana @swapkit/toolbox-substrate @swapkit/toolbox-utxo

# Plugins
$ bun install @swapkit/plugin-chainflip @swapkit/plugin-evm @swapkit/plugin-kado @swapkit/plugin-radix @swapkit/plugin-thorchain

# Wallets
$ bun install @swapkit/wallet-bitget @swapkit/wallet-coinbase @swapkit/wallet-ctrl @swapkit/wallet-evm-extensions @swapkit/wallet-exodus @swapkit/wallet-keepkey @swapkit/wallet-keepkey-bex @swapkit/wallet-ledger @swapkit/wallet-okx @swapkit/wallet-phantom @swapkit/wallet-polkadotjs @swapkit/wallet-radix @swapkit/wallet-tailsman @swapkit/wallet-trezor @swapkit/wallet-wc

# Helpers and others
$ bun install @swapkit/helpers @swapkit/api @swapkit/contracts @swapkit/tokens

after

# Toolboxes
$ bun install @swapkit/toolboxes

# Plugins
$ bun install @swapkit/plugins

# Wallets
$ bun install @swapkit/wallets

# Helpers and others
$ bun install @swapkit/helpers
OldNew
@swapkit/api@swapkit/helpers/api
@swapkit/contracts@swapkit/helpers/contracts
@swapkit/tokens@swapkit/helpers/tokens
@swapkit/plugin-chainflip@swapkit/plugins/chainflip
@swapkit/plugin-evm@swapkit/plugins/evm
@swapkit/plugin-kado@swapkit/plugins/kado
@swapkit/plugin-radix@swapkit/plugins/radix
@swapkit/plugin-thorchain@swapkit/plugins/thorchain
@swapkit/toolbox-cosmos@swapkit/toolboxes/cosmos
@swapkit/toolbox-evm@swapkit/toolboxes/evm
@swapkit/toolbox-radix@swapkit/toolboxes/radix
@swapkit/toolbox-solana@swapkit/toolboxes/solana
@swapkit/toolbox-substrate@swapkit/toolboxes/substrate
@swapkit/toolbox-utxo@swapkit/toolboxes/utxo
@swapkit/wallet-bitget@swapkit/wallets/bitget
@swapkit/wallet-coinbase@swapkit/wallets/coinbase
@swapkit/wallet-ctrl@swapkit/wallets/ctrl
@swapkit/wallet-evm-extensions@swapkit/wallets/evm-extensions
@swapkit/wallet-exodus@swapkit/wallets/exodus
@swapkit/wallet-keepkey@swapkit/wallets/keepkey
@swapkit/wallet-keepkey-bex@swapkit/wallets/keepkey-bex
@swapkit/wallet-ledger@swapkit/wallets/ledger
@swapkit/wallet-okx@swapkit/wallets/okx
@swapkit/wallet-phantom@swapkit/wallets/phantom
@swapkit/wallet-polkadotjs@swapkit/wallets/polkadotjs
@swapkit/wallet-radix@swapkit/wallets/radix
@swapkit/wallet-tailsman@swapkit/wallets/tailsman
@swapkit/wallet-trezor@swapkit/wallets/trezor
@swapkit/wallet-wc@swapkit/wallets/walletconnect
  • SKConfig - configuration module for handling api keys and other configuration options
  • createPlugin - factory function to create a new plugin
  • Now combines @swapkit/api, @swapkit/contracts, @swapkit/tokens under a single package
  • Now combines @swapkit/plugin-chainflip, @swapkit/plugin-evm, @swapkit/plugin-kado, @swapkit/plugin-radix, @swapkit/plugin-thorchain under a single package
  • Now combines @swapkit/toolbox-evm, @swapkit/toolbox-cosmos, @swapkit/toolbox-solana, @swapkit/toolbox-substrate, @swapkit/toolbox-utxo under a single package

Methods were scoped under SwapKitApi object and split into related api endpoints.

  • getSwapQuoteV2 -> use getSwapQuote directly
  • getTokenListV2 -> use getTokenList directly
  • for thornode requests use SwapKitApi.thornode
  • for mayachain midgard requests use SwapKitApi.mayachainMidgard
  • for thorchain midgard requests use SwapKitApi.thorchainMidgard
  • for microgard requests use SwapKitApi.microgard
  • validateAddress -> Migrated to @swapkit/toolboxes -> use getAddressValidator directly
  • api -> use SwapKitApi directly. For configuration use SKConfig
  • ensureEVMApiKeys -> removed
  • setRequestClientConfig -> removed - use SKConfig directly —>