Registry / crypto / chia-agent

chia-agent

JSON →
library16.1.5jsnpmunverified

chia-agent is a comprehensive Node.js client library (v16.1.5) for interacting with Chia blockchain RPC and WebSocket APIs. It supports all RPC/WebSocket endpoints available in chia-blockchain 2.5.5, covering services like farmer, harvester, full_node, wallet, pool, data_layer, and crawler. The library is fully TypeScript with typed exports, requires Node.js >=20, and is actively maintained. Its key differentiators include seamless integration with both local daemon and direct RPC connections, complete API coverage, and event-driven WebSocket subscriptions for real-time farming/plotting data.

npm install chia-agent
INSTALL
IMPORT
SIG · CHIA-AGENT
C
chia-agent
cryptojavascriptv16.1.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RPCAgent
import { RPCAgent } from 'chia-agent'
import RPCAgent from 'chia-agent'
RPCAgent is a named export, not default.
getDaemon
import { getDaemon } from 'chia-agent'
const { getDaemon } = require('chia-agent')
Library is ESM-first; use import statements for TypeScript or ES modules. CommonJS require still works in Node.js.
get_plots
import { get_plots } from 'chia-agent/api/rpc'
import { get_plots } from 'chia-agent'
RPC API functions are subpath exports from 'chia-agent/api/rpc'; not available at top-level.
on_new_farming_info
import { on_new_farming_info } from 'chia-agent/api/ws'
import { on_new_farming_info } from 'chia-agent'
WebSocket event functions are subpath exports from 'chia-agent/api/ws'.

Creates an RPCAgent for the harvester service, fetches plot list, and logs the count. Demonstrates import of named exports from both main and subpath modules, agent instantiation, and async/await usage.

import { RPCAgent, setLogLevel } from 'chia-agent'; import { get_plots } from 'chia-agent/api/rpc'; setLogLevel('debug'); const agent = new RPCAgent({ service: 'harvester' }); (async () => { try { const res = await get_plots(agent); console.log('Plot count:', res.plots.length); } catch (err) { console.error('Error fetching plots:', err); } finally { agent.close(); } })();
Debug
Known issues
breakingRequires Node.js >=20.0.0
fix
Upgrade Node.js to version 20 or later.
affects: >=16.0.0
breakingVersion 16.x introduced breaking changes in RPC method signatures (e.g., arguments order changed)
fix
Check the changelog for specific method changes; update method calls accordingly.
affects: >=16.0.0 <16.0.0
deprecatedThe 'setLogLevel' function is deprecated; use environment variable LOG_LEVEL instead
fix
Set LOG_LEVEL env to 'debug', 'info', 'warn', or 'error' instead of calling setLogLevel.
affects: >=14.0.0
gotchaDo not reuse a single RPCAgent instance across multiple services; create a new agent per service type
fix
Instantiate separate RPCAgent objects for each service (e.g., farmer, wallet).
affects: >=1.0.0
Errors
Common errors & fixes
Error: connect ECONNREFUSED 127.0.0.1:8555
Chia daemon is not running or port is incorrect.
fix
Start the Chia daemon with 'chia start daemon' or check if it's already running.
TypeError: agent.get_plots is not a function
Misunderstanding of API: get_plots is imported separately, not a method on RPCAgent.
fix
Use import { get_plots } from 'chia-agent/api/rpc' and call get_plots(agent).
SyntaxError: Cannot use import statement outside a module
Using ES module import in a CommonJS file without 'type': 'module' in package.json.
fix
Add 'type': 'module' to your package.json or use require() instead.
Upgrade
Version history
16.1.5latest on npm
Audit
Dependencies
wsrequiredWebSocket client for daemon and RPC connections
debugoptionalInternal logging utility with log levels
Agent activity
28 hits · last 30 days
node
24
Amazon
1
Bingbot
1
Resources
chia-agent — npm install chia-agent · libregistry