Giter Club home page Giter Club logo

ava-hd-wallet's Introduction

ava-hd-wallet

Hierarchical Deterministic Wallet for AVA

Installation

Install it using npm:

npm install --save ava-hd-wallet

Usage

Set mnemonic entropy (length) and generate mnemonic

import AvaHDWallet from "ava-hd-wallet";

// optional - set entropy (default is 256)
AvaHDWallet.setEntropy(256); // -> 24 words mnemonic

const mnemonic = AvaHDWallet.generateMnemonic();
const wallet = AvaHDWallet.fromMnemonic(mnemonic)

wallet.publicKey  // -> X-avax16d7a94xle7pvfztx7p4rct6dzr7dw8m2cwwtda
wallet.privateKey  // -> PrivateKey-2kez3FVVHdubhSNYmgbHHeHY5Pn5p72v7ZLWLqUyEardJzeuGn

Generate keypair using specific mnemonic

import AvaHDWallet from "ava-hd-wallet";

const wallet = AvaHDWallet.fromMnemonic("mushroom crew fluid nephew movie roof guess gas intact actor off race guilt genuine solar move save quarter impact great stove print tourist damp")

wallet.publicKey  // -> X-avax16d7a94xle7pvfztx7p4rct6dzr7dw8m2cwwtda
wallet.privateKey  // -> PrivateKey-2kez3FVVHdubhSNYmgbHHeHY5Pn5p72v7ZLWLqUyEardJzeuGn

Set derivation path (default is m/44'/570'/0)

import AvaHDWallet from "ava-hd-wallet";

AvaHDWallet.setPath("m/44'/9000'/0");
const wallet = AvaHDWallet.fromMnemonic("mushroom crew fluid nephew movie roof guess gas intact actor off race guilt genuine solar move save quarter impact great stove print tourist damp")

wallet.publicKey  // -> X-avax1mtw0dc0d87fq4pnemarcfcs43ngys4ejs4z9tj
wallet.privateKey  // -> PrivateKey-YnKXhuzyxtcd2Pw94xa37bFwi4T2PzxFrNcQe32sbf7FCvXja

Set chain (default is "X")

import AvaHDWallet from "ava-hd-wallet";

AvaHDWallet.setChainId("19");

const mnemonic = AvaHDWallet.generateMnemonic();
const wallet = AvaHDWallet.fromMnemonic(mnemonic)

wallet.publicKey // -> 19-avax1mtw0dc0d87fq4pnemarcfcs43ngys4ejs4z9tj
wallet.privateKey // -> PrivateKey-YnKXhuzyxtcd2Pw94xa37bFwi4T2PzxFrNcQe32sbf7FCvXja

Generate wallet by given xpub and xprv

import AvaHDWallet from "ava-hd-wallet";

AvaHDWallet.setPath("m/44'/9000'/0");
const wallet = AvaHDWallet.fromMnemonic("mushroom crew fluid nephew movie roof guess gas intact actor off race guilt genuine solar move save quarter impact great stove print tourist damp")

AvaHDWallet.setPath("m/0/1");

AvaHDWallet.fromExtendedPublicKey(wallet.publicExtendedKey) // -> { publicKey: 'X-avax16qm93a9ask30qldw94jz686s7z7dw5ecyrezna', privateKey: null }
AvaHDWallet.fromExtendedPrivateKey(wallet.privateExtendedKey) // -> {publicKey: 'avax16qm93a9ask30qldw94jz686s7z7dw5ecyrezna', privateKey:'PrivateKey-jUEHoYnyvLMByd4EsuNbMVYfZCgpipthgKTo1TSv3xnsjx7w'}

Copyright © 2020 Mert Gönül (DataDef)

ava-hd-wallet's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

ava-hd-wallet's Issues

TypeError: Avalanche.avm.AVMKeyChain is not a constructor

Did something change that's causing this error?

let keychain = new Avalanche.avm.AVMKeyChain(hrp, this.chain_id);
                   ^
TypeError: Avalanche.avm.AVMKeyChain is not a constructor
    at AvaHDWallet.fromMnemonic (node_modules/ava-hd-wallet/lib/index.js:56:20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.