WDK Core Configuration
Configuration options and settings for @tetherto/wdk
Configuration
WDK Manager Configuration
import WDK from '@tetherto/wdk'
const wdk = new WDK(seedPhrase)The WDK Manager requires a seed phrase or seed bytes. Its optional second argument sets instance-level policy limits; wallet and protocol configuration remains registration-based.
Policy Condition Timeout Ceiling
const wdk = new WDK(seedPhrase, {
maxConditionTimeoutMs: 5000
})maxConditionTimeoutMs is the maximum time any one policy condition can receive through registerPolicy(..., { conditionTimeoutMs }). It defaults to 30000 milliseconds and must be a finite positive number. A policy that requests a larger timeout is capped to this ceiling rather than rejected. Each registerPolicy() call applies its requested timeout only to the policies registered by that call.
Wallet Registration Configuration
import WDK from '@tetherto/wdk'
import WalletManagerEvm from '@tetherto/wdk-wallet-evm'
import WalletManagerTon from '@tetherto/wdk-wallet-ton'
const wdk = new WDK(seedPhrase)
.registerWallet('ethereum', WalletManagerEvm, {
provider: 'https://eth.drpc.org'
})
.registerWallet('ton', WalletManagerTon, {
tonApiKey: 'YOUR_TON_API_KEY',
tonApiEndpoint: 'https://tonapi.io'
})Protocol Registration Configuration
import veloraProtocolEvm from '@tetherto/wdk-protocol-swap-velora-evm'
const wdk = new WDK(seedPhrase)
.registerProtocol('ethereum', 'velora', veloraProtocolEvm, {
apiKey: 'YOUR_velora_API_KEY'
})Configuration Options
Wallet Configuration
Each wallet manager requires its own configuration object when registered. The configuration depends on the specific wallet module being used.
EVM Wallet Configuration
const ethereumWalletConfig = {
provider: 'https://eth.drpc.org', // RPC endpoint
// Additional EVM-specific configuration options
}
wdk.registerWallet('ethereum', WalletManagerEvm, ethereumWalletConfig)TON Wallet Configuration
const tonWalletConfig = {
tonClient: {
secretKey: 'YOUR_TON_API_KEY',
url: 'https://toncenter.com/api/v2/jsonRPC'
}
}
wdk.registerWallet('ton', WalletManagerTon, tonWalletConfig)Protocol Configuration
Protocols also require their own configuration objects when registered.
Swap Protocol Configuration
const veloraProtocolConfig = {
apiKey: 'YOUR_velora_API_KEY',
baseUrl: 'https://apiv5.velora.io'
}
wdk.registerProtocol('ethereum', 'velora', veloraProtocolEvm, veloraProtocolConfig)Middleware Configuration
Middleware functions can be registered to enhance account functionality.
// Simple logging middleware
wdk.registerMiddleware('ethereum', async (account) => {
console.log('New account created:', await account.getAddress())
})Environment Variables
For production applications, consider using environment variables for sensitive configuration:
const wdk = new WDK(process.env.SEED_PHRASE)
.registerWallet('ethereum', WalletManagerEvm, {
provider: process.env.ETHEREUM_RPC_URL
})
.registerProtocol('ethereum', 'velora', veloraProtocolEvm, {
apiKey: process.env.velora_API_KEY
})Configuration Validation
Registration does not validate every downstream module configuration:
- Wallet Registration: WDK constructs the wallet manager during registration, so wallet-constructor validation errors surface immediately. Registering a second wallet under the same blockchain throws.
- Protocol Registration: Global registration stores a supported protocol class and config for later construction. Reusing the same blockchain, protocol type, and label replaces the previous global registration. Provider-constructor and config errors surface when an account retrieves the protocol.
- Middleware Registration: WDK stores the middleware for later account decoration. Errors thrown by the middleware surface when an account is retrieved.
In JavaScript, a protocol class that does not extend a supported WDK protocol base class is ignored rather than rejected. Keep protocol classes typed, use distinct labels, and test retrieval during application startup. A global registration shadows an account-scoped provider with the same type and label.
Error Handling
Handle wallet registration errors at registration time and protocol errors at retrieval time:
try {
wdk.registerWallet('ethereum', InvalidWalletClass, config)
} catch (error) {
console.error('Wallet registration failed:', error.message)
}
try {
wdk.registerProtocol('ethereum', 'velora', veloraProtocolEvm, invalidConfig)
const account = await wdk.getAccount('ethereum', 0)
account.getSwapProtocol('velora')
} catch (error) {
console.error('Protocol construction or retrieval failed:', error.message)
}Next Steps
WDK Core Usage
Get started with WDK's usage
WDK Core API
Get started with WDK's API
Wallet Modules
Explore blockchain-specific wallet modules
Bridge Modules
Cross-chain USD₮0 bridges