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

API Reference

The SwapKitApi provides access to swap quotes, price feeds, token lists, and other essential data. All methods are available through the @swapkit/helpers/api 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/helpers/api';
// All methods are static - no initialization needed const
const price: {
    identifier?: string | undefined;
    provider?: string | undefined;
    timestamp?: number | undefined;
    cg?: {
        id: string;
        market_cap: number;
        name: string;
        price_change_24h_usd: number;
        price_change_percentage_24h_usd: number;
        sparkline_in_7d: number[];
        timestamp: string;
        total_volume: number;
    } | undefined;
    price_usd?: number | undefined;
}[]
price
= 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 getPrice(body: PriceRequest): Promise<{
    identifier?: string | undefined;
    provider?: string | undefined;
    timestamp?: number | undefined;
    cg?: {
        id: string;
        market_cap: number;
        ... 5 more ...;
        total_volume: number;
    } | undefined;
    price_usd?: number | undefined;
}[]>
getPrice
({
Object literal may only specify known properties, and 'identifier' does not exist in type '{ tokens: { identifier: string; }[]; metadata: boolean; }'.
identifier
: 'ETH.ETH',
currency: stringcurrency: 'USD' });

Get swap quotes from multiple providers with best route selection:

const { const routes: anyroutes } = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getSwapQuote({
sellAsset: stringsellAsset: 'ETH.ETH', sellAmount: stringsellAmount: '1000000000000000000', // 1 ETH in base units buyAsset: stringbuyAsset: 'BTC.BTC', sourceAddress: stringsourceAddress: '0x...', // Your ETH address destinationAddress: stringdestinationAddress: 'bc1q...', // Your BTC address slippage: numberslippage: 3, // 3% slippage tolerance providers: string[]providers: ['thorchain', 'chainflip', '1inch'], // Optional: specific providers affiliate: stringaffiliate: 'your-affiliate-id', // Optional: affiliate tracking affiliateFee: numberaffiliateFee: 100 // Optional: basis points (100 = 1%) }); // Response structure { routes: [{ providers: string[]providers: ['THORCHAIN'], sellAsset: stringsellAsset: 'ETH.ETH', sellAmount: stringsellAmount: '1000000000000000000', buyAsset: stringbuyAsset: 'BTC.BTC', expectedBuyAmount: stringexpectedBuyAmount: '62500000', // 0.625 BTC expectedBuyAmountMaxSlippage: stringexpectedBuyAmountMaxSlippage: '60625000', // With 3% slippage sourceAddress: stringsourceAddress: '0x...', destinationAddress: stringdestinationAddress: 'bc1q...', targetAddress: stringtargetAddress: '0x...', // Contract to send to memo: stringmemo: 'SWAP:BTC.BTC:bc1q...', expiration: stringexpiration: '2024-01-01T00:00:00Z',
fee: {
    asset: string;
    networkFee: string;
    affiliateFee: string;
    totalFee: string;
}
fee
: {
asset: stringasset: 'ETH.ETH', networkFee: stringnetworkFee: '5000000000000000', // Network fee affiliateFee: stringaffiliateFee: '10000000000000000', // Affiliate fee totalFee: stringtotalFee: '15000000000000000' // Total fees },
estimatedTime: {
    inbound: number;
    outbound: number;
    total: number;
}
estimatedTime
: {
inbound: numberinbound: 600, // 10 minutes inbound outbound: numberoutbound: 600, // 10 minutes outbound total: numbertotal: 1200 // 20 minutes total } }] }

Get current asset prices:

// Single asset price
const const priceData: anypriceData = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getPrice({
identifier: stringidentifier: 'ETH.ETH', currency: stringcurrency: 'USD' // Optional, defaults to USD }); // Returns: [{ identifier: 'ETH.ETH', price: 2500.50 }] // Multiple assets const const prices: anyprices = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.getPrice({
identifiers: string[]identifiers: ['ETH.ETH', 'BTC.BTC', 'AVAX.AVAX'], currency: stringcurrency: 'USD' }); // Returns: [ // { identifier: 'ETH.ETH', price: 2500.50 }, // { identifier: 'BTC.BTC', price: 45000.00 }, // { identifier: 'AVAX.AVAX', price: 35.20 } // ] // With specific token addresses const const tokenPrice: anytokenPrice = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.getPrice({
identifier: stringidentifier: 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' });

Get all token balances for an address on a specific chain with scam filtering:

const const balances: anybalances = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getChainBalance({
chain: stringchain: 'ETH', address: stringaddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f6E321', scamFilter: booleanscamFilter: true // Optional, defaults to true }); // Response includes native and token balances [ { identifier: stringidentifier: 'ETH.ETH', value: stringvalue: '1500000000000000000', // 1.5 ETH decimal: numberdecimal: 18 }, { identifier: stringidentifier: 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', value: stringvalue: '1000000000', // 1000 USDC decimal: numberdecimal: 6 } ]

Get current gas rates for supported chains:

// Get gas rates for all chains
const const gasRates: anygasRates = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getGasRate();
// Response format { ETH: { low:
Left side of comma operator is unused and has no side effects.
'20'
, // Gwei
Cannot find name 'average'.
average
Left side of comma operator is unused and has no side effects.
';' expected.
: '25', // Gwei
Cannot find name 'high'.
high
';' expected.
: '30' // Gwei
}
Declaration or statement expected.
,
BTC: { low:
Left side of comma operator is unused and has no side effects.
'5'
, // Satoshis per byte
Cannot find name 'average'.
average
Left side of comma operator is unused and has no side effects.
';' expected.
: '10', // Satoshis per byte
Cannot find name 'high'.
high
';' expected.
: '15' // Satoshis per byte
}
Declaration or statement expected.
,
AVAX: { low:
Left side of comma operator is unused and has no side effects.
'25'
, // nAVAX
Cannot find name 'average'.
average
Left side of comma operator is unused and has no side effects.
';' expected.
: '30', // nAVAX
Cannot find name 'high'.
high
';' expected.
: '35' // nAVAX
} }

Get comprehensive token metadata from a specific provider:

// Get tokens from a specific provider
const const tokens: anytokens = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getTokenList('thorswap');
// Response structure [ { chain: stringchain: 'ETH', symbol: stringsymbol: 'USDC', ticker: stringticker: 'USDC', identifier: stringidentifier: 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', address: stringaddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', decimals: numberdecimals: 6, logoURL: stringlogoURL: 'https://...', name: stringname: 'USD Coin' } ]

Get list of available token list providers:

const const providers: anyproviders = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getTokenListProviders();
// Returns available providers [ { name: stringname: 'thorswap', url: stringurl: 'https://...' }, { name: stringname: '1inch', url: stringurl: 'https://...' }, { name: stringname: 'coingecko', url: stringurl: 'https://...' }, { name: stringname: 'uniswap', url: stringurl: 'https://...' } ]

Track transaction status and progress:

const const status: anystatus = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getTrackerDetails({
txHash: stringtxHash: '0x123...', chain: stringchain: 'ETH', provider: stringprovider: 'thorchain', // Optional: specific provider actionId: stringactionId: 'swap_123' // Optional: action identifier }); // Response for swap transactions { status:
Left side of comma operator is unused and has no side effects.
'completed'
,
Cannot find name 'startTime'.
startTime
Left side of comma operator is unused and has no side effects.
';' expected.
: 1234567890,
Cannot find name 'endTime'.
endTime
Left side of comma operator is unused and has no side effects.
';' expected.
: 1234568490,
Cannot find name 'legs'.
legs
';' expected.
: [{
chain: stringchain: 'ETH', hash: stringhash: '0x123...', status: stringstatus: 'completed', inAmount: stringinAmount: '1000000000000000000', outAmount: stringoutAmount: '62500000' }] }

Get token list from static Thorswap CDN:

// Get specific token list
const const tokens: anytokens = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getStaticTokenList('thorswap');
// Response contains comprehensive token data [ { chain: stringchain: 'ETH', symbol: stringsymbol: 'USDC', ticker: stringticker: 'USDC', identifier: stringidentifier: 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', address: stringaddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', decimals: numberdecimals: 6, logoURL: stringlogoURL: 'https://static.thorswap.net/token-list/images/eth.usdc.png', name: stringname: 'USD Coin' } ]

Get logo URL for any asset:

// Get asset logo
const const logoUrl: anylogoUrl = 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getLogoForAsset('ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48');
// Returns: 'https://static.thorswap.net/token-list/images/eth.usdc-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.png' // Native assets const const ethLogo: anyethLogo =
Cannot find name 'SwapKitApi'.
SwapKitApi
.getLogoForAsset('ETH.ETH');
// Returns: 'https://static.thorswap.net/token-list/images/eth.eth.png'

Get chain logo for any asset:

// Get chain logo
const const chainLogo: anychainLogo = 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getChainLogoForAsset('ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48');
// Returns: 'https://static.thorswap.net/token-list/images/eth.png'

Get logo URL for token list providers:

const const providerLogo: anyproviderLogo = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getProviderLogo('1inch');
// Returns: 'https://...'

Access THORChain microgard services:

// Get THORName details
const const thorname: anythorname = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.microgard.getTHORNameDetails('myname');
// Get THORNames by owner const
Cannot redeclare block-scoped variable 'names'.
names
Cannot find name 'SwapKitApi'.
= await SwapKitApi.microgard.getTHORNamesByOwner('thor1...');
// Get THORNames by address const
Cannot redeclare block-scoped variable 'names'.
names
Cannot find name 'SwapKitApi'.
= await SwapKitApi.microgard.getTHORNamesByAddress('0x...');
// Get THORChain pools const const pools: anypools = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.microgard.getTHORChainPools('7d'); // '1h', '24h', '7d', '30d', '365d'
// Get liquidity positions const const positions: anypositions = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.microgard.getLiquidityPositions(['thor1...', 'thor2...']);
// Get TNS chain address const const address: anyaddress = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.microgard.getTNSChainAddress({
chain: stringchain: 'ETH', tns: stringtns: 'myname' });

Direct access to THORChain node data:

// Get last block
const const lastBlock: anylastBlock = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.thornode.getLastBlock('thorchain'); // or 'mayachain'
// Get THORChain queue const const queue: anyqueue = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.thornode.getThorchainQueue();
// Get node list const const nodes: anynodes = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.thornode.getNodes();
// Get Mimir settings const const mimir: anymimir = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.thornode.getMimirInfo();
// Get inbound addresses const const inboundAddresses: anyinboundAddresses = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.thornode.getInboundAddresses();
// Get THORNode TNS details const const tnsDetails: anytnsDetails = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.thornode.getTHORNodeTNSDetails({
name: stringname: 'myname', type: stringtype: 'thorchain' // or 'mayachain' }); // Get TNS preferred asset const const preferredAsset: anypreferredAsset = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.thornode.getTNSPreferredAsset({
tns: stringtns: 'myname', type: stringtype: 'thorchain' }); // Get RUNEPool info const const runePool: anyrunePool = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.thornode.getRunePoolInfo();
// Get RUNEPool provider info const const providerInfo: anyproviderInfo = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.thornode.getRunePoolProviderInfo({
thorAddress: stringthorAddress: 'thor1...' });

Access THORChain and Maya midgard data:

// THORChain Midgard
// Get liquidity position
const const thorLiquidity: anythorLiquidity = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.thorchainMidgard.getLiquidityPosition('thor1...');
// Get THORName details const const thorName: anythorName = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.thorchainMidgard.getNameDetails('myname');
// Get THORNames by address const const namesByAddress: anynamesByAddress = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.thorchainMidgard.getNamesByAddress('0x...');
// Get THORNames by owner const const namesByOwner: anynamesByOwner = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.thorchainMidgard.getNamesByOwner('thor1...');
// Maya Midgard - same methods available const const mayaLiquidity: anymayaLiquidity = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.mayachainMidgard.getLiquidityPosition('maya1...');
const const mayaName: anymayaName = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.mayachainMidgard.getNameDetails('myname');

Create deposit channels for Chainflip swaps:

const const channel: anychannel = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getChainflipDepositChannel({
sellAsset: {
    chain: string;
    asset: string;
}
sellAsset
: {
chain: stringchain: 'ETH', asset: stringasset: 'ETH' },
buyAsset: {
    chain: string;
    asset: string;
}
buyAsset
: {
chain: stringchain: 'BTC', asset: stringasset: 'BTC' }, destinationAddress: stringdestinationAddress: 'bc1q...', brokerCommissionBps: numberbrokerCommissionBps: 100, // Optional: 1% commission
affiliateFees: {
    brokerAddress: string;
    feeBps: number;
}[]
affiliateFees
: [ // Optional: affiliate fees
{ brokerAddress: stringbrokerAddress: '0x...', feeBps: numberfeeBps: 50 } ],
channelMetadata: {
    cfParameters: string;
    gasBudget: string;
    message: string;
}
channelMetadata
: { // Optional: additional parameters
cfParameters: stringcfParameters: '...', gasBudget: stringgasBudget: '1000000', message: stringmessage: 'Swap via SwapKit' },
refundParameters: {
    minPrice: string;
    refundAddress: string;
    retryDuration: number;
}
refundParameters
: { // Optional: refund settings
minPrice: stringminPrice: '0.01', refundAddress: stringrefundAddress: '0x...', retryDuration: numberretryDuration: 3600 },
dcaParameters: {
    numberOfChunks: number;
    chunkInterval: number;
}
dcaParameters
: { // Optional: DCA settings
numberOfChunks: numbernumberOfChunks: 10, chunkInterval: numberchunkInterval: 600 }, maxBoostFeeBps: numbermaxBoostFeeBps: 200 // Optional: max boost fee }); // Response { depositChannelId:
Left side of comma operator is unused and has no side effects.
'123456'
,
Cannot find name 'depositAddress'.
depositAddress
Left side of comma operator is unused and has no side effects.
';' expected.
: '0x...', // Send funds here
Cannot find name 'brokerCommissionBps'.
brokerCommissionBps
Left side of comma operator is unused and has no side effects.
';' expected.
: 100,
Cannot find name 'estimatedExpiryTime'.
estimatedExpiryTime
Left side of comma operator is unused and has no side effects.
';' expected.
: 1234567890,
Cannot find name 'expiryBlock'.
expiryBlock
Left side of comma operator is unused and has no side effects.
';' expected.
: 123456,
Cannot find name 'issuedBlock'.
issuedBlock
Left side of comma operator is unused and has no side effects.
';' expected.
: 123400,
Cannot find name 'sourceChainExpiryBlock'.
sourceChainExpiryBlock
';' expected.
: 234567
}

The SwapKit API has rate limits that vary by endpoint:

  • Without API key: 10 requests per minute
  • With API key: 100 requests per minute

Configure your API key in Configuration:

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
: {
swapKit?: string | undefinedswapKit: 'your-api-key' } } });

All API methods can throw errors that should be handled:

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

try {
  const const quote: anyquote = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
Expression expected.
.getSwapQuote({...});
} catch (var error: unknownerror) { if (var error: unknownerror instanceof class SwapKitErrorSwapKitError) { // Handle SwapKit-specific errors 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
('API Error:', var error: SwapKitErrorerror.Error.message: stringmessage);
// Check for rate limiting if (var error: SwapKitErrorerror.
Property 'code' does not exist on type 'SwapKitError'.
code
=== 'api_rate_limit') {
// Wait and retry } } }

When getting swap quotes, the first route is typically the best:

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

const { const routes: anyroutes } = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
Expression expected.
.getSwapQuote({...});
if (const routes: anyroutes.length > 0) { const const bestRoute: anybestRoute = const routes: anyroutes[0]; // Check if route meets your requirements const const minOutput: AssetValueminOutput = class AssetValueAssetValue.
AssetValue.from<{
    asset: any;
    value: any;
    fromBaseDecimal: boolean;
}>({ value, fromBaseDecimal, asyncTokenLookup, ...fromAssetOrChain }: never): AssetValue
from
({
Type 'any' is not assignable to type 'never'.
asset
: const bestRoute: anybestRoute.buyAsset,
Type 'any' is not assignable to type 'never'.
value
: const bestRoute: anybestRoute.expectedBuyAmountMaxSlippage,
Type 'true' is not assignable to type 'never'.
fromBaseDecimal
: true
}); if (const minOutput: AssetValueminOutput.BigIntArithmetics.gte(value: InitialisationValueType): booleangte(
Cannot find name 'requiredAmount'.
requiredAmount
)) {
await
Cannot find name 'swapKit'.
swapKit
.swap({ route: anyroute: const bestRoute: anybestRoute });
} }

Calculate price impact for large swaps:

const const quote: anyquote = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
Expression expected.
.getSwapQuote({...});
const const route: anyroute = const quote: anyquote.routes[0]; // Get current prices const const sellPrice: anysellPrice = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.getPrice(const route: anyroute.sellAsset);
const const buyPrice: anybuyPrice = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.getPrice(const route: anyroute.buyAsset);
// Calculate expected value const const sellValue: numbersellValue =
var Number: NumberConstructor
(value?: any) => number
An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.
Number
(const route: anyroute.sellAmount) * const sellPrice: anysellPrice;
const const buyValue: numberbuyValue =
var Number: NumberConstructor
(value?: any) => number
An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.
Number
(const route: anyroute.expectedBuyAmount) * const buyPrice: anybuyPrice;
// Calculate price impact const const priceImpact: numberpriceImpact = ((const sellValue: numbersellValue - const buyValue: numberbuyValue) / const sellValue: numbersellValue) * 100; 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
(`Price impact: ${const priceImpact: numberpriceImpact.Number.toFixed(fractionDigits?: number): string
Returns a string representing a number in fixed-point notation.
@paramfractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.
toFixed
(2)}%`);

Validate tokens before swapping:

async function 
function validateToken(identifier: string): Promise<{
    valid: boolean;
    decimals: any;
    name: any;
    logo: any;
} | {
    valid: boolean;
    decimals?: undefined;
    name?: undefined;
    logo?: undefined;
}>
validateToken
(identifier: stringidentifier: string) {
try { const const token: anytoken = await
Cannot find name 'SwapKitApi'.
SwapKitApi
.getTokenList(identifier: stringidentifier);
return { valid: booleanvalid: true, decimals: anydecimals: const token: anytoken.decimals, name: anyname: const token: anytoken.name, logo: anylogo: const token: anytoken.logoURL }; } catch { return { valid: booleanvalid: false }; } }

The SKConfig API provides methods to manage SwapKit’s configuration at runtime. This includes RPC URLs, API keys, custom headers, and environment settings:

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
} from '@swapkit/sdk';
// Get configuration values const const rpcUrls: Record<Chain | StagenetChain, string>rpcUrls =
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
.get: <"rpcUrls">(key: "rpcUrls") => Record<Chain | StagenetChain, string>get('rpcUrls');
const
const apiKeys: {
    blockchair: string;
    keepKey: string;
    swapKit: string;
    walletConnectProjectId: string;
}
apiKeys
=
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
.
get: <"apiKeys">(key: "apiKeys") => {
    blockchair: string;
    keepKey: string;
    swapKit: string;
    walletConnectProjectId: string;
}
get
('apiKeys');
const
const midgardUrls: {
    ARB: any;
    AVAX: any;
    BASE: any;
    BSC: any;
    BTC: any;
    BCH: any;
    GAIA: any;
    DASH: any;
    DOGE: any;
    ETH: any;
    FIAT: any;
    KUJI: any;
    LTC: any;
    MAYA: any;
    NEAR: any;
    OP: any;
    DOT: any;
    FLIP: any;
    MATIC: any;
    XRD: any;
    XRP: any;
    THOR: any;
    SOL: any;
    TRX: any;
} | ... 7 more ... | {
    ...;
}
midgardUrls
=
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
.
get: <"apiKeys" | "apis" | "chains" | "wallets" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations">(key: "apiKeys" | "apis" | "chains" | "wallets" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations") => {
    ...;
} | ... 7 more ... | {
    ...;
}
get
(
Argument of type '"midgardUrls"' is not assignable to parameter of type '"apiKeys" | "apis" | "chains" | "wallets" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations"'.
'midgardUrls'
);
const
const apiHeaders: {
    ARB: any;
    AVAX: any;
    BASE: any;
    BSC: any;
    BTC: any;
    BCH: any;
    GAIA: any;
    DASH: any;
    DOGE: any;
    ETH: any;
    FIAT: any;
    KUJI: any;
    LTC: any;
    MAYA: any;
    NEAR: any;
    OP: any;
    DOT: any;
    FLIP: any;
    MATIC: any;
    XRD: any;
    XRP: any;
    THOR: any;
    SOL: any;
    TRX: any;
} | ... 7 more ... | {
    ...;
}
apiHeaders
=
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
.
get: <"apiKeys" | "apis" | "chains" | "wallets" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations">(key: "apiKeys" | "apis" | "chains" | "wallets" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations") => {
    ...;
} | ... 7 more ... | {
    ...;
}
get
(
Argument of type '"apiHeaders"' is not assignable to parameter of type '"apiKeys" | "apis" | "chains" | "wallets" | "explorerUrls" | "nodeUrls" | "rpcUrls" | "envs" | "integrations"'.
'apiHeaders'
);
// Set complete configuration
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;
    };
    apiKeys: {
        swapKit: string;
    };
    midgardUrls: {
        THOR: string;
    };
    apiHeaders: {
        midgard: {
            'X-API-Key': string;
        };
    };
}>(config: {
    rpcUrls: {
        ETH: string;
    };
    apiKeys: {
        swapKit: string;
    };
    midgardUrls: {
        THOR: string;
    };
    apiHeaders: {
        midgard: {
            'X-API-Key': string;
        };
    };
}) => void
set
({
rpcUrls: {
    ETH: string;
}
rpcUrls
: { type ETH: stringETH: 'https://new-rpc.com' },
apiKeys: {
    swapKit: string;
}
apiKeys
: { swapKit: stringswapKit: 'new-key' },
midgardUrls: {
    THOR: string;
}
midgardUrls
: { type THOR: stringTHOR: 'https://custom-midgard.com' },
apiHeaders: {
    midgard: {
        'X-API-Key': string;
    };
}
apiHeaders
: {
midgard: {
    'X-API-Key': string;
}
midgard
: { 'X-API-Key': 'secret' } }
});
// Set individual API keys
Cannot find name 'SKConfig'.
SKConfig
.setApiKey('swapKit', 'your-swapkit-key');
Cannot find name 'SKConfig'.
SKConfig
.setApiKey('blockchair', 'your-blockchair-key');
Cannot find name 'SKConfig'.
SKConfig
.setApiKey('walletConnectProjectId', 'your-wc-id');
import { enum ChainChain } from '@swapkit/sdk';

// Set RPC URL for specific chain
Cannot find name 'SKConfig'.
SKConfig
.setRpcUrl(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum, 'https://eth-mainnet.g.alchemy.com/v2/key');
Cannot find name 'SKConfig'.
SKConfig
.setRpcUrl(enum ChainChain.function (enum member) Chain.Avalanche = "AVAX"Avalanche, 'https://api.avax.network/ext/bc/C/rpc');
import { enum ChainChain } from '@swapkit/sdk';

// Set custom Midgard URLs
Cannot find name 'SKConfig'.
SKConfig
.setMidgardUrl(enum ChainChain.function (enum member) Chain.THORChain = "THOR"THORChain, 'https://custom-midgard.com');
Cannot find name 'SKConfig'.
SKConfig
.setMidgardUrl(enum ChainChain.function (enum member) Chain.Maya = "MAYA"Maya, 'https://maya-midgard.com');
// Note: When isStagenet is true, SwapKit automatically uses stagenet URLs: // - THORChain: https://stagenet-midgard.ninerealms.com // - Maya: https://stagenet-midgard.mayachain.info
// Set headers for specific APIs
Cannot find name 'SKConfig'.
SKConfig
.setApiHeaders('midgard', {
'X-Client-ID': 'your-client-id' }); // Headers for THORNode API
Cannot find name 'SKConfig'.
SKConfig
.setApiHeaders('thornode', {
'X-Client-ID': 'your-client-id' }); // Headers for SwapKit API (in addition to automatic x-api-key)
Cannot find name 'SKConfig'.
SKConfig
.setApiHeaders('swapkitApi', {
'X-API-Key': 'additional-api-key' });
// Set environment flags
Cannot find name 'SKConfig'.
SKConfig
.setEnv('isDev', true);
Cannot find name 'SKConfig'.
SKConfig
.setEnv('isStagenet', true);
// API URLs
Cannot find name 'SKConfig'.
SKConfig
.setEnv('apiUrl', 'https://api.swapkit.dev');
Cannot find name 'SKConfig'.
SKConfig
.setEnv('devApiUrl', 'https://dev-api.swapkit.dev');
// Radix configuration
Cannot find name 'SKConfig'.
SKConfig
.setIntegrationConfig('radix', {
dAppDefinitionAddress: stringdAppDefinitionAddress: 'account_rdx...', applicationName: stringapplicationName: 'My dApp', applicationVersion: stringapplicationVersion: '1.0.0',
network: {
    networkId: number;
    networkName: string;
    dashboardBase: string;
}
network
: {
networkId: numbernetworkId: 1, networkName: stringnetworkName: 'mainnet', dashboardBase: stringdashboardBase: 'https://dashboard.radixdlt.com' } }); // Chainflip configuration
Cannot find name 'SKConfig'.
SKConfig
.setIntegrationConfig('chainflip', {
useSDKBroker: booleanuseSDKBroker: true, brokerUrl: stringbrokerUrl: 'https://broker.chainflip.io' });
// Set custom explorer URLs
Cannot find name 'SKConfig'.
SKConfig
Cannot find name 'Chain'. Did you mean 'Chai'?
.setExplorerUrl(Chain.Ethereum, 'https://etherscan.io');
Cannot find name 'SKConfig'.
SKConfig
Cannot find name 'Chain'. Did you mean 'Chai'?
.setExplorerUrl(Chain.Bitcoin, 'https://blockstream.info');
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 ChainChain, enum StagenetChainStagenetChain } from '@swapkit/sdk';
// Configure multiple settings at once
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: <{
    apiKeys: {
        swapKit: string | undefined;
        blockchair: string | undefined;
    };
    rpcUrls: {
        ETH: string;
        MATIC: string;
    };
    midgardUrls: {
        THOR: string;
        THOR_STAGENET: string;
    };
    apiHeaders: {
        midgard: {
            ...;
        };
        thornode: {
            ...;
        };
    };
    envs: {
        ...;
    };
}>(config: {
    apiKeys: {
        swapKit: string | undefined;
        blockchair: string | undefined;
    };
    rpcUrls: {
        ETH: string;
        MATIC: string;
    };
    midgardUrls: {
        THOR: string;
        THOR_STAGENET: string;
    };
    apiHeaders: {
        midgard: {
            ...;
        };
        thornode: {
            ...;
        };
    };
    envs: {
        ...;
    };
}) => void
set
({
apiKeys: {
    swapKit: string | undefined;
    blockchair: string | undefined;
}
apiKeys
: {
swapKit: string | undefinedswapKit: var process: NodeJS.Processprocess.NodeJS.Process.env: NodeJS.ProcessEnv
The `process.env` property returns an object containing the user environment. See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html). An example of this object looks like: ```js { TERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', PWD: '/Users/maciej', EDITOR: 'vim', SHLVL: '1', HOME: '/Users/maciej', LOGNAME: 'maciej', _: '/usr/local/bin/node' } ``` It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or (unless explicitly requested) to other `Worker` threads. In other words, the following example would not work: ```bash node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo ``` While the following will: ```js import { env } from 'node:process'; env.foo = 'bar'; console.log(env.foo); ``` Assigning a property on `process.env` will implicitly convert the value to a string. **This behavior is deprecated.** Future versions of Node.js may throw an error when the value is not a string, number, or boolean. ```js import { env } from 'node:process'; env.test = null; console.log(env.test); // => 'null' env.test = undefined; console.log(env.test); // => 'undefined' ``` Use `delete` to delete a property from `process.env`. ```js import { env } from 'node:process'; env.TEST = 1; delete env.TEST; console.log(env.TEST); // => undefined ``` On Windows operating systems, environment variables are case-insensitive. ```js import { env } from 'node:process'; env.TEST = 1; console.log(env.test); // => 1 ``` Unless explicitly specified when creating a `Worker` instance, each `Worker` thread has its own copy of `process.env`, based on its parent thread's `process.env`, or whatever was specified as the `env` option to the `Worker` constructor. Changes to `process.env` will not be visible across `Worker` threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner unlike the main thread.
@sincev0.1.27
env
.string | undefinedSWAPKIT_API_KEY,
blockchair: string | undefinedblockchair: var process: NodeJS.Processprocess.NodeJS.Process.env: NodeJS.ProcessEnv
The `process.env` property returns an object containing the user environment. See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html). An example of this object looks like: ```js { TERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', PWD: '/Users/maciej', EDITOR: 'vim', SHLVL: '1', HOME: '/Users/maciej', LOGNAME: 'maciej', _: '/usr/local/bin/node' } ``` It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or (unless explicitly requested) to other `Worker` threads. In other words, the following example would not work: ```bash node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo ``` While the following will: ```js import { env } from 'node:process'; env.foo = 'bar'; console.log(env.foo); ``` Assigning a property on `process.env` will implicitly convert the value to a string. **This behavior is deprecated.** Future versions of Node.js may throw an error when the value is not a string, number, or boolean. ```js import { env } from 'node:process'; env.test = null; console.log(env.test); // => 'null' env.test = undefined; console.log(env.test); // => 'undefined' ``` Use `delete` to delete a property from `process.env`. ```js import { env } from 'node:process'; env.TEST = 1; delete env.TEST; console.log(env.TEST); // => undefined ``` On Windows operating systems, environment variables are case-insensitive. ```js import { env } from 'node:process'; env.TEST = 1; console.log(env.test); // => 1 ``` Unless explicitly specified when creating a `Worker` instance, each `Worker` thread has its own copy of `process.env`, based on its parent thread's `process.env`, or whatever was specified as the `env` option to the `Worker` constructor. Changes to `process.env` will not be visible across `Worker` threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner unlike the main thread.
@sincev0.1.27
env
.string | undefinedBLOCKCHAIR_API_KEY
},
rpcUrls: {
    ETH: string;
    MATIC: string;
}
rpcUrls
: {
[enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum]: 'https://eth-mainnet.g.alchemy.com/v2/key', [enum ChainChain.function (enum member) Chain.Polygon = "MATIC"Polygon]: 'https://polygon-rpc.com' },
midgardUrls: {
    THOR: string;
    THOR_STAGENET: string;
}
midgardUrls
: {
[enum ChainChain.function (enum member) Chain.THORChain = "THOR"THORChain]: 'https://private-midgard.com', [enum StagenetChainStagenetChain.function (enum member) StagenetChain.THORChain = "THOR_STAGENET"THORChain]: 'https://stagenet-midgard.com' },
apiHeaders: {
    midgard: {
        'X-Client-ID': string | undefined;
    };
    thornode: {
        'X-Client-ID': string | undefined;
    };
}
apiHeaders
: {
midgard: {
    'X-Client-ID': string | undefined;
}
midgard
: {
'X-Client-ID': var process: NodeJS.Processprocess.NodeJS.Process.env: NodeJS.ProcessEnv
The `process.env` property returns an object containing the user environment. See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html). An example of this object looks like: ```js { TERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', PWD: '/Users/maciej', EDITOR: 'vim', SHLVL: '1', HOME: '/Users/maciej', LOGNAME: 'maciej', _: '/usr/local/bin/node' } ``` It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or (unless explicitly requested) to other `Worker` threads. In other words, the following example would not work: ```bash node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo ``` While the following will: ```js import { env } from 'node:process'; env.foo = 'bar'; console.log(env.foo); ``` Assigning a property on `process.env` will implicitly convert the value to a string. **This behavior is deprecated.** Future versions of Node.js may throw an error when the value is not a string, number, or boolean. ```js import { env } from 'node:process'; env.test = null; console.log(env.test); // => 'null' env.test = undefined; console.log(env.test); // => 'undefined' ``` Use `delete` to delete a property from `process.env`. ```js import { env } from 'node:process'; env.TEST = 1; delete env.TEST; console.log(env.TEST); // => undefined ``` On Windows operating systems, environment variables are case-insensitive. ```js import { env } from 'node:process'; env.TEST = 1; console.log(env.test); // => 1 ``` Unless explicitly specified when creating a `Worker` instance, each `Worker` thread has its own copy of `process.env`, based on its parent thread's `process.env`, or whatever was specified as the `env` option to the `Worker` constructor. Changes to `process.env` will not be visible across `Worker` threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner unlike the main thread.
@sincev0.1.27
env
.string | undefinedCLIENT_ID
},
thornode: {
    'X-Client-ID': string | undefined;
}
thornode
: {
'X-Client-ID': var process: NodeJS.Processprocess.NodeJS.Process.env: NodeJS.ProcessEnv
The `process.env` property returns an object containing the user environment. See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html). An example of this object looks like: ```js { TERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', PWD: '/Users/maciej', EDITOR: 'vim', SHLVL: '1', HOME: '/Users/maciej', LOGNAME: 'maciej', _: '/usr/local/bin/node' } ``` It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or (unless explicitly requested) to other `Worker` threads. In other words, the following example would not work: ```bash node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo ``` While the following will: ```js import { env } from 'node:process'; env.foo = 'bar'; console.log(env.foo); ``` Assigning a property on `process.env` will implicitly convert the value to a string. **This behavior is deprecated.** Future versions of Node.js may throw an error when the value is not a string, number, or boolean. ```js import { env } from 'node:process'; env.test = null; console.log(env.test); // => 'null' env.test = undefined; console.log(env.test); // => 'undefined' ``` Use `delete` to delete a property from `process.env`. ```js import { env } from 'node:process'; env.TEST = 1; delete env.TEST; console.log(env.TEST); // => undefined ``` On Windows operating systems, environment variables are case-insensitive. ```js import { env } from 'node:process'; env.TEST = 1; console.log(env.test); // => 1 ``` Unless explicitly specified when creating a `Worker` instance, each `Worker` thread has its own copy of `process.env`, based on its parent thread's `process.env`, or whatever was specified as the `env` option to the `Worker` constructor. Changes to `process.env` will not be visible across `Worker` threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner unlike the main thread.
@sincev0.1.27
env
.string | undefinedCLIENT_ID
} },
envs: {
    isDev: boolean;
    isStagenet: false;
}
envs
: {
isDev: booleanisDev: var process: NodeJS.Processprocess.NodeJS.Process.env: NodeJS.ProcessEnv
The `process.env` property returns an object containing the user environment. See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html). An example of this object looks like: ```js { TERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', PWD: '/Users/maciej', EDITOR: 'vim', SHLVL: '1', HOME: '/Users/maciej', LOGNAME: 'maciej', _: '/usr/local/bin/node' } ``` It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or (unless explicitly requested) to other `Worker` threads. In other words, the following example would not work: ```bash node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo ``` While the following will: ```js import { env } from 'node:process'; env.foo = 'bar'; console.log(env.foo); ``` Assigning a property on `process.env` will implicitly convert the value to a string. **This behavior is deprecated.** Future versions of Node.js may throw an error when the value is not a string, number, or boolean. ```js import { env } from 'node:process'; env.test = null; console.log(env.test); // => 'null' env.test = undefined; console.log(env.test); // => 'undefined' ``` Use `delete` to delete a property from `process.env`. ```js import { env } from 'node:process'; env.TEST = 1; delete env.TEST; console.log(env.TEST); // => undefined ``` On Windows operating systems, environment variables are case-insensitive. ```js import { env } from 'node:process'; env.TEST = 1; console.log(env.test); // => 1 ``` Unless explicitly specified when creating a `Worker` instance, each `Worker` thread has its own copy of `process.env`, based on its parent thread's `process.env`, or whatever was specified as the `env` option to the `Worker` constructor. Changes to `process.env` will not be visible across `Worker` threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner unlike the main thread.
@sincev0.1.27
env
.Env.NODE_ENV?: string | undefinedNODE_ENV === 'development',
isStagenet: falseisStagenet: false } }); // Later, update individual settings if (
Cannot find name 'userPrefersTestnet'.
userPrefersTestnet
) {
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
.setEnv: <"isStagenet">(key: "isStagenet", value: boolean) => voidsetEnv('isStagenet', true);
// Midgard URLs automatically switch to stagenet when isStagenet is true }
  • Automatic Stagenet Support: When isStagenet is true, appropriate stagenet URLs are used automatically
  • Custom Headers: Set authentication headers for Midgard, THORNode, and SwapKit APIs
  • Runtime Updates: All configuration can be updated dynamically without recreating SwapKit instances
  • Environment-Based Config: Easily switch between development, staging, and production environments