# althashjs-lib

> An extend lib for bitcoinjs-lib, it supports two new network of html and html-testnet, and it can generate contract creating and sending transactions

Latest version **0.0.8** (published 2020-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install althashjs-lib
pnpm add althashjs-lib
yarn add althashjs-lib
bun add althashjs-lib
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2020-08-28 |
| First published | 2020-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Qtum Weiyu |
| Maintainers | machado-rev |
| Keywords | althash, althashjs, smart contract, htmlcoin, bitcoin |

## Links

- npm: https://www.npmjs.com/package/althashjs-lib
- Repository: https://github.com/machado-rev/althashjs-lib
- Homepage: https://github.com/machado-rev/althashjs-lib#readme
- Issues: https://github.com/machado-rev/althashjs-lib/issues
- npm.io page: https://npm.io/package/althashjs-lib

## Dependencies (4)

- [safe-buffer](https://npm.io/package/safe-buffer.md) ^5.1.1
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^4.1.0
- [bitcoinjs-lib](https://npm.io/package/bitcoinjs-lib.md) ^3.3.2
- [althash-opcodes](https://npm.io/package/althash-opcodes.md) ^1.0.0

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.0.8 (latest) — 2020-08-28

## README

# qtumjs-lib
This is an extend lib for bitcoinjs-lib.
It extends the network type of bitcoinjs-lib.
It also provides an useful lib to help you building QTUM transactions.

## Installation
``` bash
npm install qtumjs-lib
```

## Setup
### Node.js
``` javascript
var qtumjs = require('qtumjs-lib')
```

## New features
### Network
```
{
    qtum: {
        messagePrefix: '\x18Qtum Signed Message:\n',
        bech32: 'qc',
        bip32: {
            public: 0x0488b21e,
            private: 0x0488ade4
        },
        pubKeyHash: 0x3a,
        scriptHash: 0x32,
        wif: 0x80
    },
    qtum_testnet: {
        messagePrefix: '\x18Qtum Signed Message:\n',
        bech32: 'tq',
        bip32: {
            public: 0x043587cf,
            private: 0x04358394
        },
        pubKeyHash: 0x78,
        scriptHash: 0x6e,
        wif: 0xef
    }
}

```

### Utils
#### Utils.selectTxs
```javascript
/**
 * This is a function for selecting QTUM utxos to build transactions
 * the transaction object takes at least 3 fields, value(unit is 1e-8 QTUM) , confirmations and isStake
 *
 * @param [transaction] unspentTransactions
 * @param Number amount(unit: QTUM)
 * @param Number fee(unit: QTUM)
 * @returns [transaction]
 */
function selectTxs(unspentTransactions, amount, fee)
```
#### Utils.buildPubKeyHashTransaction
```javascript
/**
 * This is a helper function to build a pubkeyhash transaction
 * the transaction object takes at least 5 fields, value(unit is 1e-8 QTUM), confirmations, isStake, hash and pos
 *
 * @param bitcoinjs-lib.KeyPair keyPair
 * @param String to
 * @param Number amount(unit: QTUM)
 * @param Number fee(unit: QTUM)
 * @param [transaction] utxoList
 * @returns String the built tx
 */
function buildPubKeyHashTransaction(keyPair, to, amount, fee, utxoList)
```
#### Utils.buildCreateContractTransaction
```javascript
/**
 * This is a helper function to build a create-contract transaction
 * the transaction object takes at least 5 fields, value(unit is 1e-8 QTUM), confirmations, isStake, hash and pos
 *
 * @param bitcoinjs-lib.KeyPair keyPair
 * @param String code The contract byte code
 * @param Number gasLimit
 * @param Number gasPrice(unit: 1e-8 QTUM/gas)
 * @param Number fee(unit: QTUM)
 * @param [transaction] utxoList
 * @returns String the built tx
 */
function buildCreateContractTransaction(keyPair, code, gasLimit, gasPrice, fee, utxoList)
```
#### Utils.buildSendToContractTransaction
```javascript
/**
 * This is a helper function to build a send-to-contract transaction
 * the transaction object takes at least 5 fields, value(unit is 1e-8 QTUM), confirmations, isStake, hash and pos
 *
 * @param bitcoinjs-lib.KeyPair keyPair
 * @param String contractAddress The contract address
 * @param String encodedData The encoded abi data
 * @param Number gasLimit
 * @param Number gasPrice(unit: 1e-8 QTUM/gas)
 * @param Number fee(unit: QTUM)
 * @param [transaction] utxoList
 * @returns String the built tx
 */
function buildSendToContractTransaction(keyPair, contractAddress, encodedData, gasLimit, gasPrice, fee, utxoList)
```

---
_Source: https://npm.io/package/althashjs-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
