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-walletDependencies
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 MainnetCryptoNetwork.BITCOIN_TESTNET: Bitcoin Testnet
Ethereum Networks
CryptoNetwork.ETHEREUM_MAINNET: Ethereum MainnetCryptoNetwork.ETHEREUM_GOERLI: Goerli TestnetCryptoNetwork.ETHEREUM_SEPOLIA: Sepolia Testnet
Binance Smart Chain (BSC) Networks
CryptoNetwork.BSC_MAINNET: BSC MainnetCryptoNetwork.BSC_TESTNET: BSC Testnet
Polygon Networks
CryptoNetwork.POLYGON_MAINNET: Polygon MainnetCryptoNetwork.POLYGON_MUMBAI: Polygon Mumbai Testnet
Dash Networks
CryptoNetwork.DASH_MAINNET: Dash MainnetCryptoNetwork.DASH_TESTNET: Dash Testnet
Litecoin Networks
CryptoNetwork.LITECOIN_MAINNET: Litecoin MainnetCryptoNetwork.LITECOIN_TESTNET: Litecoin Testnet
Dogecoin Networks
CryptoNetwork.DOGECOIN_MAINNET: Dogecoin MainnetCryptoNetwork.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 testBuilding
npm run buildContributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.