Skip to content
Cive

Mnemonic Account

A Mnemonic Account is a Hierarchical Deterministic (HD) Account that is derived from a BIP-39 mnemonic phrase and an optional HD path.

It has the ability to sign transactions and messages with the private key derived from the HD Node.

Import

import {  } from "cive/accounts";

Usage

To initialize a Mnemonic Account, you will need to pass a mnemonic phrase to mnemonicToAccount:

import { ,  } from "cive";
import {  } from "cive/accounts";
import {  } from "cive/chains";
 
const  = (
  "surge stable sick canyon you absent rigid define rack banana author retire", 
  { : . } 
);
 
const  = ({
  ,
  : ,
  : (),
});

Generating Mnemonics

You can generate a random BIP-39 mnemonic using the generateMnemonic function with a wordlist:

import {  } from "cive/chains";
import { , ,  } from "cive/accounts";
 
const  = (); 
const  = (, { : . });

Available wordlists:

  • czech
  • english
  • french
  • italian
  • japanese
  • korean
  • simplifiedChinese
  • spanish
  • traditionalChinese
import {
  ,
  ,
  ,
  ,
  ,
  ,
  ,
  ,
  ,
} from "cive/accounts";

Parameters

mnemonic

  • Type: string

The BIP-39 mnemonic phrase.

const  = (
  "surge stable sick canyon you absent rigid define rack banana author retire", //,
  { : . } 
);
.;
// 'cfx:aan3gfd3b9nnwba7928ckpt7zfkbkncngpc0gp5xjm'

options.networkId

  • Type: number

The network id of the Account.

const  = (
  "surge stable sick canyon you absent rigid define rack banana author retire", //,
  { : . } 
);

options.accountIndex

  • Type: number
  • Default: 0

The account index to use in the path ("m/44'/503'/${accountIndex}'/0/0") to derive a private key.

const  = (
  "surge stable sick canyon you absent rigid define rack banana author retire",
  {
    : .,
    : 1, 
  }
);

options.addressIndex

  • Type: number
  • Default: 0

The address index to use in the path ("m/44'/503'/0'/0/${addressIndex}") to derive a private key.

const  = (
  "surge stable sick canyon you absent rigid define rack banana author retire",
  {
    : .,
    : 1,
    : 6, 
  }
);

options.changeIndex

  • Type: number
  • Default: 0

The change index to use in the path ("m/44'/503'/0'/0/${addressIndex}") to derive a private key.

const  = (
  "surge stable sick canyon you absent rigid define rack banana author retire",
  {
    : .,
    : 1,
    : 6,
    : 2, 
  }
);

options.path

  • Type: "m/44'/503'/${string}"

The HD path to use to derive a private key.

const  = (
  "surge stable sick canyon you absent rigid define rack banana author retire",
  {
    : .,
    : "m/44'/503'/5'/0/2", 
  }
);