Building a Zig foothold in the Zcash ecosystem - talking to Zebra over JSON-RPC

After shipping a pure-Zig address library, the next natural step for me was tooling that talks to a live node. zebra-utils.zig is a Zig toolkit for calling a running Zebra instance over its JSON-RPC interface.

https://github.com/gorusys/zebra-utils.zig

The core is a small library (JSON helpers, RPC client, typed responses, config) plus zebra-cli: a general-purpose CLI for the sorts of calls you use when operating or debugging a node - chain info, tip, blocks, transactions, mempool, peers, network, treestate, ping and sendrawtransaction. Output can be table, JSON, or compact, with optional color and ~/.config/zebra-utils/config.toml defaults. Builds target Zig 0.14.x; binaries are linked without libc, same philosophy as the address work.

Tests use fixtures and mock HTTP under src/rpc/, so zig build test does not require a daemon. Point --node at Zebra when you want to exercise it for real.

Next Steps:
Planned binaries include zebra-watch, zebra-rpc-diff, zebra-scan, and zebra-checkpoint.

If you run Zebra in production or hack on light clients, I’d especially like feedback on which RPC surfaces matter most for CLI tooling.

3 Likes

Developer tooling in more languages matters. If someone knows Zig, they should be able to talk to Zebra without switching stacks.

Static binaries with zero system dependencies are great for production ops. Curious what pulled you toward Zig specifically over Go or Nim for this.

To briefly summarize it once again, following my earlier post on bringing Zig into the Zcash ecosystem (starting with zcash-addr.zig):I chose Zig mainly for its ability to produce static, dependency-free binaries, strong C interop, and suitability for constrained environments like hardware wallets. Its native WASM support and smaller output sizes also make it appealing for browser-based tooling.The goal isn’t to replace the existing Rust/C++ stack, but to complement it with an independent implementation for broader accessibility and cross-language verification. And there is also a purpose in learning and utilizing Zig right now. :grinning_face_with_smiling_eyes:

1 Like

You zig, I zag. Neat and cool to see :+1:

Haha, zig or zag, both get we somewhere :smile: Curious what direction you’ve been exploring lately?

1 Like

Bash → RUST with the help of grok. One of my pet peeves was having to learn new languages every 4 years but AI is helping fix that problem.

Here is some of the RPC work I use everyday for my gm twitter posts :smiley:

1 Like

zebra-watch implemented - terminal dashboard for Zebra RPC

What it does

zebra-watch is a small terminal dashboard that polls your node on a timer and redraws the screen. It shows:

  • Chain: network name, height, headers, verification progress (“sync %”), truncated best block hash

  • Mempool: transaction count and size in bytes

  • Peers: getpeerinfo count, P2P connections from getnetworkinfo, and subversion

If the RPC is unreachable, it shows “RPC unavailable. Retrying…” and keeps trying on the next interval instead of exiting immediately.

How to run

Build as usual (zig build / zig build -Doptimize=ReleaseSafe), then:

./zig-out/bin/zebra-watch --help

Useful flags (same spirit as zebra-cli):

  • --node host:port — default 127.0.0.1:8232 or from ~/.config/zebra-utils/config.toml

  • --user user:pass — HTTP Basic auth (e.g. Zebra RPC cookie)

  • --interval <secs> — refresh period (default 5 seconds)

  • --color / --no-color

Stop with Ctrl+C.