Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web3-hd-wallet

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-hd-wallet

Ethereum HD Wallet

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Web3 HD Wallet

Web3 HD Wallet is a package that provides functionality to generate HD wallets and encrypt/decrypt private keys.

Installation

To install the package, use npm:

npm install web3-hd-wallet --save

Usage

HD Wallet

const { HdWallet } = require('web3-hd-wallet');

const hdWallet = new HdWallet();

const mnemonic = hdWallet.generateMnemonic();
console.log('Mnemonic:', mnemonic);

const wallets = hdWallet.generateHDWallets({
  mnemonic: mnemonic,
  numOfWallets: 3,
  hdPath: "m/44'/60'/0'/0",
});
console.log('HD Wallets:', wallets);

Web3Eth

const { Web3Eth } = require('web3-hd-wallet');
const web3Eth = new Web3Eth('http://localhost:8545');

const encryptedKey = web3Eth.encrypt({
  privateKey: '0x1234567890abcdef',
  password: 'testpassword',
});
console.log('Encrypted Key:', encryptedKey);

const decryptedWallet = web3Eth.decrypt({
  keystoreJson: { /* Keystore JSON object */ },
  password: 'testpassword',
});
console.log('Decrypted Wallet:', decryptedWallet);

API

HD Wallet Methods

  • generateMnemonic(): string: Generates a random mnemonic phrase.
  • generateHDWallets(params: IHdWallet): Array<{ address: string, privateKey: string }>: Generates multiple HD wallets based on the provided parameters. The params object should have the following properties:
    • mnemonic (string): The mnemonic phrase.
    • numOfWallets (number): The number of wallets to generate.
    • hdPath (string, optional): The HD derivation path (default: "m/44'/60'/0'/0").

Web3Eth Methods

  • encrypt(params: IWeb3Encrypt): any: Encrypts a wallet private key. The params object should have the following properties:
    • privateKey (string): The private key to encrypt.
    • password (string): The password used for encryption.
  • decrypt(params: IWeb3Decrypt): any: Decrypts a keystore JSON. The params object should have the following properties:
    • keystoreJson (any): The keystore JSON object to decrypt.
    • password (string): The password used for decryption.

For detailed information about the parameters and return values, refer to the inline documentation in the source code.

Keywords

FAQs

Package last updated on 27 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc