Factories

The following factory and helper functions are exported at the top-level package module.

createWallet(rootSeed)

Initialize an HD wallet master node at a root seed

Returns:the initialized Wallet instance.
Arguments
Name Type Required Description
rootSeed string Yes 512-bit hexadecimal key of the HD wallet root node

Examples

Creating a new Wallet

1
2
3
4
5
import { createWallet } from 'cryptoasset-wallet'

// glare exile skill cinnamon vehicle blossom join argue crash rent way layer yellow web future
const rootSeed = '86bd966a3bb5f6e9c28166c95f2bb7ca4e0f55d62399e6d27baaf6855de4d73178c6bd8da57f3d62fcca1b94873c25b77c557e07892fd26191d42b9d48ecea85'
const wallet = createWallet(rootSeed)
restoreWallet(rootSeed, walletJSON)

Restores a wallet from a root seed and JSON export created with Wallet.export.

Returns:the restored Wallet instance.
Arguments
Name Type Required Description
rootSeed string Yes 512-bit hexadecimal key of the HD wallet root node
walletJSON object Yes Wallet structure obtained through the Wallet export method

Examples

Restoring a Wallet From Backup

1
2
3
4
5
6
7
import { restoreWallet } from 'cryptoasset-wallet'
import backup from './my-wallet-backup.json'

// glare exile skill cinnamon vehicle blossom join argue crash rent way layer yellow web future
const rootSeed = '86bd966a3bb5f6e9c28166c95f2bb7ca4e0f55d62399e6d27baaf6855de4d73178c6bd8da57f3d62fcca1b94873c25b77c557e07892fd26191d42b9d48ecea85'
const wallet = restoreWallet(rootSeed, backup)
console.log("My accounts are:", wallet.accounts)