Lightweight, customizable, and feature-rich wallet connection solution
npm install @shelchin/walletkit
# or
pnpm add @shelchin/walletkit
# or
yarn add @shelchin/walletkit
<script src="https://unpkg.com/@shelchin/walletkit/dist/standalone.js"></script>
<script>
import { WalletKit, WalletButton } from '@shelchin/walletkit';
const config = {
projectId: 'YOUR_WALLETCONNECT_PROJECT_ID', // Required for WalletConnect
networks: [1, 137, 42161], // Ethereum, Polygon, Arbitrum
theme: 'auto', // 'light' | 'dark' | 'auto'
locale: 'en' // 'en' | 'zh'
};
</script>
<WalletKit {config}>
<WalletButton />
</WalletKit>
<div id="wallet-container"></div>
<script src="https://unpkg.com/@shelchin/walletkit/dist/standalone.js"></script>
<script>
WalletKit.init({
containerId: 'wallet-container',
projectId: 'YOUR_WALLETCONNECT_PROJECT_ID',
theme: 'dark',
networks: [1, 137, 42161]
});
</script>
interface WalletKitConfig {
// WalletConnect Project ID (required for WalletConnect)
projectId?: string;
// Supported networks (chain IDs)
networks?: number[];
// Custom RPC endpoints
rpcUrls?: Record<number, string[]>;
// Theme configuration
theme?: 'light' | 'dark' | 'auto' | ThemeConfig;
// Localization
locale?: 'en' | 'zh' | LocaleConfig;
// Wallet options
wallets?: {
includeDefault?: boolean;
custom?: WalletConfig[];
};
// Features
features?: {
ensResolution?: boolean;
siwe?: boolean; // Sign-In with Ethereum
analytics?: boolean;
};
// Custom modal options
modal?: {
disableBackdropClick?: boolean;
showRecentTransactions?: boolean;
};
}
const customTheme = {
colors: {
primary: '#6366f1',
background: '#ffffff',
text: '#111827',
border: '#e5e7eb'
},
radius: {
button: '0.75rem',
modal: '1.5rem'
},
fonts: {
base: 'Inter, system-ui, sans-serif'
}
};
WalletKit.init({
theme: customTheme
});
const customNetworks = {
networks: [1, 137, 42161, 56], // Include BSC
rpcUrls: {
1: ['https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY'],
137: ['https://polygon-rpc.com'],
42161: ['https://arb1.arbitrum.io/rpc'],
56: ['https://bsc-dataseed.binance.org']
}
};
WalletKit is fully optimized for mobile devices with:
import { createTheme } from '@shelchin/walletkit';
const myTheme = createTheme({
primary: '#8b5cf6',
secondary: '#ec4899',
borderRadius: 'lg',
fontFamily: 'Roboto, sans-serif'
});
const customLocale = {
connect: 'Connect Wallet',
disconnect: 'Disconnect',
switchNetwork: 'Switch Network',
copyAddress: 'Copy Address'
// ... more translations
};
WalletKit.init({
locale: customLocale
});
// Initialize WalletKit
WalletKit.init(config: WalletKitConfig): void
// Connect wallet
WalletKit.connect(): Promise<WalletConnection>
// Disconnect wallet
WalletKit.disconnect(): Promise<void>
// Get current account
WalletKit.getAccount(): Address | null
// Switch network
WalletKit.switchNetwork(chainId: number): Promise<void>
// Sign message
WalletKit.signMessage(message: string): Promise<string>
// Send transaction
WalletKit.sendTransaction(tx: TransactionRequest): Promise<string>
// Account change
WalletKit.onAccountChange((account) => {
console.log('Account changed:', account);
});
// Network change
WalletKit.onChainChange((chainId) => {
console.log('Network changed:', chainId);
});
// Connection status
WalletKit.onConnectionChange((connected) => {
console.log('Connection status:', connected);
});
import { account, chainId, connected, connecting } from '@shelchin/walletkit';
// Use in Svelte components
$: currentAccount = $account;
$: currentChain = $chainId;
$: isConnected = $connected;
WalletKit follows Clean Architecture principles:
src/
├── lib/
│ ├── domain/ # Business logic & types
│ ├── application/ # Use cases & services
│ ├── infrastructure/ # External integrations
│ └── presentation/ # UI components
├── standalone/ # Standalone build entry
└── routes/ # Demo pages
# Install dependencies
pnpm install
# Start development server
pnpm dev
# Run tests
pnpm test
# Build library
pnpm build
# Lint & format
pnpm lint
pnpm format
# Unit tests
pnpm test:unit
# E2E tests
pnpm test:e2e
# Type checking
pnpm check
MIT © 2025 WalletKit
Contributions are welcome! Please read our Contributing Guide for details.
Special thanks to all our sponsors and contributors!