Skip to content

RadarTech/wallet-manager

Repository files navigation

wallet-manager

A library that simplifies Ethereum wallet creation.

npm version CircleCI

Installation

npm

npm install @radarrelay/wallet-manager

Yarn

yarn add @radarrelay/wallet-manager

LightWallet Usage

Import

import { LightWalletManager } from '@radarrelay/wallet-manager';

LightWalletManager Methods

Create a new wallet

Create a new lightwallet and save it into local storage or as a file.

Options:

  • password (mandatory) A string used to encrypt the vault when serialized.
  • seedPhrase (optional) A twelve-word mnemonic used to generate all accounts. Randomly generated if not supplied.
  • salt (optional) The salt used to encrypt & decrypt the vault. Randomly generated if not supplied.
  • hdPathString (optional) A BIP39 compliant HD Path String. Defaults to m/44'/60'/0'/0.
  • storageKeyName (optional) The local storage key or file name.
const lightWallet = await LightWalletManager.createWalletAsync(options: LightWalletOptions): Promise<LightWallet>

Save an existing wallet

Save the encrypted lightwallet into local storage or as a file.

LightWalletManager.saveWallet(wallet: LightWallet): void

Load an existing wallet

Load the lightwallet from local storage or the file system.

const lightWallet = await LightWalletManager.loadWalletAsync(password: string): Promise<LightWallet>

LightWallet Methods

Add new accounts

Adds 1 or more accounts to the lightwallet instance and saves the updated wallet.

lightWallet.addNewAccounts(numberOfAccounts: number = 1): void

Export private key

Exports the private key for a single account.

const privateKey = lightWallet.exportAccountPrivateKeyAsync(account: string, password: string): Promise<string>

Export seed phrase

Exports the wallet's seed phrase.

const seedPhrase = await lightWallet.exportSeedPhraseAsync(password: string): Promise<string>

Get accounts

Gets all the accounts from the wallet.

const accounts = lightWallet.getAccounts(): string[]

Serialize

Serialize the encrypted lightwallet.

const serializedWallet = lightWallet.serialize(): string

Signer Methods

Sign a message

const signedMsg = await lightWallet.signer.signPersonalMessageAsync(account: string, message: string): Promise<string>

Sign a message hash

const signedMsgHash = await lightWallet.signer.signPersonalMessageHashAsync(account: string, messageHash: string): Promise<string>

Sign a transaction

const signedTx = await lightWallet.signer.signTransactionAsync(txParams: PartialTxParams): Promise<string>

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

A library that simplifies Ethereum wallet creation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published