Learn how to use Swaps, Bridges, and Lending protocols.
The WDK Core module supports registering external protocols. This allows you to extend the basic wallet functionality with advanced features like token swapping, cross-chain bridging, and lending, all through a unified interface.
Register Protocols
You can register protocols globally (for all new accounts).
Global Registration (Recommended)
Global registration ensures that every account you retrieve already has the protocol ready to use. You can do this by chaining a call to .registerProtocol() on the WDK instance.
Now, import the protocol modules and register them with your WDK instance. This makes the protocol methods available to any account derived from that instance.
Then, register the protocols for the specific chains they support:
Register Protocols
// Register protocols for specific chainsconstwdk=newWDK(seedPhrase).registerWallet('ethereum', WalletManagerEvm, ethConfig)// Register Velora Swap for Ethereum.registerProtocol('ethereum','velora', veloraProtocolEvm, { apiKey:'YOUR_API_KEY' })// Register USDT0 Bridge for Ethereum.registerProtocol('ethereum','usdt0', usdt0ProtocolEvm, { ethereumRpcUrl:'https://eth.drpc.org'// Configuration depends on the module })
Use Protocols
Once registered, you can access the protocol instance using the specific getter methods: getSwapProtocol, getBridgeProtocol, or getLendingProtocol.
Swapping Tokens
Use getSwapProtocol to access registered swap services on any wallet account.
Bridging Assets
Use getBridgeProtocol to access cross-chain bridges.
Call bridge from the bridge protocol to send tokens from one protocol to another.
Protocol Availability: If you try to access a protocol that hasn't been registered (e.g., getSwapProtocol('uniswap')), the SDK will throw an error. always ensure registration matches the ID you request.
Next Steps
Learn how to configure middleware to add logging or failover protection to your wallet interactions.