chia-daemon

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

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
chia-daemon
1610.6.010 days ago4 months agoMinified + gzip package size for chia-daemon in KB

Readme

chia-daemon
Version Version Monthly Downloads Total Downloads A JS client for chia daemon with dynamically generated end points

Getting Started

```bash npm install npm test ```

Documention

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 dyanmically invoked there is no need to update the library with new chia release.
(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);
} ```

Payload Helpers

Includes helper functions to get request payloads right:

Get the OpenAPI responseBody Schema Descriptor

```javascript console.log(daemon.fullnode.getPayloadDescriptor('openconnection')); { type: 'object', required: 'ip', 'port' , properties: {
ip: { type: 'string', format: 'ipaddress' },
port: { type: 'integer' }
} } ```

Get a Payload Object Instance

```javascript const connection = daemon.fullnode.makePayload('openconnection'); console.log(payload); { ip: '', port: 0 } connection.ip = 'chia.net'; connection.port = 4444; await daemon.fullnode.openconnection(connection); ```