Migrate to v4
This guide provides a comprehensive overview of all breaking changes and migration steps from SwapKit v3 to v4.
Major Breaking Changes
Section titled “Major Breaking Changes”1. Package Restructuring
Section titled “1. Package Restructuring”v4 fundamentally changes how packages are organized:
v3 Structure: Individual packages for each component
@swapkit/plugin-chainflip
@swapkit/plugin-evm
@swapkit/toolbox-cosmos
@swapkit/wallet-keystore
@swapkit/api
v4 Structure: Consolidated monolithic packages with submodule exports
@swapkit/plugins/* # All plugins in one package
@swapkit/toolboxes/* # All toolboxes in one package
@swapkit/wallets/* # All wallets in one package
@swapkit/helpers # Utilities and API (previously @swapkit/api)
@swapkit/sdk # Complete bundle with everything
2. Import Path Changes
Section titled “2. Import Path Changes”All imports must be updated:
// Plugins
- import { ChainflipPlugin } from "@swapkit/plugin-chainflip";
- import { EVMPlugin } from "@swapkit/plugin-evm";
+ import { ChainflipPlugin } from "@swapkit/plugins/chainflip";
+ import { EVMPlugin } from "@swapkit/plugins/evm";
// Toolboxes
- import { getToolboxByChain } from "@swapkit/toolbox-cosmos";
- import { EVMToolbox } from "@swapkit/toolbox-evm";
+ import { getCosmosToolbox } from "@swapkit/toolboxes/cosmos";
+ import { getEvmToolbox } from "@swapkit/toolboxes/evm";
// Wallets
- import { keystoreWallet } from "@swapkit/wallet-keystore";
+ import { keystoreWallet } from "@swapkit/wallets/keystore";
// API (moved to helpers)
- import { SwapKitApi } from "@swapkit/api";
+ import { SwapKitApi } from "@swapkit/helpers/api";
3. Client Initialization Changes
Section titled “3. Client Initialization Changes”The SwapKit client initialization has changed:
// v3
- import { SwapKit } from "@swapkit/core";
- const client = SwapKit({
- apis: { /* custom APIs */ },
- rpcUrls: { /* RPC URLs */ },
- config: { stagenet: false },
- plugins: { ...ThorchainPlugin },
- wallets: { ...keystoreWallet }
- });
// v4
+ import { SwapKit } from "@swapkit/core";
+ const client = SwapKit({
+ config: {
+ rpcUrls: { /* RPC URLs */ },
+ apiKeys: { /* API keys */ }
+ },
+ plugins: { ...ThorchainPlugin },
+ wallets: { ...keystoreWallet }
+ });
4. Configuration System (SKConfig)
Section titled “4. Configuration System (SKConfig)”v4 introduces a centralized configuration system:
// v3 - Direct configuration
- const client = SwapKit({
- apis: { [Chain.Ethereum]: customEthApi },
- rpcUrls: { [Chain.Ethereum]: "https://eth-rpc.com" }
- });
// v4 - SKConfig system
+ import { SKConfig } from "@swapkit/helpers";
+ SKConfig.set({
+ rpcUrls: { [Chain.Ethereum]: "https://eth-rpc.com" },
+ apiKeys: {
+ blockchair: "YOUR_KEY",
+ swapKit: "YOUR_KEY"
+ }
+ });
5. Plugin Interface Changes
Section titled “5. Plugin Interface Changes”Plugins now use the createPlugin
helper:
// v3
- export function plugin({ getWallet, config }: SwapKitPluginParams<ConnectConfig>) {
- return {
- swap,
- supportedSwapkitProviders: [ProviderName.THORCHAIN]
- };
- }
// v4
+ import { createPlugin } from "@swapkit/helpers";
+ export const MyPlugin = createPlugin({
+ name: "myPlugin",
+ properties: { supportedSwapkitProviders: [ProviderName.THORCHAIN] },
+ methods: ({ getWallet }) => ({ swap })
+ });
6. Wallet Interface Changes
Section titled “6. Wallet Interface Changes”Wallets now use the createWallet
helper:
// v3
- export const keystoreWallet: SwapKitWallet<[chains: CryptoChain[], phrase: string]> =
- ({ addChain, apis, rpcUrls }) => {
- return async (chains, phrase) => { /* ... */ };
- };
// v4
+ import { createWallet } from "@swapkit/helpers";
+ export const keystoreWallet = createWallet({
+ name: "keystore",
+ hooks: ({ config }) => ({
+ async connectWallet(chains: Chain[], phrase: string) { /* ... */ }
+ })
+ });
7. Toolbox Constructor Changes
Section titled “7. Toolbox Constructor Changes”Toolboxes no longer accept RPC URLs directly:
// v3
- const toolbox = getToolboxByChain(chain, {
- api: customApi,
- rpcUrl: "https://rpc.url",
- signer
- });
// v4 - RPC URLs from SKConfig only
+ const toolbox = getEvmToolbox(chain, { signer });
// RPC URL automatically retrieved from SKConfig
8. Type Changes
Section titled “8. Type Changes”Several type imports have changed:
// Wallet types
- import type { EVMWallets } from "@swapkit/toolbox-evm";
+ import type { EVMToolboxes } from "@swapkit/toolboxes/evm";
// API types
- import type { QuoteRequest } from "@swapkit/api";
+ import type { QuoteRequest } from "@swapkit/helpers/api";
// Plugin params simplified
- SwapKitPluginParams<ConnectConfig>
+ SwapKitPluginParams
9. Removed Features
Section titled “9. Removed Features”ChainApis
type: Use SKConfig system instead- Direct API parameter: Configure via SKConfig
walletAddressValidator
helper: Removed from core exports- Individual package installations: Must use consolidated packages
Migration Steps
Section titled “Migration Steps”Step 1: Update Dependencies
Section titled “Step 1: Update Dependencies”# Remove v3 packages
bun remove @swapkit/plugin-* @swapkit/toolbox-* @swapkit/wallet-*
# Install v4 packages
bun add @swapkit/sdk
# or individual packages
bun add @swapkit/core @swapkit/plugins @swapkit/toolboxes @swapkit/wallets
# Remove v3 packages
pnpm remove @swapkit/plugin-* @swapkit/toolbox-* @swapkit/wallet-*
# Install v4 packages
pnpm add @swapkit/sdk
# or individual packages
pnpm add @swapkit/core @swapkit/plugins @swapkit/toolboxes @swapkit/wallets
# Remove v3 packages
npm uninstall @swapkit/plugin-* @swapkit/toolbox-* @swapkit/wallet-*
# Install v4 packages
npm install @swapkit/sdk
# or individual packages
npm install @swapkit/core @swapkit/plugins @swapkit/toolboxes @swapkit/wallets
# Remove v3 packages
yarn remove @swapkit/plugin-* @swapkit/toolbox-* @swapkit/wallet-*
# Install v4 packages
yarn add @swapkit/sdk
# or individual packages
yarn add @swapkit/core @swapkit/plugins @swapkit/toolboxes @swapkit/wallets
Step 2: Update Imports
Section titled “Step 2: Update Imports”Replace all v3 imports with v4 equivalents:
-import { THORChainPlugin } from "@swapkit/plugin-thorchain";
-import { EVMToolbox } from "@swapkit/toolbox-evm";
-import { ledgerWallet } from "@swapkit/wallet-ledger";
+import { ThorchainPlugin } from "@swapkit/plugins/thorchain";
+import { getEvmToolbox } from "@swapkit/toolboxes/evm";
+import { ledgerWallet } from "@swapkit/wallets/ledger";
Step 3: Update Client Initialization
Section titled “Step 3: Update Client Initialization”-import { SwapKitCore } from "@swapkit/core";
+import { createSwapKit } from "@swapkit/sdk";
-const client = new SwapKitCore({
+const client = createSwapKit({
// config
});
Step 4: Update Wallet Connections
Section titled “Step 4: Update Wallet Connections”The wallet connection pattern remains similar but uses the new import paths:
import { function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
chainflip: {
supportedSwapkitProviders: ProviderName[];
} & {
swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
};
... 5 more ...;
near: {
...;
} & {
...;
};
} & {
...;
} & {
...;
}
createSwapKit, enum Chain
Chain } from "@swapkit/sdk";
const const client: {
chainflip: {
supportedSwapkitProviders: ProviderName[];
} & {
swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
};
... 5 more ...;
near: {
...;
} & {
...;
};
} & {
...;
} & {
...;
}
client = function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
chainflip: {
supportedSwapkitProviders: ProviderName[];
} & {
swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
};
... 5 more ...;
near: {
...;
} & {
...;
};
} & {
...;
} & {
...;
}
createSwapKit({
// your config
});
// Connect EVM wallet
await const client: {
chainflip: {
supportedSwapkitProviders: ProviderName[];
} & {
swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
};
... 5 more ...;
near: {
...;
} & {
...;
};
} & {
...;
} & {
...;
}
client.connectEVMWallet: (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>
connectEVMWallet([enum Chain
Chain.function (enum member) Chain.Ethereum = "ETH"
Ethereum]);
// Connect keystore wallet
const const chains: Chain[]
chains = [enum Chain
Chain.function (enum member) Chain.Bitcoin = "BTC"
Bitcoin, enum Chain
Chain.function (enum member) Chain.Ethereum = "ETH"
Ethereum, enum Chain
Chain.function (enum member) Chain.Cosmos = "GAIA"
Cosmos];
const const phrase: "your mnemonic phrase here"
phrase = "your mnemonic phrase here";
await const client: {
chainflip: {
supportedSwapkitProviders: ProviderName[];
} & {
swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
};
... 5 more ...;
near: {
...;
} & {
...;
};
} & {
...;
} & {
...;
}
client.connectKeystore: (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
ARB?: DerivationPathArray | undefined;
AVAX?: DerivationPathArray | undefined;
... 21 more ...;
TRX?: DerivationPathArray | undefined;
} | undefined) => Promise<boolean>
connectKeystore(const chains: Chain[]
chains, const phrase: "your mnemonic phrase here"
phrase);
New Features in v4
Section titled “New Features in v4”1. Runtime Configuration Updates (Major Improvement)
Section titled “1. Runtime Configuration Updates (Major Improvement)”The biggest improvement in v4 is the ability to update configuration at runtime without recreating the SwapKit client.
v3 Approach (Client Recreation Required)
Section titled “v3 Approach (Client Recreation Required)”// v3 - Had to recreate entire client for config changes
const const client1: any
client1 = Cannot find name 'SwapKit'.SwapKit({
rpcUrls: {
[x: number]: string;
}
rpcUrls: { [Cannot find name 'Chain'. Did you mean 'Chai'?Chain.Ethereum]: "https://public-rpc.com" },
apis: {
[x: number]: any;
}
apis: { [Cannot find name 'Chain'. Did you mean 'Chai'?ChainCannot find name 'customBtcApi'..Bitcoin]: customBtcApi }
});
// To change RPC URL, needed to create new client
const const client2: any
client2 = Cannot find name 'SwapKit'.SwapKit({
rpcUrls: {
[x: number]: string;
}
rpcUrls: { [Cannot find name 'Chain'. Did you mean 'Chai'?Chain.Ethereum]: "https://premium-rpc.com" },
apis: {
[x: number]: any;
}
apis: { [Cannot find name 'Chain'. Did you mean 'Chai'?ChainCannot find name 'customBtcApi'..Bitcoin]: customBtcApi }
});
v4 Approach (Runtime Updates)
Section titled “v4 Approach (Runtime Updates)”import { function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
chainflip: {
supportedSwapkitProviders: ProviderName[];
} & {
swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
};
... 5 more ...;
near: {
...;
} & {
...;
};
} & {
...;
} & {
...;
}
createSwapKit, const SKConfig: {
getState: () => SwapKitConfigStore;
get: <T extends "wallets" | "apiKeys" | "apis" | "chains" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations">(key: T) => SwapKitConfigStore[T];
... 6 more ...;
setIntegrationConfig: <T extends keyof SKConfigIntegrations>(integration: T, config: SKConfigIntegrations[T]) => void;
}
SKConfig, enum Chain
Chain } from '@swapkit/sdk';
// Create client once
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 | undefined
config: {
rpcUrls?: Partial<Record<Chain | StagenetChain, string>> | undefined
rpcUrls: { [enum Chain
Chain.function (enum member) Chain.Ethereum = "ETH"
Ethereum]: "https://public-rpc.com" },
apiKeys?: Partial<{
blockchair: string;
keepKey: string;
swapKit: string;
walletConnectProjectId: string;
}> | undefined
apiKeys: { blockchair?: string | undefined
blockchair: "basic-key" }
}
});
// Update configuration at runtime - client continues working with new config
const SKConfig: {
getState: () => SwapKitConfigStore;
get: <T extends "wallets" | "apiKeys" | "apis" | "chains" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations">(key: T) => SwapKitConfigStore[T];
... 6 more ...;
setIntegrationConfig: <T extends keyof SKConfigIntegrations>(integration: T, config: SKConfigIntegrations[T]) => void;
}
SKConfig.setRpcUrl: <Chain.Ethereum>(chain: Chain.Ethereum, url: string) => void
setRpcUrl(enum Chain
Chain.function (enum member) Chain.Ethereum = "ETH"
Ethereum, "https://premium-rpc.com");
const SKConfig: {
getState: () => SwapKitConfigStore;
get: <T extends "wallets" | "apiKeys" | "apis" | "chains" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations">(key: T) => SwapKitConfigStore[T];
... 6 more ...;
setIntegrationConfig: <T extends keyof SKConfigIntegrations>(integration: T, config: SKConfigIntegrations[T]) => void;
}
SKConfig.setApiKey: <"blockchair">(key: "blockchair", apiKey: string) => void
setApiKey("blockchair", "premium-api-key");
// Switch to testnet mode
const SKConfig: {
getState: () => SwapKitConfigStore;
get: <T extends "wallets" | "apiKeys" | "apis" | "chains" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations">(key: T) => SwapKitConfigStore[T];
... 6 more ...;
setIntegrationConfig: <T extends keyof SKConfigIntegrations>(integration: T, config: SKConfigIntegrations[T]) => void;
}
SKConfig.setEnv: <"isStagenet">(key: "isStagenet", value: boolean) => void
setEnv("isStagenet", true);
// All subsequent operations automatically use new configuration!
const const balance: AssetValue[]
balance = 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 Chain
Chain.function (enum member) Chain.Ethereum = "ETH"
Ethereum); // Uses premium RPC
2. Individual Configuration Updates
Section titled “2. Individual Configuration Updates”Update specific parts of configuration without affecting others:
// Update API keys individually
Cannot find name 'SKConfig'.SKConfig.setApiKey("swapKit", "your-swapkit-api-key");
Cannot find name 'SKConfig'.SKConfig.setApiKey("walletConnectProjectId", "your-wc-project-id");
Cannot find name 'SKConfig'.SKConfig.setApiKey("blockchair", "your-blockchair-key");
// Update RPC URLs for specific chains
Cannot find name 'SKConfig'.SKConfigCannot find name 'Chain'. Did you mean 'Chai'?.setRpcUrl(Chain.Ethereum, "https://ethereum-rpc.com");
Cannot find name 'SKConfig'.SKConfigCannot find name 'Chain'. Did you mean 'Chai'?.setRpcUrl(Chain.Arbitrum, "https://arbitrum-rpc.com");
Cannot find name 'SKConfig'.SKConfigCannot find name 'Chain'. Did you mean 'Chai'?.setRpcUrl(Chain.Avalanche, "https://avalanche-rpc.com");
// Update environment settings
Cannot find name 'SKConfig'.SKConfig.setEnv("isDev", false);
Cannot find name 'SKConfig'.SKConfig.setEnv("isStagenet", true);
// Update integration configurations
Cannot find name 'SKConfig'.SKConfig.setIntegrationConfig("radix", {
dAppDefinitionAddress: string
dAppDefinitionAddress: "account_rdx...",
applicationName: string
applicationName: "My DeFi App",
applicationVersion: string
applicationVersion: "1.0.0",
network: {
networkId: number;
networkName: string;
}
network: { networkId: number
networkId: 1, networkName: string
networkName: "mainnet" }
});
3. Bulk Configuration Updates
Section titled “3. Bulk Configuration Updates”Update multiple configurations at once:
// Update multiple settings simultaneously
Cannot find name 'SKConfig'.SKConfig.set({
rpcUrls: {
[x: number]: string;
}
rpcUrls: {
[Cannot find name 'Chain'. Did you mean 'Chai'?Chain.Ethereum]: "https://ethereum-rpc.com",
[Cannot find name 'Chain'. Did you mean 'Chai'?Chain.Arbitrum]: "https://arbitrum-rpc.com",
[Cannot find name 'Chain'. Did you mean 'Chai'?Chain.Avalanche]: "https://avalanche-rpc.com"
},
apiKeys: {
blockchair: string;
swapKit: string;
walletConnectProjectId: string;
}
apiKeys: {
blockchair: string
blockchair: "premium-blockchair-key",
swapKit: string
swapKit: "premium-swapkit-key",
walletConnectProjectId: string
walletConnectProjectId: "your-project-id"
},
envs: {
isStagenet: boolean;
isDev: boolean;
}
envs: {
isStagenet: boolean
isStagenet: false,
isDev: boolean
isDev: false
}
});
4. Dynamic Environment Switching
Section titled “4. Dynamic Environment Switching”Switch between mainnet and testnet without recreating client:
// Start on mainnet
const const swapKit: any
swapKit = Cannot find name 'createSwapKit'.createSwapKit();
// Switch to testnet for testing
Cannot find name 'SKConfig'.SKConfig.setEnv("isStagenet", true);
Cannot find name 'SKConfig'.SKConfigCannot find name 'Chain'. Did you mean 'Chai'?.setRpcUrl(Chain.THORChain, "https://stagenet-thornode.ninerealms.com");
// All operations now use testnet
await const swapKit: any
swapKit.connectKeystore([Cannot find name 'Chain'. Did you mean 'Chai'?ChainCannot find name 'phrase'..THORChain], phrase);
const const balance: any
balance = await const swapKit: any
swapKit.getBalance(Cannot find name 'Chain'. Did you mean 'Chai'?Chain.THORChain); // Testnet balance
// Switch back to mainnet
Cannot find name 'SKConfig'.SKConfig.setEnv("isStagenet", false);
Cannot find name 'SKConfig'.SKConfigCannot find name 'Chain'. Did you mean 'Chai'?.setRpcUrl(Chain.THORChain, "https://thornode.ninerealms.com");
5. How Toolboxes Automatically Use Updated Config
Section titled “5. How Toolboxes Automatically Use Updated Config”All toolboxes in v4 dynamically retrieve configuration from SKConfig:
// When you call this...
const const ethToolbox: any
ethToolbox = await Cannot find name 'getEvmToolbox'. Did you mean 'ethToolbox'?getEvmToolboxCannot find name 'Chain'. Did you mean 'Chai'?(Chain.Ethereum);
// Internally, it gets the RPC URL from SKConfig
const const rpcUrl: any
rpcUrl = Cannot find name 'SKConfig'.SKConfigCannot find name 'Chain'. Did you mean 'Chai'?.get("rpcUrls")[Chain.Ethereum];
const const provider: any
provider = new Cannot find name 'JsonRpcProvider'.JsonRpcProvider(const rpcUrl: any
rpcUrl);
// So when you update the RPC URL...
Cannot find name 'SKConfig'.SKConfigCannot find name 'Chain'. Did you mean 'Chai'?.setRpcUrl(Chain.Ethereum, "https://new-rpc.com");
// The next toolbox instance automatically uses the new URL
const const newEthToolbox: any
newEthToolbox = await Cannot find name 'getEvmToolbox'. Did you mean 'ethToolbox'?getEvmToolboxCannot find name 'Chain'. Did you mean 'Chai'?(Chain.Ethereum); // Uses new RPC!
6. Standardized Creation Helpers
Section titled “6. Standardized Creation Helpers”createPlugin
: Streamlined plugin creation with consistent interfacecreateWallet
: Simplified wallet adapter development
7. Enhanced Chain Support
Section titled “7. Enhanced Chain Support”- Improved Solana Support: Jupiter API integration for real-time token metadata
- Dynamic Cosmos Fees: Automatic fee estimation when not provided
- Ripple Support: Full XRP toolbox implementation
- OneKey Wallet: New wallet integration
8. Configuration State Preservation
Section titled “8. Configuration State Preservation”Updates preserve existing configuration:
// Set initial API key
Cannot find name 'SKConfig'.SKConfig.setApiKey("swapKit", "key1");
// Add another API key - preserves existing ones
Cannot find name 'SKConfig'.SKConfig.setApiKey("blockchair", "key2");
// Both keys are now available
const const apiKeys: any
apiKeys = Cannot find name 'SKConfig'.SKConfig.get("apiKeys");
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.log(const apiKeys: any
apiKeys.swapKit); // "key1"
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.log(const apiKeys: any
apiKeys.blockchair); // "key2"
Common Migration Issues
Section titled “Common Migration Issues”1. TypeScript Errors
Section titled “1. TypeScript Errors”// Error: Module '@swapkit/api' has no exported member 'SwapKitApi'
// Solution: Update import
import { 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";
2. Missing RPC URL Parameter
Section titled “2. Missing RPC URL Parameter”// Error: Argument of type '{ signer }' is not assignable...
// Solution: Configure via SKConfig
import { const SKConfig: {
getState: () => SwapKitConfigStore;
get: <T extends "apiKeys" | "apis" | "chains" | "wallets" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations">(key: T) => SwapKitConfigStore[T];
... 6 more ...;
setIntegrationConfig: <T extends keyof SKConfigIntegrations>(integration: T, config: SKConfigIntegrations[T]) => void;
}
SKConfig, enum Chain
Chain, 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/sdk";
const SKConfig: {
getState: () => SwapKitConfigStore;
get: <T extends "apiKeys" | "apis" | "chains" | "wallets" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations">(key: T) => SwapKitConfigStore[T];
... 6 more ...;
setIntegrationConfig: <T extends keyof SKConfigIntegrations>(integration: T, config: SKConfigIntegrations[T]) => void;
}
SKConfig.set: <{
rpcUrls: {
ETH: string;
};
}>(config: {
rpcUrls: {
ETH: string;
};
}) => void
set({ rpcUrls: {
ETH: string;
}
rpcUrls: { [enum Chain
Chain.function (enum member) Chain.Ethereum = "ETH"
Ethereum]: "https://..." } });
const const signer: any
signer = /* your signer instance */Expression expected.;
const const toolbox: Promise<{
estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
feeOption: FeeOption;
chain: EVMChain;
}) => Promise<...>;
... 20 more ...;
validateAddress: (address: string) => boolean;
} | {
...;
} | {
...;
}>
toolbox = 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 Chain
Chain.function (enum member) Chain.Ethereum = "ETH"
Ethereum, { signer?: (ChainSigner<EVMTransferParams, string> & Signer) | JsonRpcSigner | undefined
signer });
3. Plugin Interface Mismatch
Section titled “3. Plugin Interface Mismatch”// Error: Type '{ swap }' is not assignable...
// Solution: Use createPlugin helper
import { function createPlugin<const Name extends string, T extends (params: SwapKitPluginParams) => Record<string, unknown>, K extends {
supportedSwapkitProviders?: (ProviderName | string)[];
}>({ name, properties, methods }: {
name: Name;
properties?: K;
methods: T;
}): { [key in Name]: (pluginParams: SwapKitPluginParams) => K & ReturnType<T>; }
createPlugin } from "@swapkit/sdk";
const const swap: (params: any) => Promise<void>
swap = async (Parameter 'params' implicitly has an 'any' type.params) => { /* implementation */ };
export const const MyPlugin: {
myPlugin: (pluginParams: SwapKitPluginParams) => {
supportedSwapkitProviders?: (ProviderName | string)[];
} & {
...;
};
}
MyPlugin = createPlugin<"myPlugin", ({ getWallet }: SwapKitPluginParams) => {
swap: (params: any) => Promise<void>;
}, {
supportedSwapkitProviders?: (ProviderName | string)[];
}>({ name, properties, methods }: {
...;
}): {
...;
}
createPlugin({
name: "myPlugin"
name: "myPlugin",
methods: ({ getWallet }: SwapKitPluginParams) => {
swap: (params: any) => Promise<void>;
}
methods: ({ getWallet: <T extends CryptoChain>(chain: T) => FullWallet[T]
getWallet }) => ({ swap: (params: any) => Promise<void>
swap })
});
Migration Checklist
Section titled “Migration Checklist”- Update all package dependencies
- Replace all import paths
- Update client initialization code
- Configure SKConfig for RPC URLs and API keys
- Update custom plugins to use
createPlugin
- Update custom wallets to use
createWallet
- Remove direct API/RPC parameters from toolboxes
- Test all functionality thoroughly
Need Help?
Section titled “Need Help?”- 💬 Join our Discord for migration support
- 🐛 Report issues on GitHub
- 📚 Check the Getting Started guide for v4 patterns