# cron-lib-alpha

> Node.js integration example

Latest version **0.1.13** (published 2020-06-25) · 0 weekly downloads

## Install

```sh
npm install cron-lib-alpha
pnpm add cron-lib-alpha
yarn add cron-lib-alpha
bun add cron-lib-alpha
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.13 |
| Published | 2020-06-25 |
| First published | 2020-01-10 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | kolerts, volkoff |

## Links

- npm: https://www.npmjs.com/package/cron-lib-alpha
- npm.io page: https://npm.io/package/cron-lib-alpha

## Dependencies (1)

- [request](https://npm.io/package/request.md) 2.88.0

## Recent versions

- 0.1.13 (latest) — 2020-06-25
- 0.1.12 — 2020-06-03
- 0.1.11 — 2020-06-03
- 0.1.10 — 2020-05-21
- 0.1.9 — 2020-05-21
- 0.1.8 — 2020-05-20
- 0.1.7 — 2020-02-25
- 0.1.6 — 2020-02-25
- 0.1.5 — 2020-02-05
- 0.1.4 — 2020-02-05
- 0.1.3 — 2020-01-21
- 0.1.2 — 2020-01-21
- 0.1.1 — 2020-01-17
- 0.1.0 — 2020-01-15
- 0.0.9 — 2020-01-15
- … 8 more at https://npm.io/package/cron-lib-alpha/versions

## README

<a name="Client"></a>

## Client
Client class for Cron RPC.
Node.js CRON integration example

**Kind**: global class  

* [Client](#Client)
    * [new Client([url], [protocol], [host], [port])](#new_Client_new)
    * [.newPrivateKey()](#Client+newPrivateKey) ⇒ <code>String</code>
    * [.getKeys(id)](#Client+getKeys) ⇒ <code>Promise</code>
    * [.generateKeyPair(id)](#Client+generateKeyPair) ⇒ <code>Promise</code>
    * [.getBalance(address, id)](#Client+getBalance) ⇒ <code>Promise</code>
    * [.getUnspents(address,, asset, id)](#Client+getUnspents) ⇒ <code>Promise</code>
    * [.getTxHeight(txId, id)](#Client+getTxHeight) ⇒ <code>Promise</code>
    * [.getTxOut(txId, index, id)](#Client+getTxOut) ⇒ <code>Promise</code>
    * [.getTxInfo(txId, verbose, id)](#Client+getTxInfo) ⇒ <code>Promise</code>
    * [.getTxs(wallet)](#Client+getTxs) ⇒ <code>Promise</code>
    * [.sendTransaction(data, id)](#Client+sendTransaction) ⇒ <code>Promise</code>
    * [.getBlockCount()](#Client+getBlockCount) ⇒ <code>Promise</code>
    * [.callRpc(method, id, params)](#Client+callRpc) ⇒ <code>Promise</code>

<a name="new_Client_new"></a>

### new Client([url], [protocol], [host], [port])

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [url] | <code>string</code> |  | connection url (use other params if not specified) |
| [protocol] | <code>string</code> | <code>&quot;http&quot;</code> | connection protocol |
| [host] | <code>string</code> |  | connection host |
| [port] | <code>string</code> |  | connection port |

<a name="Client+newPrivateKey"></a>

### client.newPrivateKey() ⇒ <code>String</code>
Generate new privateKey

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>String</code> - new privateKey  
<a name="Client+getKeys"></a>

### client.getKeys(id) ⇒ <code>Promise</code>
get keys info by privateKey

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>Promise</code> - Promise object with object with publicKey, privateKey and other key info  

| Param | Type | Default |
| --- | --- | --- |
| id | <code>number</code> | <code>1</code> | 

<a name="Client+generateKeyPair"></a>

### client.generateKeyPair(id) ⇒ <code>Promise</code>
Generate new key pair

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>Promise</code> - Promise object with object with publicKey and privateKey  

| Param | Type | Default |
| --- | --- | --- |
| id | <code>number</code> | <code>1</code> | 

<a name="Client+getBalance"></a>

### client.getBalance(address, id) ⇒ <code>Promise</code>
Get address current balance

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>Promise</code> - Promise object with current balance of given address  

| Param | Type | Default |
| --- | --- | --- |
| address | <code>string</code> |  | 
| id | <code>number</code> | <code>1</code> | 

<a name="Client+getUnspents"></a>

### client.getUnspents(address,, asset, id) ⇒ <code>Promise</code>
Get address unspents

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>Promise</code> - Promise object with current unspents  

| Param | Type | Description |
| --- | --- | --- |
| address, | <code>string</code> |  |
| asset | <code>string</code> | (not required), |
| id | <code>number</code> |  |

<a name="Client+getTxHeight"></a>

### client.getTxHeight(txId, id) ⇒ <code>Promise</code>
Get transaction height

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>Promise</code> - txBlock  

| Param | Type | Default |
| --- | --- | --- |
| txId | <code>string</code> |  | 
| id | <code>number</code> | <code>1</code> | 

<a name="Client+getTxOut"></a>

### client.getTxOut(txId, index, id) ⇒ <code>Promise</code>
Get transaction out

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>Promise</code> - tx data  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| txId | <code>string</code> |  |  |
| index | <code>number</code> | <code>0</code> | The index of the transaction output to be obtained in the transaction (starts from 0) |
| id | <code>number</code> | <code>1</code> |  |

<a name="Client+getTxInfo"></a>

### client.getTxInfo(txId, verbose, id) ⇒ <code>Promise</code>
Get transaction info (getrawtransaction)

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>Promise</code> - tx data  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| txId | <code>string</code> |  |  |
| verbose | <code>number</code> | <code>1</code> | When verbose is 1, detailed information of the corresponding block in Json format string, is returned |
| id | <code>number</code> | <code>1</code> |  |

<a name="Client+getTxs"></a>

### client.getTxs(wallet) ⇒ <code>Promise</code>
Get transactions by address (cron_get_transactions)

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>Promise</code> - txs list  

| Param | Type | Description |
| --- | --- | --- |
| wallet | <code>string/array</code> | address |

<a name="Client+sendTransaction"></a>

### client.sendTransaction(data, id) ⇒ <code>Promise</code>
Send transaction

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>Promise</code> - Promise object with hash of new transaction  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| data | <code>object</code> |  | Object with privateKey, to, amount, asset(optional), message(optional), fee(optional) |
| id | <code>number</code> | <code>1</code> |  |

<a name="Client+getBlockCount"></a>

### client.getBlockCount() ⇒ <code>Promise</code>
Get blockchain block count

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>Promise</code> - Promise object with blockCount  
<a name="Client+callRpc"></a>

### client.callRpc(method, id, params) ⇒ <code>Promise</code>
Call RPC API-method

**Kind**: instance method of [<code>Client</code>](#Client)  
**Returns**: <code>Promise</code> - Promise object with blockCount  

| Param | Type |
| --- | --- |
| method | <code>string</code> | 
| id | <code>number</code> | 
| params | <code>object</code> |

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