{"id":17109130,"url":"https://github.com/dkackman/chia-service-connector","last_synced_at":"2026-02-16T02:32:44.636Z","repository":{"id":193299882,"uuid":"688525755","full_name":"dkackman/chia-service-connector","owner":"dkackman","description":"Package for managing connections to Chia RPC services","archived":false,"fork":false,"pushed_at":"2025-02-19T16:57:22.000Z","size":551,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T18:39:07.255Z","etag":null,"topics":["chia","chia-blockchain","rpc"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dkackman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2023-09-07T14:25:10.000Z","updated_at":"2023-09-08T01:02:15.000Z","dependencies_parsed_at":"2023-09-07T16:05:30.656Z","dependency_job_id":"93b3d831-97ea-419e-8902-518646091a16","html_url":"https://github.com/dkackman/chia-service-connector","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":"0.025000000000000022","last_synced_commit":"b454eeec8a408a6a195291febf40520dbec595c7"},"previous_names":["dkackman/chia-service-connector"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dkackman/chia-service-connector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkackman%2Fchia-service-connector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkackman%2Fchia-service-connector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkackman%2Fchia-service-connector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkackman%2Fchia-service-connector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dkackman","download_url":"https://codeload.github.com/dkackman/chia-service-connector/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkackman%2Fchia-service-connector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29498665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T02:07:14.481Z","status":"online","status_checked_at":"2026-02-16T02:03:22.852Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["chia","chia-blockchain","rpc"],"created_at":"2024-10-14T16:22:11.970Z","updated_at":"2026-02-16T02:32:44.620Z","avatar_url":"https://github.com/dkackman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chia-service-connector\n\n[![Node.js CI](https://github.com/dkackman/chia-service-connector/actions/workflows/node.js.yml/badge.svg)](https://github.com/dkackman/chia-service-connector/actions/workflows/node.js.yml)\n[![CodeQL](https://github.com/dkackman/chia-service-connector/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/dkackman/chia-service-connector/actions/workflows/github-code-scanning/codeql)\n\u003ca href=\"https://www.npmjs.com/package/chia-service-connector\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/chia-service-connector.svg?sanitize=true\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\ncoauthored with [@MichaelTaylor3d](https://github.com/MichaelTaylor3D)\n\n## Introduction\n\nPackage for managing connections to Chia RPC services. Intended to encapsulate finding CHIA_ROOT, implement environment chia conventions, and provide a simple interface for describing the\nconnection with the service. This simplifies finding the cert files, in a reusable manner, decoupled from aby specific communication library or pattern.\n\n## Examples\n\n`createChiaConnection` and `createChiaConnectionFromConfig` are the main entry points for the package. They return a `ChiaConnection` object that can be used with a `https` or `wss` library to make RPC calls to the service. Unless specified bt the caller, all methods respect the `CHIA_ROOT` environment variable or default to `~/.chia/mainnet`.\n\n### The simplest example\n\nThis creates a connection to the wallet service using the default connection parameters, `localhost` and `~/.chia/mainnet/`.\n\n```javascript\nconst connector = require('chia-service-connector');\n\nconst connection = connector.createChiaConnection(\"wallet\");\n\nconst configConnection = connector.createChiaConnectionFromConfig(\"wallet\");\n```\n\n### A slightly less simple example\n\nCreate a connection to the chia daemon on another machine, using the default `~/.chia/mainnet/` location for certs.\n\n```javascript\nconst connector = require('chia-service-connector');\n\nconst connection = connector.createChiaConnection(\"daemon\", \"192.168.1.155\");\n\nconst configConnection = connector.createChiaConnectionFromConfig(\"daemon\", \"~/path/to/some/config.yaml\");\n```\n\n### All of the arguments for createChiaConnection\n\n```javascript\nconst connector = require('chia-service-connector');\n\nconst connection = connector.createChiaConnection(\n    \"full_node\",             // service name \n    \"192.168.1.155\",         // host (name or ip)\n    connector.getChiaRoot(), // getChiaRoot will try to find the current CHIA_ROOT\n    60,                      // timeout in seconds\n    { \"full_node\": 8765 }    // map of service names to ports - defaults to the standard ports\n);\n```\n\n### Create the ChiaConnection object directly\n\nThe `ChiaConnection` object can be created directly, but it is recommended to use create methods instead since they accommodate the most environment and conventional values.\n\n```javascript\nconst connector = require('chia-service-connector');\n\nconst connection = new connector.ChiaConnection(\n    \"full_node\",             // service name \n    \"192.168.1.155\",         // host (name or ip)\n    9812,                    // port\n    \"~/.chia/mainnet/config/ssl/wallet/private_wallet.key\", // full path to the cert file \n    \"~/.chia/mainnet/config/ssl/wallet/private_wallet.crt\", // full path to the key file\n    60,                      // timeout in seconds\n);\n```\n\n### Members of the ChiaConnection object\n\n- `service` - the service name\n- `host` - the host name or ip address\n- `port` - the port number\n- `timeout_seconds` - the timeout in seconds for the connection\n- `cert_path` - the full path to the cert file\n- `key_path` - the full path to the key file\n- `cert` - the contents of the cert file as a `Buffer`\n- `key` - the contents of the key file as a `Buffer`\n- `serviceAddress` - the formatted address to the service, including protocol, host, and port\n- `createClientOptions()` - a function that returns an object that can be used with the `https` or `wss` libraries or `https agent`\n\n### Using the connection\n\nThe `ChiaConnection` keeps the details that can be used with your favorite `https` library.\n\n```javascript\nconst connector = require('chia-service-connector');\nconst https = require('https');\nconst axiosLib = require('axios');\nconst superagent = require('superagent');\n\nconst connection = connector.createChiaConnection(\"wallet\");\n\nconst axios = axiosLib.create({\n        baseURL: connection.serviceAddress,\n        timeout: connection.timeout_seconds * 1000,\n        headers: {\n            accepts: \"application/json\",\n            \"content-type\": \"application/json\",\n        },\n        httpsAgent: new https.Agent(\n            connection.createClientOptions()\n        ),\n    });\n\nconst response = await superagent\n    .post(`${connection.serviceAddress}/get_sync_status`)\n    .send({})\n    .timeout(timeout)\n    .agent(new https.Agent(connection.createClientOptions()));\n```\n\nOr web-sockets\n\n```javascript\nconst connector = require('chia-service-connector');\nconst ws = require(\"ws\");\n\nconst connection = connector.createChiaConnection(\"daemon\");\n\nconst socket = new ws.WebSocket(\n    connection.serviceAddress,\n    connection.createClientOptions()\n);\n```\n\nOr the [chia-daemon package](https://www.npmjs.com/package/chia-daemon)\n\n```javascript\nimport { createChiaConnection, createChiaConnectionFromConfig } from 'chia-service-connector';\nimport { ChiaDaemon, ChiaHttps } from 'chia-daemon';\n\nconst daemonConnection = createChiaConnection(\"daemon\");\nconst daemon = new ChiaDaemon(daemonConnection);\nawait demon.connect();\nconsole.log(await daemon.services.full_node.get_blockchain_state())\n\nconst walletConnection = createChiaConnectionFromConfig(\"wallet\");\nconst wallet = new ChiaHttps(walletConnection);\nconsole.log(await wallet.get_wallet_balance({ wallet_id: 1}))\n```\n\nOr whatever other chia library you like.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkackman%2Fchia-service-connector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdkackman%2Fchia-service-connector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkackman%2Fchia-service-connector/lists"}