Expand description
A no_std-compatible client library for interacting with the Miden network.
This crate provides a lightweight client that handles connections to the Miden node, manages accounts and their state, and facilitates executing, proving, and submitting transactions.
For a protocol-level overview and guides for getting started, please visit the official Miden docs.
§Overview
The library is organized into several key modules:
-
Accounts: Provides types for managing accounts. Once accounts are tracked by the client, their state is updated with every transaction and validated during each sync.
-
Notes: Contains types and utilities for working with notes in the Miden client.
-
RPC: Facilitates communication with Miden node, exposing RPC methods for syncing state, fetching block headers, and submitting transactions.
-
Store: Defines and implements the persistence layer for accounts, transactions, notes, and other entities.
-
Sync: Provides functionality to synchronize the local state with the current state on the Miden network.
-
Transactions: Offers capabilities to build, execute, prove, and submit transactions.
Additionally, the crate re-exports several utility modules:
- Assembly: Types for working with Miden Assembly.
- Assets: Types and utilities for working with assets.
- Auth: Authentication-related types and functionalities.
- Blocks: Types for handling block headers.
- Crypto: Cryptographic types and utilities, including random number generators.
- Utils: Miscellaneous utilities for serialization and common operations.
The library is designed to work in both no_std and std environments and is
configurable via Cargo features.
§Usage
To use the Miden client library in your project, add it as a dependency in your Cargo.toml:
[dependencies]
miden-client = "0.10"§Example
Below is a brief example illustrating how to instantiate the client using ClientBuilder:
use std::sync::Arc;
use miden_client::DebugMode;
use miden_client::builder::ClientBuilder;
use miden_client::keystore::FilesystemKeyStore;
use miden_client::rpc::{Endpoint, GrpcClient};
use miden_client_sqlite_store::SqliteStore;
// Create the SQLite store.
let sqlite_store = SqliteStore::new("path/to/store".try_into()?).await?;
let store = Arc::new(sqlite_store);
// Create the keystore for transaction signing.
let keystore = FilesystemKeyStore::new("path/to/keys/directory".try_into()?)?;
// Create the RPC client.
let endpoint = Endpoint::new("https".into(), "localhost".into(), Some(57291));
// Instantiate the client using the builder.
let client = ClientBuilder::new()
.rpc(Arc::new(GrpcClient::new(&endpoint, 10_000)))
.store(store)
.authenticator(Arc::new(keystore))
.in_debug_mode(DebugMode::Disabled)
.build()
.await?;
For network-specific defaults, use the convenience constructors:
// For testnet (includes remote prover and note transport)
let client = ClientBuilder::for_testnet()
.store(store)
.authenticator(Arc::new(keystore))
.build()
.await?;
// For local development
let client = ClientBuilder::for_localhost()
.store(store)
.authenticator(Arc::new(keystore))
.build()
.await?;For additional usage details, configuration options, and examples, consult the documentation for each module.
Re-exports§
pub use errors::*;
Modules§
- account
- The
accountmodule provides types and client APIs for managing accounts within the Miden network. - address
- Provides types for working with addresses within the Miden network.
- assembly
- Provides types and utilities for working with Miden Assembly.
- asset
- Provides types and utilities for working with assets within the Miden network.
- auth
- Provides authentication-related types and functionalities for the Miden network.
- block
- Provides types for working with blocks within the Miden network.
- builder
- crypto
- Provides cryptographic types and utilities used within the Miden rollup
network. It re-exports commonly used types and random number generators like
FeltRngfrom themiden_standardscrate. - errors
- grpc_
support - keystore
- note
- Contains the Client APIs related to notes. Notes can contain assets and scripts that are executed as part of transactions.
- note_
transport - notes
- rpc
- Provides an interface for the client to communicate with a Miden node using Remote Procedure Calls (RPC).
- settings
- The
settingsmodule provides methods for managing arbitrary setting values that are persisted in the client’s store. - store
- Defines the storage interfaces used by the Miden client.
- sync
- Provides the client APIs for synchronizing the client’s local state with the Miden network. It ensures that the client maintains a valid, up-to-date view of the chain.
- testing
testing - Provides test utilities for working with accounts and account IDs
within the Miden network. This module is only available when the
testingfeature is enabled. - transaction
- Provides APIs for creating, executing, proving, and submitting transactions to the Miden network.
- utils
- Provides various utilities that are commonly used throughout the Miden client library.
- vm
- Provides types for working with the virtual machine within the Miden network.
Structs§
- Client
- A light client for connecting to the Miden network.
- Client
Rng - A wrapper around a
FeltRngthat implements theRngCoretrait. This allows the user to pass their own generic RNG so that it’s used by the client. - Execution
Options - A set of parameters specifying execution parameters of the VM.
- Felt
- A
Feltbacked by Plonky3’s Goldilocks field element. - Remote
Transaction Prover - A
RemoteTransactionProveris a transaction prover that sends witness data to a remote gRPC server and receives a proven transaction. - Slice
Reader - Implements ByteReader trait for a slice of bytes.
- Word
- A unit of data consisting of 4 field elements.
Enums§
- Debug
Mode - Indicates whether the client is operating in debug mode.
Constants§
- EMPTY_
WORD - Array of field elements representing word of ZEROs in the Miden base field.
- MAX_
TX_ EXECUTION_ CYCLES - The maximum number of VM cycles a transaction is allowed to take.
- MIN_
TX_ EXECUTION_ CYCLES - The minimum number of VM cycles a transaction needs to execute.
- ONE
- Field element representing ONE in the Miden base filed.
- ZERO
- Field element representing ZERO in the Miden base filed.
Traits§
- Client
Felt Rng - Marker trait for RNGs that can be shared across threads and used by the client.
- Deserializable
- Defines how to deserialize
Selffrom bytes. - Pretty
Print - The PrettyPrint trait is used as a building block for pretty printing data or syntax trees, as commonly seen in tools like Prettier.
- Serializable
- Defines how to serialize
Selfinto bytes.
Type Aliases§
- Client
RngBox - Boxed RNG trait object used by the client.