Skip to content

HdKey.fromSeed

Creates a HD Key from a master seed.

Imports

Named
import { HdKey } from 'ox'

Examples

import { HdKey, Mnemonic } from 'ox'
 
const seed = Mnemonic.toSeed('test test test test test test test test test test test junk')
const hdKey = HdKey.fromSeed(seed)

Path Derivation

You can derive a HD Key at a specific path using derive.

import { HdKey, Mnemonic } from 'ox'
 
const mnemonic = Mnemonic.toSeed('test test test test test test test test test test test junk')
const hdKey = HdKey.fromSeed(mnemonic).derive(HdKey.path())
 
console.log(hdKey.privateKey)
'0x...'

Definition

function fromSeed(
  seed: Hex.Hex | Bytes.Bytes,
  options?: fromSeed.Options,
): HdKey

Source: src/core/HdKey.ts

Parameters

seed

  • Type: Hex.Hex | Bytes.Bytes

The master seed to create the HD Key from.

options

  • Type: fromSeed.Options
  • Optional

Creation options.

options.versions

  • Type: Versions | undefined
  • Optional

The versions to use for the HD Key.

Return Type

The HD Key.

HdKey.HdKey