0.12.3 • Published 8 months ago

chia-daemon v0.12.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

chia-daemon

A JS client for chia daemon and https services with dynamically generated end points

Getting Started

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)
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:

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

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

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);
0.12.0

8 months ago

0.12.1

8 months ago

0.11.2

9 months ago

0.12.2

8 months ago

0.11.3

9 months ago

0.12.3

8 months ago

0.11.5

9 months ago

0.11.1

11 months ago

0.11.0

1 year ago

0.10.2

1 year ago

0.10.1

1 year ago

0.10.0

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.3.2

2 years ago

0.2.3

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.2.2

2 years ago

0.3.4

2 years ago

0.2.5

2 years ago

0.3.3

2 years ago

0.2.4

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago