npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chia-agent

v14.4.0

Published

chia rpc/websocket client library

Downloads

3,733

Readme

chia-agent

npm version License: MIT

chia rpc/websocket client library for NodeJS.
Supports all RPC/Websocket API available at 2.4.4 of chia-blockchain.
(If you need previous version, search for the corresponding release here)

you can develop your own nodejs script with chia-agent to:

  • retrieve latest data from RPC servers like farmer, harvester, full_node, wallet, pool, data_layer, crawler.
  • send email when proof is found.
  • trigger scripts when target event is observed.
  • start/stop services.
  • write program to schedule plotting with javascript.
  • etc, etc, etc

Install

npm install chia-agent
# or
yarn add chia-agent

Compatibility

This code is compatible with:

API

There are 2 kinds of APIs in chia.
RPC API and Websocket API.

RPC API

RPC API is used to send message directly to chia services like farmer, harvester, full_node, wallet, data_layer, crawler.

RPC API is just an async function in a traditional request/response style.

const {RPCAgent, setLogLevel} = require("chia-agent");
const {get_plots} = require("chia-agent/api/rpc");
setLogLevel("debug");

const agent = new RPCAgent({
  service: "harvester",
});

const res = await get_plots(agent);
console.log(res.plots[0]);

/*
// sample output
{
  file_size: 108875876912,
  filename: 'M:\\plot-k32-yyyy-mm-dd-xx-xx-xxxxxxxxxxxxxxxxxxxxxxxxx.plot',
  plot_id: '...',
  plot_public_key: '0x934a93489...',
  pool_contract_puzzle_hash: null,
  pool_public_key: '0xb0aa9485c0d...',
  size: 32,
  time_modified: 1619540745
}
*/

// Or you can request RPC API via daemon websocket like this
const {getDaemon, setLogLevel} = require("chia-agent");
const {get_plots} = require("chia-agent/api/rpc");
const daemon = getDaemon();
await daemon.connect(); // connect to local daemon using config file.
const res = await get_plots(daemon);

Websocket API

Websocket API is used to connect to chia daemon.

With websocket API, you can request chia daemon to start/stop plotting or other services,
or capture various broadcast messages like:

  • Plotting progress
  • Farming info such as passed filter, proofs found, etc.
const {getDaemon, setLogLevel} = require("chia-agent");
const {on_new_farming_info} = require("chia-agent/api/ws");

setLogLevel("debug");

const daemon = getDaemon();
await daemon.connect(); // connect to local daemon using config file.
const unsubscribe = await on_new_farming_info(daemon, (e) => {
  console.log(e.data);
})

setTimeout(async () => {
  unsubscribe(); // Stop capturing message
  daemon.close();
}, 30*1000); // Disconnect after 30s passed.

/*
// sample output
{
  farming_info: {
    challenge_hash: '0x07228cf04e8877797adc1e0605018007def282548f009564b00286886e23e88b',
    passed_filter: 0,
    proofs: 0,
    signage_point: '0xfe1272a8e6659c0a3875cac37f8b170f1f85d47fecfee36d825dfae0b2a73a31',
    timestamp: 1621255822,
    total_plots: 299
  },
  success: true
}
 */

API Reference

See Documentation here

Examples

See documentation here

Here are some of those examples

Build from source

Once source files is build by npm run build:prod, files will be output to /dist directory.
Then the files/directories are published to npm registry.
Please note it does not upload files in project root to npm registry, but files inside '/dist'.

Read details here

Donation

For continuous development, please support me with donation xch1wr8g2k7cn55xvepmg480dsu2xhf4rz5ezghwwapulj7jxqcz9ztqqclwdj