DogeUni Keyring SDK
A powerful multi-chain wallet SDK that supports generating, recovering, and managing wallets for multiple blockchain networks.
Supported Networks
- Bitcoin (BTC)
- Dogecoin (DOGE)
- PEP (PEP)
- ClassZZ (CZZ)
- EthereumFair (ETHF)
- DogeOS (DOGEOS)
Key Features
- Mnemonic Generation & Validation - Supports BIP39 standard
- Multi-Network Wallet Generation - Generate wallets for multiple networks with one click
- Network Configuration - Configure which networks to enable for wallet generation
- Private Key Recovery - Recover wallets from private keys, WIF format, and encrypted JSON
- Address Validation - Validate various blockchain address formats
- Data Encryption - AES encryption for sensitive data protection
- Message Signing - Support for Ethereum-like network message signing
- Security Validation - Password strength and mnemonic strength validation
Installation
npm install @dogeuni-org/keyring
Quick Start
Basic Usage
import { DogeUniKeyring } from "@dogeuni-org/keyring";
const keyring = new DogeUniKeyring();
const mnemonic = keyring.generateMnemonic();
console.log("Mnemonic:", mnemonic);
const bitcoinWallet = keyring.recoverWallet({
mnemonic,
network: "bitcoin",
index: 0,
});
const dogecoinWallet = keyring.recoverWallet({
mnemonic,
network: "dogecoin",
index: 0,
});
console.log("Bitcoin address:", bitcoinWallet.address);
console.log("Dogecoin address:", dogecoinWallet.address);
Network Configuration
import { MultiWalletManager } from "@dogeuni-org/keyring";
import { NetworkType } from "@dogeuni-org/keyring";
const enabledNetworks: NetworkType[] = ["bitcoin", "dogecoin", "ethereum"];
const walletManager = new MultiWalletManager(
undefined,
"my-password",
enabledNetworks
);
console.log("Enabled networks:", walletManager.getEnabledNetworks());
walletManager.addEnabledNetwork("pepe");
walletManager.removeEnabledNetwork("ethereum");
console.log("Bitcoin enabled:", walletManager.isNetworkEnabled("bitcoin"));
walletManager.resetNetworks();
Recover Wallet from Private Key
const wallet = keyring.recoverFromPrivateKey(
"your-private-key-here",
"bitcoin"
);
const wifWallet = keyring.recoverFromWIF("your-wif-private-key", "dogecoin");
Generate Multiple Addresses
const wallets = keyring.generateMultipleWallets(mnemonic, "bitcoin", 10);
wallets.forEach((wallet, index) => {
console.log(`Address ${index + 1}: ${wallet.address}`);
});
Ethereum-like Wallet Features
const message = "Hello from DogeUni!";
const signature = keyring.signMessage(
message,
wallet.privateKey,
"ethereumfair"
);
const recoveredAddress = keyring.verifyMessage(
message,
signature,
"ethereumfair"
);
Encrypt Wallet
const encryptedWallet = await keyring.createEncryptedWallet(
wallet.privateKey,
"your-password",
"ethereumfair"
);
const decryptedWallet = await keyring.recoverFromEncryptedJson(
encryptedWallet,
"your-password",
"ethereumfair"
);
API Reference
DogeUniKeyring Class
Constructor
new DogeUniKeyring();
Methods
generateMnemonic(strength?: number): string
Generate a new mnemonic phrase
strength
: Entropy bits (128, 160, 192, 224, 256), defaults to 256
validateMnemonic(mnemonic: string): boolean
Validate if a mnemonic is valid
mnemonicToSeed(mnemonic: string, password?: string): string
Generate seed from mnemonic
generateWallet(options: KeyringOptions): WalletInfo
Generate a new wallet (automatically generates mnemonic)
recoverWallet(options: RecoveryOptions): WalletInfo
Recover wallet from mnemonic
recoverFromPrivateKey(privateKey: string, network: SupportedNetwork): WalletInfo
Recover wallet from private key
recoverFromWIF(wif: string, network: SupportedNetwork): WalletInfo
Recover wallet from WIF format private key
generateMultipleWallets(mnemonic: string, network: SupportedNetwork, count: number, derivationPath?: string): WalletInfo[]
Generate multiple wallet addresses
validateAddress(address: string, network: SupportedNetwork): boolean
Validate address format
signMessage(message: string, privateKey: string, network: SupportedNetwork): string
Sign message (only supports Ethereum-like networks)
verifyMessage(message: string, signature: string, network: SupportedNetwork): string
Verify message signature
createEncryptedWallet(privateKey: string, password: string, network: SupportedNetwork): Promise
Create encrypted wallet
recoverFromEncryptedJson(encryptedJson: string, password: string, network: SupportedNetwork): Promise
Recover wallet from encrypted JSON
Type Definitions
type SupportedNetwork =
| "bitcoin"
| "dogecoin"
| "pepe"
| "classzz"
| "ethereumfair"
| "dogeos";
interface WalletInfo {
address: string;
privateKey: string;
publicKey: string;
network: SupportedNetwork;
derivationPath?: string;
}
interface KeyringOptions {
network: SupportedNetwork;
derivationPath?: string;
password?: string;
}
interface RecoveryOptions {
mnemonic: string;
network: SupportedNetwork;
derivationPath?: string;
password?: string;
index?: number;
}
Derivation Paths
The SDK uses standard BIP44 derivation paths:
- Bitcoin:
m/44'/0'/0'/0/0
- Dogecoin:
m/44'/3'/0'/0/0
- PEP/ClassZZ/EthereumFair/DogeOS:
m/44'/60'/0'/0/0
Security Considerations
- Private Key Security: Never hardcode private keys in client-side code
- Mnemonic Backup: Securely backup mnemonics and never store them in the cloud
- Password Strength: Use strong passwords to protect encrypted wallets
- Environment Security: Generate and use wallets in secure environments
Bundle Optimization
This SDK includes advanced bundle optimization features:
Build Commands
npm run build
npm run build:optimized
npm run build:prod
npm run build:test
node scripts/gzip-compress.js
Bundle Sizes
- Standard Build: ~4.1MB
- Optimized Build: ~3.2MB (22% reduction)
- Production Build: ~2.8MB (32% reduction)
- Gzip Compressed: ~0.8MB (80% reduction)
Optimization Features
- Advanced Terser Configuration: Multiple compression passes with aggressive optimizations
- Code Splitting: Intelligent chunking by functionality (crypto, blockchain, utils)
- Tree Shaking: Remove unused code and dependencies
- Gzip Compression: Built-in compression analysis and optimization
Development
Prerequisites
- Node.js >= 16.0.0
- npm >= 8.0.0
Setup
npm install
npm run build
npm test
npm run type-check
npm run lint
Build Options
npm run build
npm run build:optimized
npm run build:prod
npm run build:test
Testing
npm test
npm run test:watch
npm run test:coverage
Browser Compatibility
The SDK is built for modern browsers and includes necessary polyfills:
- Target: ES2020
- Browsers: > 1% market share, last 2 versions
- Polyfills: Node.js modules (crypto, buffer, stream, etc.)
Examples
Check the demo/
directory for complete examples:
KeyringTest.tsx
- Basic usage example
MultiWalletTest.tsx
- Advanced multi-wallet functionality
Run the demo:
cd demo
npm install
npm run dev
Performance
Bundle Optimization
The SDK implements several optimization strategies:
- Code Splitting: Separate chunks for crypto, blockchain, and utility functions
- Tree Shaking: Remove unused code during build
- Minification: Advanced Terser configuration for maximum compression
- Gzip Compression: Built-in compression analysis
Expected Performance
- Initial Load: 32% smaller bundle size
- Caching: Better cache efficiency with code splitting
- Runtime: Optimized for modern JavaScript engines
Contributing
We welcome contributions! Please see our contributing guidelines:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
If you encounter any issues or have questions:
Roadmap
Changelog
See CHANGELOG.md for version history and updates.