Javascript SDK of WoopChain protocol
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
sdk/packages/harmony-account
neeboo dce1b4d29e v0.0.60 5 years ago
..
src fix(transaction):fixed recover and setParams, and passed e2e and unit tests 5 years ago
LICENSE [feat] update LICENSE 6 years ago
README.md [breaking] rename packages dependency prefix to `@harmony-js` 6 years ago
package.json v0.0.60 5 years ago
tsconfig.json [FIX] update tsconfig.json 6 years ago
tsconfig.test.json [fix] update a lot and add test fixtures for transaction 6 years ago

README.md

Features

  1. Account instance
  2. Create Account
  3. Import prv key
  4. Import/Export keystore file
  5. BIP39
  6. BIP44
  7. [WIP] Sign txn/message
  8. getBalance
  9. Wallet CRUD

Wallet Usage


import { Wallet } from '@harmony-js/account';

const wallet = new Wallet();

const mnes = wallet.generateMnemonic();

// add mnemonic and use index=0
const accountA = wallet.addByMnemonic(mnes,0);

// this account instance will be the wallet's signer by default
console.log(wallet.signer.address === accountA.address)
// true

wallet.encryptAccount(accountA.address,'easy password')
    .then((encrypted)=>{
        console.log(encrypted.privateKey);
        // private key now is keyStoreV3 format string

        wallet.decryptAccount(accountA.address,'easy password')
            .then((decrypted)=>{
                console.log(decrypted.privateKey);
                // now private key is recovered
            })
    });


wallet.accounts
// it will display accounts addresses live in wallet

wallet.getAccount(accountA.address);
// it will get account instance by using address as reference

wallet.removeAccount(accountA.address);
// it will remove account instance from wallet

wallet.createAccount();
// it will create a new acount instance

wallet.addByPrivateKey(key);
// you can add private key directly as well