JSPM

think-hd-wallet

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • 0
    • Score
      100M100P100Q18673F
    • License MIT

    A React Native HD wallet supporting multiple cryptocurrency networks

    Package Exports

    • think-hd-wallet
    • think-hd-wallet/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (think-hd-wallet) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    React Native Multi-Crypto Wallet

    A TypeScript library for creating and managing Bitcoin, Ethereum, Binance Smart Chain (BSC), Polygon, Dash, Litecoin, and Dogecoin wallets in React Native applications. This library provides a unified interface for handling different cryptocurrency wallets while following BIP standards for key derivation and address generation.

    Features

    • BIP39 mnemonic generation and import
    • BIP32/44 HD wallet support
    • Bitcoin wallet functionality (Legacy and SegWit addresses)
    • Ethereum wallet functionality
    • Binance Smart Chain (BSC) wallet functionality
    • Polygon wallet functionality
    • Dash wallet functionality
    • Litecoin wallet functionality
    • Dogecoin wallet functionality
    • TypeScript support
    • Comprehensive test coverage

    Installation

    npm install react-native-multi-crypto-wallet

    Dependencies

    This package requires the following peer dependencies:

    {
      "bip32": "^3.0.1",
      "bip39": "^3.0.4",
      "bitcoinjs-lib": "^6.1.0",
      "ethers": "^6.0.0",
      "ethereumjs-util": "^7.1.5",
      "tiny-secp256k1": "^2.2.1"
    }

    Usage

    Bitcoin Wallet

    import { BitcoinWallet, CryptoNetwork } from 'react-native-multi-crypto-wallet';
    
    // Create a new Bitcoin wallet
    const bitcoinWallet = new BitcoinWallet({
      network: CryptoNetwork.BITCOIN_TESTNET // or BITCOIN_MAINNET
    });
    
    // Generate a new mnemonic
    const mnemonic = bitcoinWallet.generateMnemonic();
    console.log('Mnemonic:', mnemonic);
    
    // Get wallet address
    const address = bitcoinWallet.getAddress();
    console.log('Bitcoin Address:', address);
    
    // Get private key
    const privateKey = bitcoinWallet.getPrivateKey();
    console.log('Private Key:', privateKey);
    
    // Get public key
    const publicKey = bitcoinWallet.getPublicKey();
    console.log('Public Key:', publicKey);
    
    // Import existing wallet from mnemonic
    const importedWallet = new BitcoinWallet({
      network: CryptoNetwork.BITCOIN_TESTNET,
      mnemonic: 'your twelve word mnemonic phrase here'
    });

    Ethereum Wallet

    import { EthereumWallet, CryptoNetwork } from 'react-native-multi-crypto-wallet';
    
    // Create a new Ethereum wallet
    const ethereumWallet = new EthereumWallet(CryptoNetwork.ETHEREUM_GOERLI); // or ETHEREUM_MAINNET, ETHEREUM_SEPOLIA
    
    // Generate a new mnemonic
    const mnemonic = ethereumWallet.generateMnemonic();
    console.log('Mnemonic:', mnemonic);
    
    // Get Ethereum address
    const address = ethereumWallet.getAddress();
    console.log('Ethereum Address:', address);
    
    // Get private key
    const privateKey = ethereumWallet.getPrivateKey();
    console.log('Private Key:', privateKey);
    
    // Get public key
    const publicKey = ethereumWallet.getPublicKey();
    console.log('Public Key:', publicKey);
    
    // Check balance
    const balance = await ethereumWallet.getBalance();
    console.log('Balance:', balance, 'ETH');
    
    // Import existing wallet from mnemonic
    const importedEthWallet = new EthereumWallet({CryptoNetwork.ETHEREUM_GOERLI,
      mnemonic: 'your twelve word mnemonic phrase here'
    });
    
    // Sign a transaction
    const transaction = {
      to: "0x1234...",
      value: ethers.parseEther("0.1"),
      gasLimit: "21000",
    };
    const signedTx = await ethereumWallet.signTransaction(transaction);

    BNB Wallet

    import { BNBWallet, CryptoNetwork } from 'react-native-multi-crypto-wallet';
    
    // Create a new BNB wallet
    const bnbWallet = new BNBWallet({
      network: CryptoNetwork.BSC_MAINNET // or BSC_TESTNET
    });
    
    // Generate a new mnemonic
    const mnemonic = bnbWallet.generateMnemonic();
    console.log('Mnemonic:', mnemonic);
    
    // Get BNB address
    const address = bnbWallet.getAddress();
    console.log('BNB Address:', address);
    
    // Import existing wallet from mnemonic
    const importedBnbWallet = new BNBWallet({
      network: CryptoNetwork.BSC_MAINNET,
      mnemonic: 'your twelve word mnemonic phrase here'
    });
    
    // Check balance
    const balance = await bnbWallet.getBalance();
    console.log('Balance:', balance, 'BNB');

    Polygon Wallet

    import { PolygonWallet, CryptoNetwork } from 'react-native-multi-crypto-wallet';
    
    // Create a new Polygon wallet
    const polygonWallet = new PolygonWallet({
      network: CryptoNetwork.POLYGON_MAINNET // or POLYGON_MUMBAI
    });
    
    // Generate a new mnemonic
    const mnemonic = polygonWallet.generateMnemonic();
    console.log('Mnemonic:', mnemonic);
    
    // Get MATIC address
    const address = polygonWallet.getAddress();
    console.log('Polygon Address:', address);
    
    // Import existing wallet from mnemonic
    const importedPolygonWallet = new PolygonWallet({
      network: CryptoNetwork.POLYGON_MAINNET,
      mnemonic: 'your twelve word mnemonic phrase here'
    });
    
    // Check balance
    const balance = await polygonWallet.getBalance();
    console.log('Balance:', balance, 'MATIC');

    Dash Wallet

    import { DashWallet, CryptoNetwork } from 'react-native-multi-crypto-wallet';
    
    // Create a new Dash wallet
    const dashWallet = new DashWallet({
      network: CryptoNetwork.DASH_MAINNET // or DASH_TESTNET
    });
    
    // Generate a new mnemonic
    const mnemonic = dashWallet.generateMnemonic();
    console.log('Mnemonic:', mnemonic);
    
    // Get Dash address
    const address = dashWallet.getAddress();
    console.log('Dash Address:', address);
    
    // Import existing wallet from mnemonic
    const importedDashWallet = new DashWallet({
      network: CryptoNetwork.DASH_MAINNET,
      mnemonic: 'your twelve word mnemonic phrase here'
    });

    Litecoin Wallet

    import { LitecoinWallet, CryptoNetwork } from 'react-native-multi-crypto-wallet';
    
    // Create a new Litecoin wallet
    const ltcWallet = new LitecoinWallet({
      network: CryptoNetwork.LITECOIN_MAINNET // or LITECOIN_TESTNET
    });
    
    // Generate a new mnemonic
    const mnemonic = ltcWallet.generateMnemonic();
    console.log('Mnemonic:', mnemonic);
    
    // Get Litecoin address
    const address = ltcWallet.getAddress();
    console.log('Litecoin Address:', address);
    
    // Import existing wallet from mnemonic
    const importedLtcWallet = new LitecoinWallet({
      network: CryptoNetwork.LITECOIN_MAINNET,
      mnemonic: 'your twelve word mnemonic phrase here'
    });

    Dogecoin Wallet

    import { DogecoinWallet, CryptoNetwork } from 'react-native-multi-crypto-wallet';
    
    // Create a new Dogecoin wallet
    const dogeWallet = new DogecoinWallet({
      network: CryptoNetwork.DOGECOIN_MAINNET // or DOGECOIN_TESTNET
    });
    
    // Generate a new mnemonic
    const mnemonic = dogeWallet.generateMnemonic();
    console.log('Mnemonic:', mnemonic);
    
    // Get Dogecoin address
    const address = dogeWallet.getAddress();
    console.log('Dogecoin Address:', address);
    
    // Import existing wallet from mnemonic
    const importedDogeWallet = new DogecoinWallet({
      network: CryptoNetwork.DOGECOIN_MAINNET,
      mnemonic: 'your twelve word mnemonic phrase here'
    });

    Network Support

    Bitcoin Networks

    • CryptoNetwork.BITCOIN_MAINNET: Bitcoin Mainnet
    • CryptoNetwork.BITCOIN_TESTNET: Bitcoin Testnet

    Ethereum Networks

    • CryptoNetwork.ETHEREUM_MAINNET: Ethereum Mainnet
    • CryptoNetwork.ETHEREUM_GOERLI: Goerli Testnet
    • CryptoNetwork.ETHEREUM_SEPOLIA: Sepolia Testnet

    Binance Smart Chain (BSC) Networks

    • CryptoNetwork.BSC_MAINNET: BSC Mainnet
    • CryptoNetwork.BSC_TESTNET: BSC Testnet

    Polygon Networks

    • CryptoNetwork.POLYGON_MAINNET: Polygon Mainnet
    • CryptoNetwork.POLYGON_MUMBAI: Polygon Mumbai Testnet

    Dash Networks

    • CryptoNetwork.DASH_MAINNET: Dash Mainnet
    • CryptoNetwork.DASH_TESTNET: Dash Testnet

    Litecoin Networks

    • CryptoNetwork.LITECOIN_MAINNET: Litecoin Mainnet
    • CryptoNetwork.LITECOIN_TESTNET: Litecoin Testnet

    Dogecoin Networks

    • CryptoNetwork.DOGECOIN_MAINNET: Dogecoin Mainnet
    • CryptoNetwork.DOGECOIN_TESTNET: Dogecoin Testnet

    Security

    • Never store mnemonics or private keys in plain text
    • Use secure storage solutions for sensitive data
    • Always validate user input
    • Consider using hardware wallets for large amounts

    Development

    Running Tests

    npm test

    Building

    npm run build

    Contributing

    1. Fork the repository
    2. Create your feature branch (git checkout -b feature/amazing-feature)
    3. Commit your changes (git commit -m 'Add some amazing feature')
    4. Push to the branch (git push origin feature/amazing-feature)
    5. Open a Pull Request

    License

    This project is licensed under the MIT License - see the LICENSE file for details.

    Acknowledgments

    • BIP39 for mnemonic generation
    • BIP32 for HD wallet specification
    • BIP44 for multi-account hierarchy