getKrakenWhitelistedAddresses
Retrieves the list of whitelisted withdrawal addresses configured in the user’s Kraken account.
Kraken allows users to enable address whitelisting as a security feature. When enabled, withdrawals can only be sent to pre-approved addresses. Use this function to check if whitelisting is enforced and to get the list of approved destinations.
Usage
import { getKrakenWhitelistedAddresses } from '@dynamic-labs-sdk/client';
const { destinations, enforcesAddressWhitelist } =
await getKrakenWhitelistedAddresses();
if (enforcesAddressWhitelist) {
console.log('User can only withdraw to these addresses:');
destinations.forEach(dest => {
console.log(` ${dest.address} (${dest.tokens?.join(', ')})`);
});
} else {
console.log('User can withdraw to any address');
}
Parameters
| Parameter | Type | Description |
|---|
client | DynamicClient (optional) | The Dynamic client instance. Only required when using multiple clients. |
Returns
Promise<TransferDestinationResponse> - A promise that resolves to:
type TransferDestinationResponse = {
destinations: TransferDestination[];
enforcesAddressWhitelist: boolean; // true if user can only send to whitelisted addresses
};
type TransferDestination = {
address: string; // The whitelisted wallet address
tokens?: string[]; // Currencies supported at this address (e.g., ['ETH', 'USDC'])
};
Understanding Whitelisting
enforcesAddressWhitelist | Behavior |
|---|
true | User can ONLY transfer to addresses in the destinations array |
false | User can transfer to any valid address |
When whitelisting is enforced, each destination address has a tokens array specifying which currencies can be sent to that address. Always filter destinations by the currency being transferred.
Examples
Basic usage
import { getKrakenWhitelistedAddresses } from '@dynamic-labs-sdk/client';
const checkWhitelist = async () => {
const { destinations, enforcesAddressWhitelist } =
await getKrakenWhitelistedAddresses();
if (!enforcesAddressWhitelist) {
return { enforced: false, addresses: [] };
}
return {
enforced: true,
addresses: destinations.map(dest => ({
address: dest.address,
supportedTokens: dest.tokens || [],
})),
};
};
const whitelist = await checkWhitelist();
console.log('Whitelisting enforced:', whitelist.enforced);
Filter addresses by currency
import { getKrakenWhitelistedAddresses } from '@dynamic-labs-sdk/client';
const getAddressesForCurrency = async (currency) => {
const { destinations, enforcesAddressWhitelist } =
await getKrakenWhitelistedAddresses();
if (!enforcesAddressWhitelist) {
// Any address is allowed
return { enforced: false, addresses: null };
}
// Filter to addresses that support this currency
const validAddresses = destinations.filter(
dest => dest.tokens?.includes(currency)
);
return {
enforced: true,
addresses: validAddresses.map(dest => dest.address),
};
};
// Usage
const ethAddresses = await getAddressesForCurrency('ETH');
if (ethAddresses.enforced) {
console.log('Whitelisted ETH addresses:', ethAddresses.addresses);
} else {
console.log('Any address can receive ETH');
}
Validate address before transfer
import {
getKrakenWhitelistedAddresses,
createKrakenExchangeTransfer,
} from '@dynamic-labs-sdk/client';
const safeTransfer = async (accountId, address, amount, currency) => {
// Check whitelist requirements
const { destinations, enforcesAddressWhitelist } =
await getKrakenWhitelistedAddresses();
if (enforcesAddressWhitelist) {
const isWhitelisted = destinations.some(
dest =>
dest.address.toLowerCase() === address.toLowerCase() &&
dest.tokens?.includes(currency)
);
if (!isWhitelisted) {
throw new Error(
`Address ${address} is not whitelisted for ${currency}. ` +
`Add it in your Kraken account settings before transferring.`
);
}
}
// Address is valid, proceed with transfer
return createKrakenExchangeTransfer({
accountId,
to: address,
amount,
currency,
});
};
// Usage
try {
const transfer = await safeTransfer(
'acc_123',
'0x742d35Cc6634C0532925a3b844Bc9e7595f7ABCD',
0.5,
'ETH'
);
console.log('Transfer created:', transfer.id);
} catch (error) {
console.error(error.message);
}
Address selector dropdown (React)
import { useState, useEffect } from 'react';
import { getKrakenWhitelistedAddresses } from '@dynamic-labs-sdk/client';
const AddressSelector = ({ currency, value, onChange }) => {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchAddresses = async () => {
try {
const response = await getKrakenWhitelistedAddresses();
setData(response);
} catch (error) {
console.error('Failed to fetch addresses:', error);
} finally {
setLoading(false);
}
};
fetchAddresses();
}, []);
if (loading) return <div>Loading addresses...</div>;
// If whitelisting is not enforced, show a text input
if (!data?.enforcesAddressWhitelist) {
return (
<input
type="text"
value={value}
onChange={e => onChange(e.target.value)}
placeholder="Enter wallet address (0x...)"
/>
);
}
// Filter addresses that support the selected currency
const validAddresses = data.destinations.filter(
dest => dest.tokens?.includes(currency)
);
if (validAddresses.length === 0) {
return (
<div>
<p>No whitelisted addresses for {currency}.</p>
<p>Add one in your Kraken account settings.</p>
</div>
);
}
return (
<select value={value} onChange={e => onChange(e.target.value)}>
<option value="">Select a whitelisted address</option>
{validAddresses.map(dest => (
<option key={dest.address} value={dest.address}>
{dest.address.slice(0, 10)}...{dest.address.slice(-8)}
</option>
))}
</select>
);
};
Check if custom addresses are allowed
import { getKrakenWhitelistedAddresses } from '@dynamic-labs-sdk/client';
const canUseAnyAddress = async () => {
const { enforcesAddressWhitelist } = await getKrakenWhitelistedAddresses();
return !enforcesAddressWhitelist;
};
// Usage in UI
if (await canUseAnyAddress()) {
// Show free-form address input
showAddressInput();
} else {
// Show dropdown of whitelisted addresses only
showAddressDropdown();
}
Group addresses by currency
import { getKrakenWhitelistedAddresses } from '@dynamic-labs-sdk/client';
const getAddressesGroupedByCurrency = async () => {
const { destinations, enforcesAddressWhitelist } =
await getKrakenWhitelistedAddresses();
if (!enforcesAddressWhitelist) {
return { enforced: false, grouped: null };
}
const grouped = {};
destinations.forEach(dest => {
(dest.tokens || []).forEach(token => {
if (!grouped[token]) {
grouped[token] = [];
}
grouped[token].push(dest.address);
});
});
return { enforced: true, grouped };
};
// Usage
const { enforced, grouped } = await getAddressesGroupedByCurrency();
if (enforced) {
console.log('ETH addresses:', grouped.ETH);
console.log('BTC addresses:', grouped.BTC);
console.log('USDC addresses:', grouped.USDC);
}
Pre-flight check before showing transfer UI
import {
getKrakenAccounts,
getKrakenWhitelistedAddresses,
} from '@dynamic-labs-sdk/client';
const canTransferCurrency = async (currency) => {
const [accounts, { destinations, enforcesAddressWhitelist }] =
await Promise.all([
getKrakenAccounts(),
getKrakenWhitelistedAddresses(),
]);
// Check if user has balance
let hasBalance = false;
let accountId = null;
for (const account of accounts) {
const balance = account.balances.find(b => b.currency === currency);
if (balance && parseFloat(balance.balance) > 0) {
hasBalance = true;
accountId = account.id;
break;
}
}
if (!hasBalance) {
return { canTransfer: false, reason: `No ${currency} balance` };
}
// Check if there's a valid destination
if (enforcesAddressWhitelist) {
const hasValidDestination = destinations.some(
dest => dest.tokens?.includes(currency)
);
if (!hasValidDestination) {
return {
canTransfer: false,
reason: `No whitelisted address for ${currency}. Add one in Kraken settings.`,
};
}
}
return { canTransfer: true, accountId };
};
// Usage
const ethCheck = await canTransferCurrency('ETH');
if (!ethCheck.canTransfer) {
alert(ethCheck.reason);
} else {
showTransferForm(ethCheck.accountId);
}
Prerequisites
- User must have connected their Kraken account through Dynamic
- Whitelisted addresses are managed in Kraken’s security settings, not through the Dynamic SDK
Notes
- Address whitelisting is a Kraken security feature that users enable in their exchange account
- When whitelisting is enforced, transfers to non-whitelisted addresses will fail
- Each whitelisted address is associated with specific currencies via the
tokens array
- Users must add new whitelisted addresses directly in their Kraken account settings
Last modified on February 2, 2026