@dashevo/wallet-lib
Version:
Light wallet library for Dash
85 lines (59 loc) • 2.6 kB
Markdown
[](https://www.npmjs.com/package/@dashevo/wallet-lib)
[](https://github.com/dashpay/platform/actions/workflows/release.yml)
[](https://github.com/dashpay/platform/releases/latest)
[](https://github.com/RichardLitt/standard-readme)
A pure and extensible JavaScript Wallet Library for Dash
Wallet-lib provides all the wallet features needed for node and browser usage.
From being able to display an account balance, to paying to another address, passing by the need to automate back-end task related to a cold-storage.
Wallet-lib allows you to easily work with Wallets/Accounts for HDWallets, or from just a single private key.
It also allows you to monitor public keys and HDPubKey.
You might also wish to create your own set of plugins or your own coin selection logic.
In order to use this library in Node, you will need to add it to your project as a dependency.
Having [NodeJS](https://nodejs.org/) installed, just type in your terminal :
```sh
npm install @dashevo/wallet-lib
```
For browser usage, you can also directly rely on unpkg :
```
<script src="https://unpkg.com/@dashevo/wallet-lib"></script>
```
In your file, where you want to execute it :
```js
const { Wallet, EVENTS } = require('@dashevo/wallet-lib');
const wallet = new Wallet();
// We can dump our initialization parameters
const mnemonic = wallet.exportWallet();
// Hook on headers and TX sync progress events
wallet.on(EVENTS.HEADERS_SYNC_PROGRESS, (progressInfo) => {
const {
confirmedProgress,
totalProgress,
confirmedSyncedCount,
totalSyncedCount,
totalCount
} = progressInfo;
})
wallet.on(EVENTS.TRANSACTIONS_SYNC_PROGRESS, (progressInfo) => {
const {
progress,
syncedBlocksCount,
totalBlocksCount,
transactionsCount
} = progressInfo;
})
wallet.getAccount().then((account) => {
// At this point, account has fetch all UTXOs if they exists
const balance = account.getTotalBalance();
console.log(`Balance: ${balance}`);
// We easily can get a new address to fund
const { address } = account.getUnusedAddress();
});
```
[](https://github.com/dashevo/wallet-lib/blob/master/LICENCE.md) © Dash Core Group, Inc.