Skip to content

Sentriscloud/sentrix-grpc-wasm

Repository files navigation

sentrix-grpc-wasm

CI License: MIT

Rust + WASM gRPC-Web client for Sentrix Chain. Compiles to WASM via wasm-pack and is consumable from any browser dApp that wants typed gRPC-Web access to the chain's sentrix.v1.Sentrix service.

Extracted from sentrix-explorer-v2 so other browser apps can reuse the wrapper instead of re-implementing the tonic-web-wasm-client glue.

Picking the right SDK

Use case Crate / package
Browser dApp, Rust+WASM (Leptos, Yew, plain wasm-bindgen) this crate
Browser dApp, TypeScript @sentrix/chain/grpc-web (uses @protobuf-ts/grpcweb-transport)
Node.js service (Rust) sentrix-chain grpc feature
Node.js service (TypeScript) @sentrix/chain/grpc (uses @grpc/grpc-js)

All four hit the same grpc.sentrixchain.com:443 endpoint — Caddy at the edge transcodes between gRPC-Web and native gRPC via tonic-web.

Quick start

use sentrix_grpc_wasm::SentrixGrpcClient;

#[wasm_bindgen]
pub async fn read_tip() -> Result<String, JsError> {
    let mut client = SentrixGrpcClient::new("https://grpc.sentrixchain.com");
    let block = client.get_latest_block().await
        .map_err(|s| JsError::new(&format!("rpc: {s}")))?;
    Ok(format!("tip: {}", block.index))
}

Build to WASM:

wasm-pack build --target web --release

Then import the generated pkg/ from your bundler (Vite, webpack, etc).

Available calls (chain v0.4+)

Method Returns
get_latest_block() / get_block_by_height(h) pb::Block
get_balance(address) pb::Account (20-byte address)
get_validator_set() pb::ValidatorSet
get_supply() pb::Supply
get_mempool(limit) pb::Mempool
subscribe_events(filters) server-stream pb::ChainEvent

Older chain hosts (v0.2 / v0.3) return Status::unimplemented for the newer methods; the SDK forwards the error verbatim so callers can fall back to JSON-RPC / REST.

Endpoints

Network URL
Mainnet https://grpc.sentrixchain.com
Testnet https://grpc-testnet.sentrixchain.com

Roadmap

  • Extract from sentrix-explorer-v2/src/grpc/
  • Standalone crate with tonic-build codegen
  • CI: cargo build + cargo build --target wasm32-unknown-unknown
  • Smoke test: wasm-pack test --headless --chrome against staging endpoint
  • Published to crates.io (sentrix-grpc-wasm) — v0.1.0-alpha.0 since 2026-05-12
  • Optional: pre-built WASM artifact npm package (skip the local wasm-pack step for JS consumers)

Status

v0.1.0-alpha.0 on crates.io. Born as the gRPC-Web wrapper inside sentrix-explorer-v2; now extracted as a sibling crate that any browser dApp can pull as a thin client over sentrix-proto without re-implementing the tonic-web-wasm-client glue. (explorer-v2 itself depends on sentrix-proto directly, not on this crate — they're siblings, not parent/child.)

License

MIT — see LICENSE.

About

Rust + WASM gRPC-Web client for Sentrix Chain. Extracted from sentrix-explorer-v2; usable from any browser dApp via wasm-pack.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages