@enclave-hq/wallet-sdk
v1.2.3
Published
Multi-chain wallet adapter for Enclave - supports EVM and Tron ecosystems
Downloads
901
Maintainers
Readme
@enclave-hq/wallet-sdk
Multi-chain wallet adapter for Enclave - supports EVM and Tron ecosystems
📋 Overview
@enclave-hq/wallet-sdk is a powerful, extensible wallet adapter library that provides a unified interface for connecting to multiple blockchain wallets across different ecosystems (EVM and Tron).
Key Features
- 🔗 Multi-Chain Support: Unified interface for EVM (Ethereum, BSC, Polygon, etc.) and Tron
- 🔌 Multiple Wallets: MetaMask, TronLink, WalletConnect, and private key support
- ⚡️ Easy Integration: Simple API with React hooks
- 🎯 Type-Safe: Full TypeScript support with comprehensive type definitions
- 🔐 Secure: Standard-compliant signing (EIP-191, TIP-191, EIP-712)
- 📦 Tree-Shakeable: Modern build system with ESM and CJS support
- 🎨 Extensible: Plugin-based architecture for adding new wallets and chains
📦 Installation
npm install @enclave-hq/wallet-sdk
# or
yarn add @enclave-hq/wallet-sdk
# or
pnpm add @enclave-hq/wallet-sdk🚀 Quick Start
Basic Usage (Vanilla JS/TS)
import { WalletManager, WalletType } from '@enclave-hq/wallet-sdk'
// Create wallet manager
const walletManager = new WalletManager()
// Connect to MetaMask
const account = await walletManager.connect(WalletType.METAMASK, 1) // Ethereum Mainnet
console.log('Connected:', account.universalAddress)
// Output: "1:0x1234567890123456789012345678901234567890"
// Sign a message
const signature = await walletManager.signMessage('Hello World')
// Disconnect
await walletManager.disconnect()React Integration
import React from 'react'
import { WalletProvider, useWallet, useAccount, useConnect } from '@enclave-hq/wallet-sdk/react'
import { WalletType } from '@enclave-hq/wallet-sdk'
// 1. Wrap your app with WalletProvider
function App() {
return (
<WalletProvider>
<YourApp />
</WalletProvider>
)
}
// 2. Use wallet hooks in your components
function YourApp() {
const { account, isConnected } = useAccount()
const { connect, isConnecting } = useConnect()
const { disconnect } = useWallet()
const handleConnect = async () => {
try {
await connect(WalletType.METAMASK)
} catch (error) {
console.error('Connection failed:', error)
}
}
if (!isConnected) {
return (
<button onClick={handleConnect} disabled={isConnecting}>
{isConnecting ? 'Connecting...' : 'Connect MetaMask'}
</button>
)
}
return (
<div>
<p>Connected: {account?.nativeAddress}</p>
<button onClick={disconnect}>Disconnect</button>
</div>
)
}🎯 Core Concepts
Universal Address
A chain-agnostic address format: chainId:address
// Example:
"1:0x1234..." // Ethereum Mainnet
"56:0x5678..." // BSC Mainnet
"195:TJmm..." // Tron MainnetPrimary Wallet + Connected Wallets Pool
The SDK uses a hybrid architecture where you can:
- Connect multiple wallets simultaneously (EVM + Tron)
- Designate one as the "primary wallet" for default operations
- Switch the primary wallet dynamically
// Connect MetaMask as primary wallet
await walletManager.connect(WalletType.METAMASK)
// Connect TronLink as additional wallet
await walletManager.connectAdditional(WalletType.TRONLINK)
// Switch primary wallet to TronLink
await walletManager.switchPrimaryWallet(ChainType.TRON)
// Get all connected wallets
const wallets = walletManager.getConnectedWallets()📚 Supported Wallets
| Wallet | Chain Type | Status | |--------|------------|--------| | MetaMask | EVM | ✅ Supported | | TronLink | Tron | ✅ Supported | | WalletConnect | EVM | 🚧 Coming Soon | | Coinbase Wallet | EVM | 🚧 Coming Soon | | Private Key | EVM/Tron | ✅ Dev Only |
📖 Documentation
Full documentation is available in the /docs folder:
🧪 Running the Example
A fully functional example application is included:
cd example
npm install
npm run devOpen http://localhost:3000 to see the demo.
🛠️ Development
# Install dependencies
npm install
# Build the SDK
npm run build
# Watch mode (for development)
npm run dev
# Run linter
npm run lint
# Type check
npm run type-check📄 License
MIT © Enclave Team
🤝 Contributing
Contributions are welcome! Please read our Contributing Guide for details.
🔗 Links
Built with ❤️ by the Enclave Team
