Skip to main content

NodeRpcClient

Trait NodeRpcClient 

Source
pub trait NodeRpcClient: Send + Sync {
Show 26 methods // Required methods fn set_genesis_commitment<'life0, 'async_trait>( &'life0 self, commitment: Word, ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn has_genesis_commitment(&self) -> Option<Word>; fn submit_proven_transaction<'life0, 'async_trait>( &'life0 self, proven_transaction: ProvenTransaction, transaction_inputs: TransactionInputs, ) -> Pin<Box<dyn Future<Output = Result<BlockNumber, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn get_block_header_by_number<'life0, 'async_trait>( &'life0 self, block_num: Option<BlockNumber>, include_mmr_proof: bool, ) -> Pin<Box<dyn Future<Output = Result<(BlockHeader, Option<MmrProof>), RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn get_block_by_number<'life0, 'async_trait>( &'life0 self, block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<ProvenBlock, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn get_notes_by_id<'life0, 'life1, 'async_trait>( &'life0 self, note_ids: &'life1 [NoteId], ) -> Pin<Box<dyn Future<Output = Result<Vec<FetchedNote>, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn sync_chain_mmr<'life0, 'async_trait>( &'life0 self, block_from: BlockNumber, block_to: Option<BlockNumber>, ) -> Pin<Box<dyn Future<Output = Result<ChainMmrInfo, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn get_account_details<'life0, 'async_trait>( &'life0 self, account_id: AccountId, ) -> Pin<Box<dyn Future<Output = Result<FetchedAccount, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn sync_notes<'life0, 'life1, 'async_trait>( &'life0 self, block_num: BlockNumber, block_to: Option<BlockNumber>, note_tags: &'life1 BTreeSet<NoteTag>, ) -> Pin<Box<dyn Future<Output = Result<NoteSyncInfo, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn sync_nullifiers<'life0, 'life1, 'async_trait>( &'life0 self, prefix: &'life1 [u16], block_num: BlockNumber, block_to: Option<BlockNumber>, ) -> Pin<Box<dyn Future<Output = Result<Vec<NullifierUpdate>, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn check_nullifiers<'life0, 'life1, 'async_trait>( &'life0 self, nullifiers: &'life1 [Nullifier], ) -> Pin<Box<dyn Future<Output = Result<Vec<SmtProof>, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait; fn get_account_proof<'life0, 'async_trait>( &'life0 self, account_id: AccountId, storage_requirements: AccountStorageRequirements, account_state: AccountStateAt, known_account_code: Option<AccountCode>, ) -> Pin<Box<dyn Future<Output = Result<(BlockNumber, AccountProof), RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn get_note_script_by_root<'life0, 'async_trait>( &'life0 self, root: Word, ) -> Pin<Box<dyn Future<Output = Result<NoteScript, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn sync_storage_maps<'life0, 'async_trait>( &'life0 self, block_from: BlockNumber, block_to: Option<BlockNumber>, account_id: AccountId, ) -> Pin<Box<dyn Future<Output = Result<StorageMapInfo, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn sync_account_vault<'life0, 'async_trait>( &'life0 self, block_from: BlockNumber, block_to: Option<BlockNumber>, account_id: AccountId, ) -> Pin<Box<dyn Future<Output = Result<AccountVaultInfo, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn sync_transactions<'life0, 'async_trait>( &'life0 self, block_from: BlockNumber, block_to: Option<BlockNumber>, account_ids: Vec<AccountId>, ) -> Pin<Box<dyn Future<Output = Result<TransactionsInfo, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn get_network_id<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<NetworkId, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn get_rpc_limits<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<RpcLimits, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn has_rpc_limits(&self) -> Option<RpcLimits>; fn set_rpc_limits<'life0, 'async_trait>( &'life0 self, limits: RpcLimits, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn get_status_unversioned<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<RpcStatusInfo, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; // Provided methods fn get_nullifier_commit_heights<'life0, 'async_trait>( &'life0 self, requested_nullifiers: BTreeSet<Nullifier>, block_from: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<BTreeMap<Nullifier, Option<BlockNumber>>, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait { ... } fn get_public_note_records<'life0, 'life1, 'async_trait>( &'life0 self, note_ids: &'life1 [NoteId], current_timestamp: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<Vec<InputNoteRecord>, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait { ... } fn get_updated_public_accounts<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, local_accounts: &'life1 [&'life2 AccountHeader], ) -> Pin<Box<dyn Future<Output = Result<Vec<Account>, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait { ... } fn get_block_header_with_proof<'life0, 'async_trait>( &'life0 self, block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<(BlockHeader, MmrProof), RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait { ... } fn get_note_by_id<'life0, 'async_trait>( &'life0 self, note_id: NoteId, ) -> Pin<Box<dyn Future<Output = Result<FetchedNote, RpcError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait { ... }
}
Expand description

Defines the interface for communicating with the Miden node.

The implementers are responsible for connecting to the Miden node, handling endpoint requests/responses, and translating responses into domain objects relevant for each of the endpoints.

Required Methods§

Source

fn set_genesis_commitment<'life0, 'async_trait>( &'life0 self, commitment: Word, ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Sets the genesis commitment for the client and reconnects to the node providing the genesis commitment in the request headers. If the genesis commitment is already set, this method does nothing.

Source

fn has_genesis_commitment(&self) -> Option<Word>

Returns the genesis commitment if it has been set, without fetching from the node.

Source

fn submit_proven_transaction<'life0, 'async_trait>( &'life0 self, proven_transaction: ProvenTransaction, transaction_inputs: TransactionInputs, ) -> Pin<Box<dyn Future<Output = Result<BlockNumber, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Given a Proven Transaction, send it to the node for it to be included in a future block using the /SubmitProvenTransaction RPC endpoint.

Source

fn get_block_header_by_number<'life0, 'async_trait>( &'life0 self, block_num: Option<BlockNumber>, include_mmr_proof: bool, ) -> Pin<Box<dyn Future<Output = Result<(BlockHeader, Option<MmrProof>), RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Given a block number, fetches the block header corresponding to that height from the node using the /GetBlockHeaderByNumber endpoint. If include_mmr_proof is set to true and the function returns an Ok, the second value of the return tuple should always be Some(MmrProof).

When None is provided, returns info regarding the latest block.

Source

fn get_block_by_number<'life0, 'async_trait>( &'life0 self, block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<ProvenBlock, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Given a block number, fetches the block corresponding to that height from the node using the /GetBlockByNumber RPC endpoint.

Source

fn get_notes_by_id<'life0, 'life1, 'async_trait>( &'life0 self, note_ids: &'life1 [NoteId], ) -> Pin<Box<dyn Future<Output = Result<Vec<FetchedNote>, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Fetches note-related data for a list of NoteId using the /GetNotesById RPC endpoint.

For miden_protocol::note::NoteType::Private notes, the response includes only the miden_protocol::note::NoteMetadata.

For miden_protocol::note::NoteType::Public notes, the response includes all note details (recipient, assets, script, etc.).

In both cases, a miden_protocol::note::NoteInclusionProof is returned so the caller can verify that each note is part of the block’s note tree.

Source

fn sync_chain_mmr<'life0, 'async_trait>( &'life0 self, block_from: BlockNumber, block_to: Option<BlockNumber>, ) -> Pin<Box<dyn Future<Output = Result<ChainMmrInfo, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches the MMR delta for a given block range using the /SyncChainMmr RPC endpoint.

  • block_from is the last block number already present in the caller’s MMR.
  • block_to is the optional upper bound of the range. If None, syncs up to the chain tip.
Source

fn get_account_details<'life0, 'async_trait>( &'life0 self, account_id: AccountId, ) -> Pin<Box<dyn Future<Output = Result<FetchedAccount, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches the current state of an account from the node using the /GetAccountDetails RPC endpoint.

  • account_id is the ID of the wanted account.
Source

fn sync_notes<'life0, 'life1, 'async_trait>( &'life0 self, block_num: BlockNumber, block_to: Option<BlockNumber>, note_tags: &'life1 BTreeSet<NoteTag>, ) -> Pin<Box<dyn Future<Output = Result<NoteSyncInfo, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Fetches the notes related to the specified tags using the /SyncNotes RPC endpoint.

  • block_num is the last block number known by the client.
  • note_tags is a list of tags used to filter the notes the client is interested in.
Source

fn sync_nullifiers<'life0, 'life1, 'async_trait>( &'life0 self, prefix: &'life1 [u16], block_num: BlockNumber, block_to: Option<BlockNumber>, ) -> Pin<Box<dyn Future<Output = Result<Vec<NullifierUpdate>, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Fetches the nullifiers corresponding to a list of prefixes using the /SyncNullifiers RPC endpoint.

  • prefix is a list of nullifiers prefixes to search for.
  • block_num is the block number to start the search from. Nullifiers created in this block or the following blocks will be included.
  • block_to is the optional block number to stop the search at. If not provided, syncs up to the network chain tip.
Source

fn check_nullifiers<'life0, 'life1, 'async_trait>( &'life0 self, nullifiers: &'life1 [Nullifier], ) -> Pin<Box<dyn Future<Output = Result<Vec<SmtProof>, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Fetches the nullifier proofs corresponding to a list of nullifiers using the /CheckNullifiers RPC endpoint.

Source

fn get_account_proof<'life0, 'async_trait>( &'life0 self, account_id: AccountId, storage_requirements: AccountStorageRequirements, account_state: AccountStateAt, known_account_code: Option<AccountCode>, ) -> Pin<Box<dyn Future<Output = Result<(BlockNumber, AccountProof), RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches the account proof and optionally its details from the node, using the GetAccountProof endpoint.

The account_state parameter specifies the block number from which to retrieve the account proof from (the state of the account at that block).

The storage_requirements parameter specifies which storage slots and map keys should be included in the response for public accounts.

The known_account_code parameter is the known code commitment to prevent unnecessary data fetching. Returns the block number and the account proof. If the account is not found in the node, the method will return an error.

Source

fn get_note_script_by_root<'life0, 'async_trait>( &'life0 self, root: Word, ) -> Pin<Box<dyn Future<Output = Result<NoteScript, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches the note script with the specified root.

Errors:

Source

fn sync_storage_maps<'life0, 'async_trait>( &'life0 self, block_from: BlockNumber, block_to: Option<BlockNumber>, account_id: AccountId, ) -> Pin<Box<dyn Future<Output = Result<StorageMapInfo, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches storage map updates for specified account and storage slots within a block range, using the /SyncStorageMaps RPC endpoint.

  • block_from: The starting block number for the range.
  • block_to: The ending block number for the range.
  • account_id: The account ID for which to fetch storage map updates.
Source

fn sync_account_vault<'life0, 'async_trait>( &'life0 self, block_from: BlockNumber, block_to: Option<BlockNumber>, account_id: AccountId, ) -> Pin<Box<dyn Future<Output = Result<AccountVaultInfo, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches account vault updates for specified account within a block range, using the /SyncAccountVault RPC endpoint.

  • block_from: The starting block number for the range.
  • block_to: The ending block number for the range.
  • account_id: The account ID for which to fetch storage map updates.
Source

fn sync_transactions<'life0, 'async_trait>( &'life0 self, block_from: BlockNumber, block_to: Option<BlockNumber>, account_ids: Vec<AccountId>, ) -> Pin<Box<dyn Future<Output = Result<TransactionsInfo, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches transactions records for specific accounts within a block range. Using the /SyncTransactions RPC endpoint.

  • block_from: The starting block number for the range.
  • block_to: The ending block number for the range.
  • account_ids: The account IDs for which to fetch storage map updates.
Source

fn get_network_id<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<NetworkId, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches the network ID of the node. Errors:

Source

fn get_rpc_limits<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<RpcLimits, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches the RPC limits configured on the node.

Implementations may cache the result internally to avoid repeated network calls.

Source

fn has_rpc_limits(&self) -> Option<RpcLimits>

Returns the RPC limits if they have been set, without fetching from the node.

Source

fn set_rpc_limits<'life0, 'async_trait>( &'life0 self, limits: RpcLimits, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Sets the RPC limits internally to be used by the client.

Source

fn get_status_unversioned<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<RpcStatusInfo, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches the RPC status without requiring Accept header validation.

This is useful for diagnostics when version negotiation fails, as it allows retrieving node information even when there’s a version mismatch.

Provided Methods§

Source

fn get_nullifier_commit_heights<'life0, 'async_trait>( &'life0 self, requested_nullifiers: BTreeSet<Nullifier>, block_from: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<BTreeMap<Nullifier, Option<BlockNumber>>, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches the commit height where the nullifier was consumed. If the nullifier isn’t found, then None is returned. The block_num parameter is the block number to start the search from.

The default implementation of this method uses NodeRpcClient::sync_nullifiers.

Source

fn get_public_note_records<'life0, 'life1, 'async_trait>( &'life0 self, note_ids: &'life1 [NoteId], current_timestamp: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<Vec<InputNoteRecord>, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Fetches public note-related data for a list of NoteId and builds InputNoteRecords with it. If a note is not found or it’s private, it is ignored and will not be included in the returned list.

The default implementation of this method uses NodeRpcClient::get_notes_by_id.

Source

fn get_updated_public_accounts<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, local_accounts: &'life1 [&'life2 AccountHeader], ) -> Pin<Box<dyn Future<Output = Result<Vec<Account>, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Fetches the public accounts that have been updated since the last known state of the accounts.

The local_accounts parameter is a list of account headers that the client has stored locally and that it wants to check for updates. If an account is private or didn’t change, it is ignored and will not be included in the returned list. The default implementation of this method uses NodeRpcClient::get_account_details.

Source

fn get_block_header_with_proof<'life0, 'async_trait>( &'life0 self, block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<(BlockHeader, MmrProof), RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Given a block number, fetches the block header corresponding to that height from the node along with the MMR proof.

The default implementation of this method uses NodeRpcClient::get_block_header_by_number.

Source

fn get_note_by_id<'life0, 'async_trait>( &'life0 self, note_id: NoteId, ) -> Pin<Box<dyn Future<Output = Result<FetchedNote, RpcError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetches the note with the specified ID.

The default implementation of this method uses NodeRpcClient::get_notes_by_id.

Errors:

Implementors§