Configuration
Configuration options and settings for @tetherto/wdk
WDK Manager Configuration
import WDK from '@tetherto/wdk'
const wdk = new WDK(seedPhrase)The WDK Manager itself only requires a seed phrase for initialization. Configuration is done through the registration of wallets and protocols.
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:
```javascript title="WDK environment variables 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
The WDK Manager will validate configurations when wallets and protocols are registered:
- Wallet Registration: Ensures the wallet class extends the required base class
- Protocol Registration: Validates that protocol labels are unique per blockchain and protocol type
- Middleware Registration: Validates that middleware functions have the correct signature
Error Handling
Configuration errors will be thrown during registration:
try {
wdk.registerWallet('ethereum', InvalidWalletClass, config)
} catch (error) {
console.error('Wallet registration failed:', error.message)
}
try {
wdk.registerProtocol('ethereum', 'velora', veloraProtocolEvm, invalidConfig)
} catch (error) {
console.error('Protocol registration 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