Registry / blockchain / grpc-bchrpc-web

grpc-bchrpc-web

JSON →
library0.15.1jsnpmunverified

A gRPC client library for connecting to BCHD full nodes from web browsers and Node.js. Version 0.15.1 is the latest stable release, with regular updates. It provides access to BCHD's gRPC API including transaction queries, block subscription, and SLP token support when the node has SLP indexing enabled. Key differentiators: designed specifically for BCHD, supports browser via unpkg, includes automatic txid endianness reversal, and offers both web and Node.js transports.

npm install grpc-bchrpc-web
INSTALL
IMPORT
SIG · GRPC-BCHRPC-WEB
G
grpc-bchrpc-web
blockchainjavascriptv0.15.1
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-web'
import GrpcClient from 'grpc-bchrpc-web'
GrpcClient is a named export, not default.
grpc
import { grpc } from 'grpc-bchrpc-web'
var grpc = require('grpc-bchrpc-web').grpc
grpc is the namespace for gRPC utilities.
NodeHttpTransport
import { NodeHttpTransport } from 'grpc-bchrpc-web'
import { NodeHttpTransport } from 'grpc-bchrpc-web/src/transports'
NodeHttpTransport is re-exported from the main package.

Shows how to instantiate GrpcClient, set Node.js transport, and fetch a raw transaction with reversed hash order.

import { GrpcClient, grpc, NodeHttpTransport } from 'grpc-bchrpc-web'; // For Node.js, set transport if (typeof window === 'undefined') { grpc.setDefaultTransport(NodeHttpTransport()); } async function main() { const client = new GrpcClient({ url: 'https://bchd.greyh.at:8335' }); const txid = '11556da6ee3cb1d14727b3a8f4b37093b6fecd2bc7d577a02b4e98b7be58a7e8'; try { const res = await client.getRawTransaction({ hash: txid, reversedHashOrder: true }); console.log(Buffer.from(res.getTransaction_asU8()).toString('hex')); } catch (err) { console.error(err); } } main();
Debug
Known issues
breakingIn version 0.11.0, the parameter 'reverseHash' was replaced with 'reversedHashOrder'. Code using 'reverseHash' will break.
fix
Replace 'reverseHash' with 'reversedHashOrder' in all method calls.
affects: <0.11.0
gotchaThe parameter 'skipSlpValidityChecks' must be set to true when submitting transactions to a BCHD node without SLP indexing enabled, otherwise SubmitTransaction will reject valid non-SLP transactions.
fix
Add { skipSlpValidityChecks: true } to SubmitTransaction options if the node does not have SLP indexing.
affects: >=0.11.0
gotchaFor Node.js, you must import and call grpc.setDefaultTransport(NodeHttpTransport()) before creating a client. Otherwise, transport will be undefined.
fix
Add the transport setup line at the top of your Node.js script.
affects: >=0.10.4
deprecatedThe global script tag from unpkg (bchrpc) may expose functionality differently than the npm module. Use npm imports for consistency.
fix
Use npm package instead of unpkg for non-trivial applications.
affects: >=0.10.5
gotchaTypeScript compilation requires DOM library in tsconfig.json because gRPC-web uses browser types.
fix
Add "DOM" to "lib" array in tsconfig.json.
affects: >=0.10.1
Errors
Common errors & fixes
Error: No transport found
NodeHttpTransport not set before creating GrpcClient
fix
Call grpc.setDefaultTransport(NodeHttpTransport()) before instantiating GrpcClient.
Error: Cannot find module 'grpc-bchrpc-web'
Package not installed or import path incorrect
fix
Run 'npm install grpc-bchrpc-web' and ensure import path is correct.
TypeError: client.getRawTransaction is not a function
Old version (<0.10.3) that does not have getRawTransaction method
fix
Update to version 0.10.3 or later: 'npm install grpc-bchrpc-web@latest'.
Upgrade
Version history
0.15.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
43 hits · last 30 days
node
38
OpenAI (training)
2
Resources
grpc-bchrpc-web — npm install grpc-bchrpc-web · libregistry