miden-node-proto-build

Crates.iomiden-node-proto-build
lib.rsmiden-node-proto-build
version0.11.0
created_at2025-03-27 01:12:52.435504+00
updated_at2025-08-29 06:28:55.291115+00
descriptionMiden node protobuf bindings builder
homepagehttps://miden.xyz
repositoryhttps://github.com/0xMiden/miden-node
max_upload_size
id1607391
size79,976
Bobbin Threadbare (bobbinth)

documentation

README

Miden proto build

This crate contains Protobuf files defining the Miden node gRPC API. The files are exposed via FileDescriptorSets to simplify generation of Rust bindings.

It also contains the raw Protobuf files in the proto directory to be used for binding generation in other languages.

Usage

To generate Miden node gRPC bindings in Rust, you'll need to add a build.rs file to your project. The example below generates the RPC component bindings and writes them into the src/generated directory of your project.

use std::{fs, path::PathBuf, env};
use miden_node_proto_build::rpc_api_descriptor;

fn main() {
    let crate_root: PathBuf = env::var("CARGO_MANIFEST_DIR").unwrap().into();
    let dst_dir = crate_root.join("src").join("generated");

    let _ = fs::remove_dir_all(&dst_dir);
    fs::create_dir(&dst_dir).unwrap();

    let file_descriptors = rpc_api_descriptor();

    let mut prost_config = prost_build::Config::new();
    prost_config.skip_debug(["AccountId", "Digest"]);

    tonic_build::configure()
        .out_dir(dst_dir)
        .build_server(false) // this setting generates only the client side of the rpc api
        .compile_fds_with_config(prost_config, file_descriptors)
        .context("compiling protobufs")?;
}

Enabling TLS for the RPC Client

To connect to the official RPC API, you need to enable TLS in your gRPC client. The easiest way to do this is by enabling the tls-native-roots feature in the tonic crate. This ensures that your client automatically uses system-native certificate roots without requiring additional configuration.

Crate features

  • internal: exposes Protobuf file descriptors for the internal components of the node. This is not intended for general use.

License

This project is MIT licensed.

Commit count: 776

cargo fmt