Expand description
Re-export the entire miden_client crate so external projects can use a single dependency.
Provides APIs for creating, executing, proving, and submitting transactions to the Miden
network.
§Overview
This module enables clients to:
- Build transaction requests using the
TransactionRequestBuilder.TransactionRequestBuildercontains simple builders for standard transaction types, such asp2id(pay-to-id)
- Execute transactions via the local transaction executor and generate a
TransactionResultthat includes execution details and relevant notes for state tracking. - Prove transactions (locally or remotely) using a
TransactionProverand submit the proven transactions to the network. - Track and update the state of transactions, including their status (e.g.,
Pending,Committed, orDiscarded).
§Example
The following example demonstrates how to create and submit a transaction:
use miden_client::Client;
use miden_client::auth::TransactionAuthenticator;
use miden_client::crypto::FeltRng;
use miden_client::transaction::{PaymentNoteDescription, TransactionRequestBuilder};
use miden_protocol::account::AccountId;
use miden_protocol::asset::FungibleAsset;
use miden_protocol::note::NoteType;
/// Executes, proves and submits a P2ID transaction.
///
/// This transaction is executed by `sender_id`, and creates an output note
/// containing 100 tokens of `faucet_id`'s fungible asset.
async fn create_and_submit_transaction<
R: rand::Rng,
AUTH: TransactionAuthenticator + Sync + 'static,
>(
client: &mut Client<AUTH>,
sender_id: AccountId,
target_id: AccountId,
faucet_id: AccountId,
) -> Result<(), Box<dyn Error>> {
// Create an asset representing the amount to be transferred.
let asset = FungibleAsset::new(faucet_id, 100)?;
// Build a transaction request for a pay-to-id transaction.
let tx_request = TransactionRequestBuilder::new().build_pay_to_id(
PaymentNoteDescription::new(vec![asset.into()], sender_id, target_id),
NoteType::Private,
client.rng(),
)?;
// Execute, prove, and submit the transaction in a single call.
let _tx_id = client.submit_new_transaction(sender_id, tx_request).await?;
Ok(())
}For more detailed information about each function and error type, refer to the specific API documentation.
Structs§
- Account
Interface - An
AccountInterfacedescribes the exported, callable procedures of an account. - Advice
Inputs - Inputs container to initialize advice provider for the execution of Miden VM programs.
- Advice
Map - Defines a set of non-deterministic (advice) inputs which the VM can access by their keys.
- Executed
Transaction - Describes the result of executing a transaction program for the Miden protocol.
- Input
Notes - Input notes for a transaction, empty if the transaction does not consume notes.
- Local
Transaction Prover - Local Transaction prover is a stateless component which is responsible for proving transactions.
- Output
Notes - Contains a list of output notes of a transaction. The list can be empty if the transaction does not produce any notes.
- Payment
Note Description - Contains information needed to create a payment note.
- Proven
Transaction - Result of executing and proving a transaction. Contains all the data required to verify that a transaction was executed correctly.
- Proving
Options - A set of parameters specifying how Miden VM execution proofs are to be generated.
- Swap
Transaction Data - Contains information related to a swap transaction.
- Transaction
Args - Optional transaction arguments.
- Transaction
Details - Describes the details associated with a transaction.
- Transaction
Id - A unique identifier of a transaction.
- Transaction
Inputs - Contains the data required to execute a transaction.
- Transaction
Kernel - Transaction
Record - Describes a transaction that has been executed and is being tracked on the Client.
- Transaction
Request - Specifies a transaction request that can be executed by an account.
- Transaction
Request Builder - A builder for a
TransactionRequest. - Transaction
Result - Represents the result of executing a transaction by the client.
- Transaction
Script - Transaction script.
- Transaction
Store Update - Represents the changes that need to be applied to the client store as a result of a transaction execution.
- Transaction
Summary - The summary of the changes that result from executing a transaction.
Enums§
- Account
Component Interface - The enum holding all possible account interfaces which could be loaded to some account.
- Data
Store Error - Discard
Cause - Represents the cause of the discarded transaction.
- Foreign
Account - Account types for foreign procedure invocation.
- Input
Note - An input note for a transaction.
- Output
Note - The types of note outputs supported by the transaction kernel.
- Transaction
Executor Error - Transaction
Prover Error - Transaction
Request Error - Transaction
Script Template - Specifies a transaction script to be executed in a transaction.
- Transaction
Status - Represents the status of a transaction.
- Transaction
Status Variant
Traits§
- Transaction
Authenticator - Defines an authenticator for transactions.
- Transaction
Prover
Functions§
- notes_
from_ output - Extracts notes from
OutputNotes. Used for: