{"id":27177644,"url":"https://github.com/chia-mine/chia-agent","last_synced_at":"2025-04-09T13:58:58.973Z","repository":{"id":37754134,"uuid":"366914662","full_name":"Chia-Mine/chia-agent","owner":"Chia-Mine","description":"chia rpc/websocket client library","archived":false,"fork":false,"pushed_at":"2025-02-23T14:24:11.000Z","size":1096,"stargazers_count":65,"open_issues_count":5,"forks_count":15,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-23T21:49:26.595Z","etag":null,"topics":["api","chia","library","nodejs","rpc","typescript","websocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chia-Mine.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-13T02:44:15.000Z","updated_at":"2025-02-23T14:24:14.000Z","dependencies_parsed_at":"2024-01-13T18:55:20.500Z","dependency_job_id":"0e8aa786-b41a-4cae-a3e9-5bac8ce35785","html_url":"https://github.com/Chia-Mine/chia-agent","commit_stats":{"total_commits":320,"total_committers":5,"mean_commits":64.0,"dds":"0.012499999999999956","last_synced_commit":"3b6bd6d6f583bec973dd9bc8b36bcaf55b66f526"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chia-Mine%2Fchia-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chia-Mine%2Fchia-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chia-Mine%2Fchia-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chia-Mine%2Fchia-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chia-Mine","download_url":"https://codeload.github.com/Chia-Mine/chia-agent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054218,"owners_count":21039951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","chia","library","nodejs","rpc","typescript","websocket"],"created_at":"2025-04-09T13:58:58.194Z","updated_at":"2025-04-09T13:58:58.954Z","avatar_url":"https://github.com/Chia-Mine.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chia-agent\n[![npm version](https://badge.fury.io/js/chia-agent.svg)](https://badge.fury.io/js/chia-agent) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nchia rpc/websocket client library for NodeJS.  \nSupports all RPC/Websocket API available at `2.5.1`/`2.5.2` of [`chia-blockchain`](https://github.com/Chia-Network/chia-blockchain/).  \n\\(If you need previous version, search for the corresponding release [here](https://github.com/Chia-Mine/chia-agent/releases)\\)\n\nyou can develop your own nodejs script with `chia-agent` to:\n- retrieve latest data from RPC servers like `farmer`, `harvester`, `full_node`, `wallet`, `pool`, `data_layer`, `crawler`.\n- send email when proof is found.\n- trigger scripts when target event is observed.\n- start/stop services.\n- write program to schedule plotting with javascript.\n- etc, etc, etc\n\n## Install\n```\nnpm install chia-agent\n# or\nyarn add chia-agent\n```\n\n## Compatibility\nThis code is compatible with:  \n- [`ddd5a0cbcb7a4ebb106ee4d27692b3118b6fdc4a`](https://github.com/Chia-Network/chia-blockchain/tree/ddd5a0cbcb7a4ebb106ee4d27692b3118b6fdc4a) of [chia-blockchain 2.5.2](https://github.com/Chia-Network/chia-blockchain)  \n  - [Diff to the main branch of chia-blockchain](https://github.com/Chia-Network/chia-blockchain/compare/ddd5a0cbcb7a4ebb106ee4d27692b3118b6fdc4a...main)\n- [`ac72355b9220fa975bab857fe740892845017a30`](https://github.com/Chia-Network/pool-reference/tree/ac72355b9220fa975bab857fe740892845017a30) of [pool-reference](https://github.com/Chia-Network/pool-reference)  \n  - [Diff to the main branch of pool-reference](https://github.com/Chia-Network/pool-reference/compare/ac72355b9220fa975bab857fe740892845017a30...main)\n- [`0b6571ea254fe22dfc692f9ef058b6a4e224a081`](https://github.com/Chia-Network/chia_rs/tree/0b6571ea254fe22dfc692f9ef058b6a4e224a081) of [chia_rs 0.18.0](https://github.com/Chia-Network/chia_rs)\n  - [Diff to the main branch of chia_rs](https://github.com/Chia-Network/chia_rs/compare/0b6571ea254fe22dfc692f9ef058b6a4e224a081...main)\n\n## API\nThere are 2 kinds of APIs in chia.  \n`RPC API` and `Websocket API`.\n\n### RPC API\nRPC API is used to send message directly to chia services like `farmer`, `harvester`, `full_node`, `wallet`, `data_layer`, `crawler`.\n\nRPC API is just an async function in a traditional request/response style.\n\n```js\nconst {RPCAgent, setLogLevel} = require(\"chia-agent\");\nconst {get_plots} = require(\"chia-agent/api/rpc\");\nsetLogLevel(\"debug\");\n\nconst agent = new RPCAgent({\n  service: \"harvester\",\n});\n\nconst res = await get_plots(agent);\nconsole.log(res.plots[0]);\n\n/*\n// sample output\n{\n  file_size: 108875876912,\n  filename: 'M:\\\\plot-k32-yyyy-mm-dd-xx-xx-xxxxxxxxxxxxxxxxxxxxxxxxx.plot',\n  plot_id: '...',\n  plot_public_key: '0x934a93489...',\n  pool_contract_puzzle_hash: null,\n  pool_public_key: '0xb0aa9485c0d...',\n  size: 32,\n  time_modified: 1619540745\n}\n*/\n\n// Or you can request RPC API via daemon websocket like this\nconst {getDaemon, setLogLevel} = require(\"chia-agent\");\nconst {get_plots} = require(\"chia-agent/api/rpc\");\nconst daemon = getDaemon();\nawait daemon.connect(); // connect to local daemon using config file.\nconst res = await get_plots(daemon);\n```\n\n### Websocket API\nWebsocket API is used to connect to chia `daemon`.\n\nWith websocket API, you can request chia daemon to start/stop plotting or other services,  \nor capture various broadcast messages like:\n- Plotting progress\n- Farming info such as passed filter, proofs found, etc.\n\n```js\nconst {getDaemon, setLogLevel} = require(\"chia-agent\");\nconst {on_new_farming_info} = require(\"chia-agent/api/ws\");\n\nsetLogLevel(\"debug\");\n\nconst daemon = getDaemon();\nawait daemon.connect(); // connect to local daemon using config file.\nconst unsubscribe = await on_new_farming_info(daemon, (e) =\u003e {\n  console.log(e.data);\n})\n\nsetTimeout(async () =\u003e {\n  unsubscribe(); // Stop capturing message\n  daemon.close();\n}, 30*1000); // Disconnect after 30s passed.\n\n/*\n// sample output\n{\n  farming_info: {\n    challenge_hash: '0x07228cf04e8877797adc1e0605018007def282548f009564b00286886e23e88b',\n    passed_filter: 0,\n    proofs: 0,\n    signage_point: '0xfe1272a8e6659c0a3875cac37f8b170f1f85d47fecfee36d825dfae0b2a73a31',\n    timestamp: 1621255822,\n    total_plots: 299\n  },\n  success: true\n}\n */\n```\n\n## API Reference\n[See Documentation here](https://github.com/Chia-Mine/chia-agent/blob/main/src/api/README.md)\n\n## Examples\n[See documentation here](https://github.com/Chia-Mine/chia-agent/blob/main/example)\n\nHere are some of those examples\n- [Send email when proof is found](https://github.com/Chia-Mine/chia-agent/blob/main/example/send_email_when_proof_is_found)\n- [RPC API code sample to show block record in certain height](https://github.com/Chia-Mine/chia-agent/blob/main/example/get_block_by_height)\n- [Create multiple plots with javascript](https://github.com/Chia-Mine/chia-agent/blob/main/example/create_plots)\n\n## Build from source\nOnce source files is build by `npm run build:prod`, files will be output to `/dist` directory.  \nThen the files/directories are published to npm registry.  \nPlease note it does not upload files in project root to npm registry, but files inside '/dist'.\n\n[Read details here](https://github.com/Chia-Mine/chia-agent/blob/main/BUILD.md)\n\n## Donation\nFor continuous development, please support me with donation\n`xch1wr8g2k7cn55xvepmg480dsu2xhf4rz5ezghwwapulj7jxqcz9ztqqclwdj`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchia-mine%2Fchia-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchia-mine%2Fchia-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchia-mine%2Fchia-agent/lists"}