1.0.7 • Published 5 months ago
ethereum-wallet-utils v1.0.7
Ethereum Wallet Utils
Overview
Ethereum Wallet Utils is a lightweight JavaScript library for managing Ethereum wallets. It provides functionalities for generating Ethereum wallets, encrypting and decrypting private keys, signing messages, and verifying signatures.
Features
- Generate a new Ethereum wallet (address, private key, and mnemonic)
- Encrypt and decrypt private keys securely
- Sign messages using a private key
- Verify signed messages
- Built using
ethers.js
Installation
You can install the package using npm:
npm install ethereum-wallet-utils
Or using yarn:
yarn add ethereum-wallet-utils
Usage
Importing the Library
import {
generateWallet,
encryptPrivateKey,
decryptPrivateKey,
signMessage,
verifyMessage
} from 'ethereum-wallet-utils';
Generate a New Ethereum Wallet
const wallet = generateWallet();
console.log(wallet);
// Output: { address: '0x...', privateKey: '0x...', mnemonic: '...' }
Encrypt a Private Key
const encryptedKey = await encryptPrivateKey(wallet.privateKey, 'your-secure-password');
console.log(encryptedKey);
Decrypt a Private Key
const privateKey = await decryptPrivateKey(encryptedKey, 'your-secure-password');
console.log(privateKey);
Sign a Message
const message = "Hello, Ethereum!";
const signature = await signMessage(wallet.privateKey, message);
console.log(signature);
Verify a Signed Message
const isValid = verifyMessage(message, signature);
console.log(isValid);
// Output: 0x... (Recovered Ethereum address)
Repository
- GitHub: Ethereum Wallet Utils
Issues & Contributions
If you find any issues or would like to contribute, please open an issue or create a pull request on GitHub.
📄 License
This project is licensed under the MIT License.