
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
ethereumjs-wallet
Advanced tools
The ethereumjs-wallet package is a JavaScript library that provides tools for creating and managing Ethereum wallets. It allows developers to generate new wallets, import wallets from private keys or mnemonic phrases, and manage wallet data securely.
Generate a new wallet
This feature allows you to generate a new Ethereum wallet. The code sample demonstrates how to create a new wallet instance and retrieve its address.
const Wallet = require('ethereumjs-wallet').default;
const wallet = Wallet.generate();
console.log(wallet.getAddressString());
Import wallet from private key
This feature allows you to import an Ethereum wallet using a private key. The code sample shows how to create a wallet instance from a given private key and retrieve its address.
const Wallet = require('ethereumjs-wallet').default;
const privateKey = Buffer.from('yourprivatekeyhex', 'hex');
const wallet = Wallet.fromPrivateKey(privateKey);
console.log(wallet.getAddressString());
Export wallet to JSON
This feature allows you to export a wallet to a JSON format, which can be used for secure storage. The code sample demonstrates how to export a wallet to a JSON object using a password for encryption.
const Wallet = require('ethereumjs-wallet').default;
const wallet = Wallet.generate();
const json = wallet.toV3('password');
console.log(json);
The ethers.js library is a complete and compact library for interacting with the Ethereum blockchain. It provides similar wallet functionalities, such as creating and managing wallets, but also includes additional features for interacting with smart contracts and the Ethereum network. Compared to ethereumjs-wallet, ethers.js offers a broader range of tools for Ethereum development.
Web3.js is a popular library for interacting with the Ethereum blockchain. It includes wallet management features similar to ethereumjs-wallet, such as creating and importing wallets. However, web3.js is more comprehensive, providing extensive functionalities for interacting with Ethereum nodes, smart contracts, and decentralized applications. It is often used in conjunction with ethereumjs-wallet for more specialized wallet management.
A lightweight wallet implementation. At the moment it supports key creation and conversion between various formats.
It is complemented by the following packages:
Motivations are:
ethereumjs-util
and @ethereumjs/tx
)Features not supported:
For information about the Wallet's API, please go to ./docs/classes/wallet.md.
You can import the Wallet
class like this
Node.js / ES5:
const Wallet = require('ethereumjs-wallet').default
ESM / TypeScript:
import Wallet from 'ethereumjs-wallet'
Importing various third party wallets is possible through the thirdparty
submodule:
Node.js / ES5:
const { thirdparty } = require('ethereumjs-wallet')
ESM / TypeScript:
import { thirdparty } from 'ethereumjs-wallet'
Please go to ./docs/README.md for more info.
To use BIP32 HD wallets, first include the hdkey
submodule:
Node.js / ES5:
const { hdkey } = require('ethereumjs-wallet')
ESM / TypeScript:
import { hdkey } from 'ethereumjs-wallet'
Please go to ./docs/classes/ethereumhdkey.md for more info.
Provider Engine is
not very actively maintained
and support has been removed along v1.0.0
release, see
issue #115 for context.
You can use the the old src/provider-engine.ts
code (see associated PR) as some boilerplate
for your own integration if needed.
toV3
The options
is an optional object hash, where all the serialization parameters can be fine tuned:
kdf
. Size must match the requirements of the KDF (key derivation function). Random number generated via crypto.getRandomBytes
if nothing is supplied.cipher
. Size must match the requirements of the cipher. Random number generated via crypto.getRandomBytes
if nothing is supplied.cipher
settings, this must match the block sizes of those.OpenSSL
, e.g. aes-128-ctr
or aes-128-cbc
.Depending on the kdf
selected, the following options are available too.
For pbkdf2
:
c
- Number of iterations. Defaults to 262144.prf
- The only supported (and default) value is hmac-sha256
. So no point changing it.For scrypt
:
n
- Iteration count. Defaults to 262144.r
- Block size for the underlying hash. Defaults to 8.p
- Parallelization factor. Defaults to 1.The following settings are favoured by the Go Ethereum implementation and we default to the same:
kdf
: scrypt
dklen
: 32
n
: 262144
r
: 8
p
: 1
cipher
: aes-128-ctr
See our organizational documentation for an introduction to EthereumJS
as well as information on current standards and best practices.
If you want to join for work or do improvements on the libraries have a look at our contribution guidelines.
MIT License
Copyright (C) 2016 Alex Beregszaszi
[1.0.2] - 2021-10-08
Source files from the src
folder are now included in the distribution build. This allows for a better debugging experience in debug tools like Chrome DevTools by having working source map references to the original sources available for inspection.
FAQs
Utilities for handling Ethereum keys
The npm package ethereumjs-wallet receives a total of 139,691 weekly downloads. As such, ethereumjs-wallet popularity was classified as popular.
We found that ethereumjs-wallet demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.