# chia-daemon

> A JS daemon client for chia rpc with dynamically generated end points

Latest version **0.12.3** (published 2023-09-09) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install chia-daemon
pnpm add chia-daemon
yarn add chia-daemon
bun add chia-daemon
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.12.3 |
| Published | 2023-09-09 |
| First published | 2022-06-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 496.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | dkackman |
| Maintainers | dkackman |
| Keywords | chia, rpc, js, daemon |

## Links

- npm: https://www.npmjs.com/package/chia-daemon
- Repository: https://github.com/dkackman/chia-repl
- Homepage: https://github.com/dkackman/chia-repl/tree/main/packages/chia-daemon#readme
- Issues: https://github.com/dkackman/chia-repl/issues
- npm.io page: https://npm.io/package/chia-daemon

## Dependencies (5)

- [ws](https://npm.io/package/ws.md) ^8.8.0
- [axios](https://npm.io/package/axios.md) ^1.5.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [js-yaml](https://npm.io/package/js-yaml.md) ^4.1.0
- [chia-service-connector](https://npm.io/package/chia-service-connector.md) ^0.1.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.12.3 (latest) — 2023-09-09
- 0.3.0 (chia-1.4.0) — 2022-07-04
- 0.12.2 — 2023-09-07
- 0.12.1 — 2023-09-04
- 0.12.0 — 2023-09-04
- 0.11.5 — 2023-08-30
- 0.11.3 — 2023-08-30
- 0.11.2 — 2023-08-06
- 0.11.1 — 2023-06-30
- 0.11.0 — 2023-04-24
- 0.10.2 — 2023-02-17
- 0.10.1 — 2023-01-18
- 0.10.0 — 2022-11-09
- 0.8.0 — 2022-11-07
- 0.7.0 — 2022-11-05
- … 19 more at https://npm.io/package/chia-daemon/versions

## README

# chia-daemon

  <a href="https://www.npmjs.com/package/chia-daemon"><img src="https://img.shields.io/npm/v/chia-daemon.svg?sanitize=true" alt="Version"></a>
  <a href="https://www.npmjs.com/package/chia-daemon"><img src="https://img.shields.io/npm/l/chia-daemon.svg?sanitize=true" alt="Version"></a>
  <a href="https://www.npmjs.com/package/chia-daemon"><img src="https://img.shields.io/npm/dm/chia-daemon.svg?sanitize=true" alt="Monthly Downloads"></a>
  <a href="https://www.npmjs.com/package/chia-daemon"><img src="https://img.shields.io/npm/dt/chia-daemon.svg?sanitize=true" alt="Total Downloads"></a>

A JS client for chia daemon and https services with dynamically generated end points

## Getting Started

```bash
npm install
npm test
```

## Documentation

<https://dkackman.github.io/chia-daemon/>

## Basic Usage

Each service is a field on the `services` property of the `ChiaDaemon`.

- Since all service calls go through the daemon there is no need for other endpoint configuration
- All RPC calls are async
- Since all rpc call are dynamically invoked there is no need to update the library with new Chia releases.
(i.e. if you invoke `daemon.wallet.foo()` it will call make an RPC to a function named `foo` at that endpoint and error if it doesn't exist there)

```javascript
import { ChiaDaemon, loadUIConfig } from 'chia-daemon';

const daemon = new ChiaDaemon(loadUIConfig(), 'my-chia-app');
const connected = await daemon.connect();
if (connected) {
    const state = await daemon.services.full_node.get_blockchain_state();
    console.log(state);
}
```

Also supports `https` connections:

```javascript
import { createHttpsService, createConnection } from "chia-daemon";

const connection = createConnection(
    "wallet",
    "localhost",
);
const wallet = createHttpsService(connection);
const response = await wallet.get_wallets({ include_data: true });

console.log(`You have ${response.wallets.length} wallets`);
```

## Payload Helpers

Includes helper functions to get request payloads right:

### Get the OpenAPI responseBody Schema Descriptor

```javascript
console.log(daemon.services.full_node.getPayloadDescriptor('open_connection'));

{
  type: 'object',
  required: [ 'ip', 'port' ],
  properties: {
    ip: { type: 'string', format: 'ipaddress' },
    port: { type: 'integer' }
  }
}
```

### Get a Payload Object Instance

```javascript
const connection = daemon.services.full_node.makePayload('open_connection');
console.log(connection);

{ ip: '', port: 0 }

connection.ip = 'chia.net';
connection.port = 4444;

await daemon.services.full_node.open_connection(connection);
```

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