Package Exports
- @harmony-js/account
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@harmony-js/account) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Features
- Account instance
- Create Account
- Import prv key
- Import/Export keystore file
- BIP39
- BIP44
- [WIP] Sign txn/message
- getBalance
- 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