Registry / blockchain / grpc-bchrpc-node

grpc-bchrpc-node

JSON →
library0.15.2jsnpmunverified

A gRPC client for connecting to BCHD, a Bitcoin Cash full node implementation. Version 0.15.2 provides a JavaScript/TypeScript interface to BCHD's gRPC API, supporting transaction queries, blockchain data retrieval, and SLP token metadata (when node has SLP index enabled). This is a lean wrapper over gRPC, with minimal overhead compared to REST APIs. It supports both Node.js and browser (via grpc-bchrpc-web). The library is maintained by SimpleLedger and has a moderate release cadence, with updates tied to BCHD protocol changes.

npm install grpc-bchrpc-node
INSTALL
IMPORT
SIG · GRPC-BCHRPC-NODE
G
grpc-bchrpc-node
blockchainjavascriptv0.15.2
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.

GrpcClient
import { GrpcClient } from 'grpc-bchrpc-node'
const GrpcClient = require('grpc-bchrpc-node')
Default export is a named export; ESM-only since v0.15. Use named import.
GetRawTransactionRequest
import { GetRawTransactionRequest } from 'grpc-bchrpc-node'
import GetRawTransactionRequest from 'grpc-bchrpc-node'
Type interfaces are also named exports. Default import is undefined.
GrpcClientOptions
import type { GrpcClientOptions } from 'grpc-bchrpc-node'
import { GrpcClientOptions } from 'grpc-bchrpc-node'
TypeScript users: use 'import type' for interface types to avoid runtime overhead.

Creates a gRPC client connecting to a public BCHD instance, fetches blockchain info, and prints height and user agent.

import { GrpcClient } from 'grpc-bchrpc-node'; async function main() { const client = new GrpcClient({ url: process.env.BCHD_URL ?? 'bchd.greyh.at:8335', rootCertPath: process.env.BCHD_CERT_PATH ?? undefined }); try { const info = await client.getBlockchainInfo(); console.log('Block height:', info.getBestHeight()); console.log('Chain:', info.getBchd().getUseragent()); } catch (err) { console.error('Error:', err.message); } finally { client.close(); } } main();
Debug
Known issues
breakingAs of v0.15.0, the package is ESM-only. CommonJS require() will fail with ERR_REQUIRE_ESM.
fix
Use import statements or dynamic import() in CommonJS files.
affects: >=0.15.0
deprecatedConstructor option `rootCertPath` is deprecated in favor of `sslCredentials`.
fix
Use `sslCredentials: grpc.credentials.createSsl()` or pass a valid cert path via `rootCertPath` until further notice.
affects: >=0.14.0
gotchaAll transaction hashes must be passed with `reversedHashOrder: true` to match BCHD's byte order (little-endian).
fix
Always include `reversedHashOrder: true` in request objects for methods like `getRawTransaction`, `getTransaction`, or `getMerkleProof`.
affects: >=0.1.0
gotchaSLP token methods (e.g., `getSlpTransaction`) will throw an error if the connected BCHD node does not have SLP index enabled.
fix
Check node capabilities via `getBlockchainInfo` and verify SLP index is active before calling SLP-specific RPCs.
affects: >=0.10.0
Errors
Common errors & fixes
TypeError: grpc_bchrpc_node_1.default is not a function
Using default import instead of named import for GrpcClient.
fix
Replace `import GrpcClient from 'grpc-bchrpc-node'` with `import { GrpcClient } from 'grpc-bchrpc-node'`.
Error: 12 UNIMPLEMENTED: The service is not implemented
Attempting to call an RPC method that is not supported by the connected BCHD version.
fix
Verify BCHD version supports the method. For example, SLP methods require BCHD with SLP index enabled.
Error: Cannot find module '@grpc/grpc-js'
Missing peer dependency @grpc/grpc-js.
fix
Run `npm install @grpc/grpc-js` alongside grpc-bchrpc-node.
Error: 13 INTERNAL: Failed to parse server response
Proto file mismatch between client and server, often due to using an outdated version of grpc-bchrpc-node.
fix
Update grpc-bchrpc-node to the latest version and ensure BCHD is up to date.
Upgrade
Version history
0.15.2latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredCore gRPC implementation for Node.js
@grpc/proto-loaderrequiredLoads .proto files for gRPC service definition
google-protobufrequiredProtobuf runtime for generated message classes
Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
1
Resources
grpc-bchrpc-node — npm install grpc-bchrpc-node · libregistry