UNPKG

@prathammahajan/blockchain-integration

Version:

🚀 Comprehensive blockchain integration suite with multi-chain cryptocurrency support, NFT marketplace, smart contracts, DeFi protocols, and enterprise-grade wallet management

83 lines (70 loc) 2.4 kB
const BlockchainEngine = require('../src/index'); async function walletManagementExample() { try { // Initialize blockchain engine const blockchain = new BlockchainEngine({ networks: { ethereum: { enabled: false, rpc: 'https://mainnet.infura.io', chainId: 1 } }, wallet: { enabled: true, encryption: false, backup: true }, nft: { enabled: false }, smartContracts: { enabled: false }, defi: { enabled: false }, security: { enabled: false } }); // Wait for initialization await new Promise(resolve => { blockchain.on('initialized', resolve); }); console.log('✅ Blockchain Engine initialized'); // Create HD wallet const hdWallet = await blockchain.createWallet('hd'); console.log('✅ HD Wallet created:', hdWallet.address); // Create multi-signature wallet const multiSigWallet = await blockchain.createWallet('multisig', { requiredSignatures: 2, totalSigners: 3 }); console.log('✅ Multi-sig wallet created:', multiSigWallet.address); // Import wallet from private key const privateKey = '0x1234567890123456789012345678901234567890123456789012345678901234'; const importedWallet = await blockchain.importWallet('privatekey', privateKey); console.log('✅ Wallet imported:', importedWallet.address); // Get wallet balance (skip if networks are disabled) try { const balance = await blockchain.getWalletBalance(hdWallet.walletId, 'ethereum'); console.log('✅ Wallet balance:', balance); } catch (error) { console.log('⚠️ Wallet balance check skipped (networks disabled):', error.message); } // List all wallets const wallets = await blockchain.walletManager.listWallets(); console.log('✅ All wallets:', wallets); // Backup wallet const backup = await blockchain.walletManager.backupWallet(hdWallet.walletId); console.log('✅ Wallet backed up:', backup); // Shutdown await blockchain.shutdown(); console.log('✅ Blockchain Engine shutdown'); } catch (error) { console.error('❌ Error:', error.message); } } // Run the example walletManagementExample();