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.
node

Structs§

AcceptHeaderContext
Extra context attached to Accept header negotiation failures.
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.
RpcLimits
Domain type representing RPC endpoint limits.
RpcStatusInfo
Represents node status info with fields converted into domain types.

Enums§

AcceptHeaderError
Errors that can occur during accept header validation.
AccountStateAt
Represents the state that we want to retrieve from the network
EndpointError
Application-level error returned by the node for a specific RPC endpoint.
GrpcError
Categorizes gRPC errors based on their status codes and common patterns
RpcConversionError
RpcEndpoint
RPC methods for the Miden protocol.
RpcError

Traits§

NodeRpcClient
Defines the interface for communicating with the Miden node.