Skip to content

Files

Latest commit

Jun 11, 2025
a054f79 · Jun 11, 2025

History

History

wallet

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Apr 25, 2025
Nov 13, 2024
Apr 26, 2025
Apr 28, 2025
May 26, 2023
Apr 29, 2025
May 26, 2023
Jun 11, 2025
Mar 18, 2025
Apr 29, 2025
Mar 10, 2025
Nov 17, 2024
Mar 10, 2025
Mar 10, 2025
Apr 25, 2025
Jun 22, 2023

README.md

@ethereumjs/wallet v10

NPM Package Actions Status Coverage Status Discord

[DEPRECATED] This library has been deprecated (insufficient maintenance + alternatives available (Ethers).

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:

  • be lightweight
  • work in a browser
  • use a single, maintained version of crypto library (and that should be in line with @ethereumjs/util and @ethereumjs/tx)
  • support import/export between various wallet formats
  • support BIP32 HD keys

Features not supported:

  • signing transactions
  • managing storage (neither in node.js or the browser)

Table of Contents

Wallet API

For information about the Wallet's API, please go to ./docs/classes/wallet.md.

You can import the Wallet class like this

Node.js / ES6:

// ./examples/wallet.cjs

const { Wallet } = require('@ethereumjs/wallet')

const wallet = Wallet.generate()
console.log(wallet.getAddressString()) // should output an Ethereum address

ESM / TypeScript:

// ./examples/wallet.ts

import { Wallet } from '@ethereumjs/wallet'

const wallet = Wallet.generate()
console.log(wallet.getAddressString()) // should output an Ethereum address

Thirdparty API

Importing various third party wallets is possible through the thirdparty submodule:

Node.js / ES5:

// ./examples/thirdparty.cjs

const { thirdparty } = require('@ethereumjs/wallet')

const wallet = thirdparty.fromQuorumWallet('mySecretQuorumWalletPassphrase', 'myPublicQuorumUserId')
console.log(wallet.getAddressString()) // An Ethereum address

ESM / TypeScript:

// ./examples/thirdparty.ts

import { thirdparty } from '@ethereumjs/wallet'

const wallet = thirdparty.fromQuorumWallet('mySecretQuorumWalletPassphrase', 'myPublicQuorumUserId')
console.log(wallet.getAddressString()) // An Ethereum address

Please go to ./docs/README.md for more info.

HD Wallet API

To use BIP32 HD wallets, first include the hdkey submodule:

Node.js / ES5:

// ./examples/hdKey.cjs

const { hdkey } = require('@ethereumjs/wallet')

const wallet = hdkey.EthereumHDKey.fromMnemonic(
  'clown galaxy face oxygen birth round modify fame correct stumble kind excess',
)
console.log(wallet.getWallet().getAddressString()) // Should print an Ethereum address

ESM / TypeScript:

// ./examples/hdKey.ts

import { hdkey } from '@ethereumjs/wallet'

const wallet = hdkey.EthereumHDKey.fromMnemonic(
  'clown galaxy face oxygen birth round modify fame correct stumble kind excess',
)
console.log(wallet.getWallet().getAddressString()) // Should print an Ethereum address

Please go to ./docs/classes/ethereumhdkey.md for more info.

Special Topics

Remarks about toV3

The options is an optional object hash, where all the serialization parameters can be fine tuned:

  • uuid - UUID. One is randomly generated.
  • salt - Random salt for the kdf. Size must match the requirements of the KDF (key derivation function). Random number generated via crypto.getRandomBytes if nothing is supplied.
  • iv - Initialization vector for the cipher. Size must match the requirements of the cipher. Random number generated via crypto.getRandomBytes if nothing is supplied.
  • kdf - The key derivation function, see below.
  • dklen - Derived key length. For certain cipher settings, this must match the block sizes of those.
  • cipher - The cipher to use. Names must match those of supported by 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

EthereumJS

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.

License

MIT License

Copyright (C) 2016 Alex Beregszaszi