Skip to main content

Module rpc

Module rpc 

Source
Expand description

Re-export the entire miden_client crate so external projects can use a single dependency. Provides an interface for the client to communicate with a Miden node using Remote Procedure Calls (RPC).

This module defines the NodeRpcClient trait which abstracts calls to the RPC protocol used to:

  • Submit proven transactions.
  • Retrieve block headers (optionally with MMR proofs).
  • Sync state updates (including notes, nullifiers, and account updates).
  • Fetch details for specific notes and accounts.

The client implementation adapts to the target environment automatically:

  • Native targets use tonic transport with TLS.
  • wasm32 targets use tonic-web-wasm-client transport.

§Example

// Create a gRPC client instance (assumes default endpoint configuration).
let endpoint = Endpoint::new("https".into(), "localhost".into(), Some(57291));
let mut rpc_client = GrpcClient::new(&endpoint, 1000);

// Fetch the latest block header (by passing None).
let (block_header, mmr_proof) = rpc_client.get_block_header_by_number(None, true).await?;

println!("Latest block number: {}", block_header.block_num());
if let Some(proof) = mmr_proof {
    println!("MMR proof received accordingly");
}

The client also makes use of this component in order to communicate with the node.

For further details and examples, see the documentation for the individual methods in the NodeRpcClient trait.

Modules§

domain
Contains domain types related to RPC requests and responses, as well as utility functions for dealing with them.

Structs§

Endpoint
The Endpoint struct represents a network endpoint, consisting of a protocol, a host, and a port.
GrpcClient
Client for the Node RPC API using gRPC.

Enums§

AcceptHeaderError
Errors that can occur during accept header validation.
AccountStateAt
Represents the state that we want to retrieve from the network
GrpcError
Categorizes gRPC errors based on their status codes and common patterns
NodeRpcClientEndpoint
RPC methods for the Miden protocol.
RpcConversionError
RpcError

Constants§

ACCOUNT_ID_LIMIT
NOTE_IDS_LIMIT
NOTE_TAG_LIMIT
NULLIFIER_PREFIXES_LIMIT

Traits§

NodeRpcClient
Defines the interface for communicating with the Miden node.