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.0fixUpgrade 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)fixCheck 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 insteadfixSet 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 typefixInstantiate 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.
fixStart 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.
fixUse 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.
fixAdd 'type': 'module' to your package.json or use require() instead.
Audit
Dependencies
wsrequiredWebSocket client for daemon and RPC connections
debugoptionalInternal logging utility with log levels