or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

hdnode-class.mdindex.mdmnemonic-operations.mdutility-functions.md
tile.json

tessl/npm-ethersproject--hdnode

BIP32 Hierarchical Deterministic Node operations for Ethereum wallets and key derivation.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@ethersproject/hdnode@5.8.x

To install, run

npx @tessl/cli install tessl/npm-ethersproject--hdnode@5.8.0

index.mddocs/

HDNode

HDNode provides BIP32 Hierarchical Deterministic wallet functionality for Ethereum and other cryptocurrencies. It enables deterministic key pair generation from mnemonic phrases, hierarchical key derivation using standard paths, and comprehensive wallet management with full BIP39/BIP32 compliance.

Package Information

  • Package Name: @ethersproject/hdnode
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @ethersproject/hdnode

Core Imports

import { HDNode, mnemonicToSeed, defaultPath, type Mnemonic } from "@ethersproject/hdnode";
import { Wordlist } from "@ethersproject/wordlists";
import { BytesLike } from "@ethersproject/bytes";

For CommonJS:

const { HDNode, mnemonicToSeed, defaultPath } = require("@ethersproject/hdnode");

Basic Usage

import { HDNode, mnemonicToSeed, isValidMnemonic } from "@ethersproject/hdnode";

// Create HDNode from mnemonic
const mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
const rootNode = HDNode.fromMnemonic(mnemonic);

// Derive child keys using BIP44 paths
const accountNode = rootNode.derivePath("m/44'/60'/0'/0/0");
console.log("Address:", accountNode.address);
console.log("Private Key:", accountNode.privateKey);

// Validate mnemonic phrases
const isValid = isValidMnemonic(mnemonic);
console.log("Valid mnemonic:", isValid);

// Convert mnemonic to seed
const seed = mnemonicToSeed(mnemonic, "optional-password");
console.log("Seed:", seed);

Architecture

The HDNode package is structured around several key components:

  • HDNode Class: Core hierarchical deterministic node implementation supporting key derivation and wallet operations
  • Mnemonic Operations: BIP39 mnemonic phrase generation, validation, and conversion utilities
  • Key Derivation: BIP32 hierarchical key derivation with support for hardened and non-hardened paths
  • Extended Keys: BIP32 extended key format support for serialization and deserialization
  • Ethereum Integration: Native Ethereum address generation and signing key management

Capabilities

HDNode Class Operations

Core hierarchical deterministic node functionality for key derivation, wallet management, and extended key operations.

class HDNode {
  readonly privateKey: string | null;
  readonly publicKey: string;
  readonly address: string;
  readonly mnemonic?: Mnemonic;
  readonly path: string;
  
  static fromMnemonic(mnemonic: string, password?: string, wordlist?: string | Wordlist): HDNode;
  static fromSeed(seed: BytesLike): HDNode;
  static fromExtendedKey(extendedKey: string): HDNode;
  
  derivePath(path: string): HDNode;
  neuter(): HDNode;
  get extendedKey(): string;
}

HDNode Class

Mnemonic Operations

BIP39 mnemonic phrase operations including generation, validation, and conversion between mnemonic phrases, entropy, and seeds.

function mnemonicToSeed(mnemonic: string, password?: string): string;
function mnemonicToEntropy(mnemonic: string, wordlist?: string | Wordlist): string;
function entropyToMnemonic(entropy: BytesLike, wordlist?: string | Wordlist): string;
function isValidMnemonic(mnemonic: string, wordlist?: Wordlist): boolean;

Mnemonic Operations

Utility Functions

Helper functions for path generation and common operations.

const defaultPath: string; // "m/44'/60'/0'/0/0"
function getAccountPath(index: number): string;

Utility Functions

Types

interface Mnemonic {
  readonly phrase: string;
  readonly path: string;
  readonly locale: string;
}