Creating a New Wallet Adapter for Titan Kit

This guide explains how to create and integrate a new wallet adapter into Titan Kit. We'll focus on the core implementation details.

Understanding the Wallet Architecture

Titan Kit's wallet system is built on a flexible architecture with the following key components:

  1. BaseWallet: The abstract base class that all wallet types extend from

  2. ExtensionWallet: For browser extension wallets

  3. CosmosWallet: Specifically for Cosmos-based wallets

  4. EthereumWallet: For Ethereum-compatible wallets

  5. WCWallet: For WalletConnect integration

Creating a New Extension Wallet

Let's walk through the process of creating a new wallet adapter for a browser extension.

1. Define Wallet Constants

Create a constant.ts file to store wallet-specific information:

// constant.ts
export const ICON =
  "data:image/svg+xml;base64,YOUR_BASE64_ENCODED_SVG_LOGO";

// Add any other constants specific to your wallet here

2. Create Wallet Registry

Create a registry.ts file to define the wallet information:

3. Create Custom Wallet Implementation (Optional)

If your wallet requires custom methods beyond the base functionality, create a custom wallet class:

4. Create Main Entry Point

Create an index.ts file to export your wallet instance:

Mobile Wallet Support

For mobile wallets using WalletConnect, update your wallet registry:

Hardware Wallet Support

For hardware wallets, create a custom implementation:

Using Your New Wallet

After creating your wallet adapter, you can use it in your application:

Best Practices

  1. Error Handling

    • Implement proper error handling for connection failures

    • Provide clear error messages for users

    • Handle network-specific errors appropriately

  2. Security

    • Follow security best practices

    • Implement proper encryption for sensitive data

    • Validate all user inputs

  3. Compatibility

    • Test with multiple chains

    • Ensure compatibility with different network types

    • Support both mainnet and testnet environments

  4. User Experience

    • Provide clear feedback during operations

    • Handle edge cases gracefully

    • Implement proper loading states

  5. Testing

    • Test all wallet operations thoroughly

    • Test with different network conditions

    • Test error scenarios and recovery