Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

gRPC client factory for IOTA gRPC operations.

Implementations§

Source§

impl Client

Source

pub async fn execute_transaction( &self, signed_transaction: SignedTransaction, read_mask: Option<&str>, checkpoint_inclusion_timeout_ms: Option<u64>, ) -> Result<MetadataEnvelope<ExecutedTransaction>>

Execute a signed transaction.

This submits the transaction to the network for execution and waits for the result. The transaction must be signed with valid signatures.

Returns proto ExecutedTransaction. Use lazy conversion methods to extract data:

  • result.effects() - Get transaction effects
  • result.events() - Get transaction events (if available)
  • result.input_objects() - Get input objects (if requested)
  • result.output_objects() - Get output objects (if requested)
§Available Read Mask Fields

The optional read_mask parameter controls which fields the server returns. If None, uses EXECUTE_TRANSACTIONS_READ_MASK which includes effects, events, and input/output objects.

§Transaction Fields
  • transaction - includes all transaction fields
    • transaction.digest - the transaction digest
    • transaction.bcs - the full BCS-encoded transaction
  • signatures - includes all signature fields
    • signatures.bcs - the full BCS-encoded signature
  • effects - includes all effects fields
    • effects.digest - the effects digest
    • effects.bcs - the full BCS-encoded effects
  • checkpoint - the checkpoint that included the transaction. Requires checkpoint_inclusion_timeout_ms to be set.
  • timestamp - the timestamp of the checkpoint. Requires checkpoint_inclusion_timeout_ms to be set.
§Event Fields
  • events - includes all event fields (all events of the transaction)
    • events.digest - the events digest
    • events.events.bcs - the full BCS-encoded event
    • events.events.package_id - the ID of the package that emitted the event
    • events.events.module - the module that emitted the event
    • events.events.sender - the sender that triggered the event
    • events.events.event_type - the type of the event
    • events.events.bcs_contents - the full BCS-encoded contents of the event
    • events.events.json_contents - the JSON-encoded contents of the event
§Object Fields
  • input_objects - includes all input object fields
    • input_objects.reference - includes all reference fields
      • input_objects.reference.object_id - the ID of the input object
      • input_objects.reference.version - the version of the input object
      • input_objects.reference.digest - the digest of the input object contents
    • input_objects.bcs - the full BCS-encoded object
  • output_objects - includes all output object fields
    • output_objects.reference - includes all reference fields
      • output_objects.reference.object_id - the ID of the output object
      • output_objects.reference.version - the version of the output object
      • output_objects.reference.digest - the digest of the output object contents
    • output_objects.bcs - the full BCS-encoded object
§Checkpoint Inclusion

If checkpoint_inclusion_timeout_ms is set, the server will wait up to the specified duration (in milliseconds) for the transaction to be included in a checkpoint before returning. When set, include checkpoint and timestamp in the read_mask to receive the data.

§Example
let client = Client::connect("http://localhost:9000").await?;

let signed_tx: SignedTransaction = todo!();

// Execute transaction - returns proto type
let result = client.execute_transaction(signed_tx, None, None).await?;

// Lazy conversion - only deserialize what you need
let effects = result.body().effects()?.effects()?;
println!("Status: {:?}", effects.status());

let events = result.body().events()?.events()?;
if !events.0.is_empty() {
    println!("Events: {}", events.0.len());
}
Source

pub async fn execute_transactions( &self, transactions: Vec<SignedTransaction>, read_mask: Option<&str>, checkpoint_inclusion_timeout_ms: Option<u64>, ) -> Result<MetadataEnvelope<Vec<Result<ExecutedTransaction>>>>

Execute a batch of signed transactions.

Transactions are executed sequentially on the server. Each transaction is independent — failure of one does not abort the rest.

Returns a Vec<Result<ExecutedTransaction>> in the same order as the input. Each element is either the successfully executed transaction or the per-item error returned by the server.

§Available Read Mask Fields

The optional read_mask parameter controls which fields the server returns for each ExecutedTransaction. If None, uses EXECUTE_TRANSACTIONS_READ_MASK which includes effects, events, and input/output objects.

See execute_transaction for the full list of supported read mask fields.

§Checkpoint Inclusion

If checkpoint_inclusion_timeout_ms is set, the server will wait up to the specified duration (in milliseconds) for all executed transactions to be included in a checkpoint before returning. When set, include checkpoint and timestamp in the read_mask to receive the data.

§Errors

Returns Error::EmptyRequest if transactions is empty. Returns a transport-level Error::Grpc if the entire RPC fails (e.g. batch size exceeded).

Source§

impl Client

Source

pub async fn simulate_transaction( &self, transaction: Transaction, skip_checks: bool, read_mask: Option<&str>, ) -> Result<MetadataEnvelope<SimulatedTransaction>>

Simulate a transaction without executing it.

This allows you to preview the effects of a transaction before actually submitting it to the network.

§Parameters
  • transaction: The transaction to simulate
  • skip_checks: Set to true for relaxed Move VM checks (useful for debugging and development)
  • read_mask: Optional field mask to control which fields are returned

Returns [SimulatedTransaction] which contains:

  • executed_transaction() - Access to the simulated ExecutedTransaction
  • command_results() - Access to intermediate command execution results

Use lazy conversion methods on the executed transaction to extract data:

  • result.executed_transaction()?.effects() - Get simulated effects
  • result.executed_transaction()?.events() - Get simulated events (if available)
  • result.executed_transaction()?.input_objects() - Get input objects (if requested)
  • result.executed_transaction()?.output_objects() - Get output objects (if requested)
§Available Read Mask Fields

The optional read_mask parameter controls which fields the server returns. If None, uses SIMULATE_TRANSACTIONS_READ_MASK which includes effects, events, and input/output objects.

§Transaction Fields
  • executed_transaction - includes all executed transaction fields
    • executed_transaction.transaction - includes all transaction fields
      • executed_transaction.transaction.digest - the transaction digest
      • executed_transaction.transaction.bcs - the full BCS-encoded transaction
    • executed_transaction.signatures - includes all signature fields
      • executed_transaction.signatures.bcs - the full BCS-encoded signature
    • executed_transaction.effects - includes all effects fields
      • executed_transaction.effects.digest - the effects digest
      • executed_transaction.effects.bcs - the full BCS-encoded effects
    • executed_transaction.events - includes all event fields
      • executed_transaction.events.digest - the events digest
      • executed_transaction.events.events - includes all event fields (all events of the transaction)
        • executed_transaction.events.events.bcs - the full BCS-encoded event
        • executed_transaction.events.events.package_id - the ID of the package that emitted the event
        • executed_transaction.events.events.module - the module that emitted the event
        • executed_transaction.events.events.sender - the sender that triggered the event
        • executed_transaction.events.events.event_type - the type of the event
        • executed_transaction.events.events.bcs_contents - the full BCS-encoded contents of the event
        • executed_transaction.events.events.json_contents - the JSON-encoded contents of the event
    • executed_transaction.checkpoint - the checkpoint that included the transaction (not available for just-executed transactions)
    • executed_transaction.timestamp - the timestamp of the checkpoint (not available for just-executed transactions)
    • executed_transaction.input_objects - includes all input object fields
      • executed_transaction.input_objects.reference - includes all reference fields
        • executed_transaction.input_objects.reference.object_id - the ID of the input object
        • executed_transaction.input_objects.reference.version - the version of the input object
        • executed_transaction.input_objects.reference.digest - the digest of the input object contents
      • executed_transaction.input_objects.bcs - the full BCS-encoded object
    • executed_transaction.output_objects - includes all output object fields
      • executed_transaction.output_objects.reference - includes all reference fields
        • executed_transaction.output_objects.reference.object_id - the ID of the output object
        • executed_transaction.output_objects.reference.version - the version of the output object
        • executed_transaction.output_objects.reference.digest - the digest of the output object contents
      • executed_transaction.output_objects.bcs - the full BCS-encoded object
§Gas Fields
  • suggested_gas_price - the suggested gas price for the transaction, denominated in NANOS
§Execution Result Fields
  • execution_result - the execution result (oneof: command_results on success, execution_error on failure)
    • execution_result.command_results - includes all fields of per-command results if execution succeeded
      • execution_result.command_results.mutated_by_ref - includes all fields of objects mutated by reference
        • execution_result.command_results.mutated_by_ref.argument - the argument reference
        • execution_result.command_results.mutated_by_ref.type_tag - the Move type tag
        • execution_result.command_results.mutated_by_ref.bcs - the BCS-encoded value
        • execution_result.command_results.mutated_by_ref.json - the JSON-encoded value
      • execution_result.command_results.return_values - includes all fields of return values returned by the command
        • execution_result.command_results.return_values.argument - the argument reference
        • execution_result.command_results.return_values.type_tag - the Move type tag
        • execution_result.command_results.return_values.bcs - the BCS-encoded value
        • execution_result.command_results.return_values.json - the JSON-encoded value
    • execution_result.execution_error - includes all fields of the execution error if execution failed
      • execution_result.execution_error.bcs_kind - the BCS-encoded error kind
      • execution_result.execution_error.source - the error source description
      • execution_result.execution_error.command_index - the index of the command that failed
§Example
let client = Client::connect("http://localhost:9000").await?;

let tx: Transaction = todo!();

// Simulate transaction - returns proto type
let result = client.simulate_transaction(tx, false, None).await?;

// Lazy conversion - only deserialize what you need
let executed_tx = result.body().executed_transaction()?;
let effects = executed_tx.effects()?.effects()?;
println!("Simulation status: {:?}", effects.status());

let output_objs = executed_tx.output_objects()?;
println!("Would create {} objects", output_objs.objects.len());
Source

pub async fn simulate_transactions( &self, transactions: Vec<SimulateTransactionInput>, read_mask: Option<&str>, ) -> Result<MetadataEnvelope<Vec<Result<SimulatedTransaction>>>>

Simulate a batch of transactions without executing them.

Transactions are simulated sequentially on the server. Each transaction is independent — failure of one does not abort the rest.

Returns a Vec<Result<SimulatedTransaction>> in the same order as the input. Each element is either the successfully simulated transaction or the per-item error returned by the server.

§Errors

Returns Error::EmptyRequest if transactions is empty. Returns a transport-level Error::Grpc if the entire RPC fails (e.g. batch size exceeded).

Source§

impl Client

Source

pub async fn get_checkpoint_latest( &self, read_mask: Option<&str>, transactions_filter: Option<TransactionFilter>, events_filter: Option<EventFilter>, ) -> Result<MetadataEnvelope<CheckpointResponse>>

Get the latest checkpoint.

This retrieves the checkpoint including summary, contents, transactions, and events based on the provided read mask.

§Parameters
§Example
let client = Client::connect("http://localhost:9000").await?;
let checkpoint = client.get_checkpoint_latest(None, None, None).await?;
println!("Received checkpoint {}", checkpoint.body().sequence_number,);
Source

pub async fn get_checkpoint_by_sequence_number( &self, sequence_number: CheckpointSequenceNumber, read_mask: Option<&str>, transactions_filter: Option<TransactionFilter>, events_filter: Option<EventFilter>, ) -> Result<MetadataEnvelope<CheckpointResponse>>

Get checkpoint by sequence number.

This retrieves the checkpoint including summary, contents, transactions, and events based on the provided read mask.

§Parameters
  • sequence_number - The checkpoint sequence number to fetch
  • read_mask - Optional field mask specifying which fields to include. If None, uses crate::api::GET_CHECKPOINT_READ_MASK as default. See module-level documentation for all available fields.
  • transactions_filter - Optional filter to apply to transactions
  • events_filter - Optional filter to apply to events
§Example
let client = Client::connect("http://localhost:9000").await?;
let checkpoint = client
    .get_checkpoint_by_sequence_number(100, None, None, None)
    .await?;
println!("Received checkpoint {}", checkpoint.body().sequence_number,);
Source

pub async fn get_checkpoint_by_digest( &self, digest: Digest, read_mask: Option<&str>, transactions_filter: Option<TransactionFilter>, events_filter: Option<EventFilter>, ) -> Result<MetadataEnvelope<CheckpointResponse>>

Get checkpoint by digest.

This retrieves the checkpoint including summary, contents, transactions, and events based on the provided read mask.

§Parameters
  • digest - The checkpoint digest to fetch
  • read_mask - Optional field mask specifying which fields to include. If None, uses crate::api::GET_CHECKPOINT_READ_MASK as default. See module-level documentation for all available fields.
  • transactions_filter - Optional filter to apply to transactions
  • events_filter - Optional filter to apply to events
§Example
let client = Client::connect("http://localhost:9000").await?;
let digest: Digest = todo!();
let checkpoint = client
    .get_checkpoint_by_digest(digest, None, None, None)
    .await?;
println!("Received checkpoint {}", checkpoint.body().sequence_number,);
Source

pub async fn stream_checkpoints( &self, start_sequence_number: Option<CheckpointSequenceNumber>, end_sequence_number: Option<CheckpointSequenceNumber>, read_mask: Option<&str>, transactions_filter: Option<TransactionFilter>, events_filter: Option<EventFilter>, ) -> Result<MetadataEnvelope<Pin<Box<dyn Stream<Item = Result<CheckpointResponse>> + Send>>>>

Stream checkpoints across a range of checkpoints.

Returns a stream of CheckpointResponse objects, each representing a complete checkpoint with its transactions and events. Every checkpoint in the range is yielded, even if the filters produce no matching transactions or events within it.

To skip non-matching checkpoints entirely, use stream_checkpoints_filtered.

Note: The metadata in the returned MetadataEnvelope is captured from the initial gRPC response headers when the stream is opened. It is not updated as subsequent checkpoint data arrives.

§Parameters
  • start_sequence_number - Optional starting checkpoint. If None, starts from the latest checkpoint.
  • end_sequence_number - Optional ending checkpoint. If None, streams indefinitely.
  • read_mask - Optional field mask specifying which fields to include. If None, uses crate::api::GET_CHECKPOINT_READ_MASK as default. See module-level documentation for all available fields.
  • transactions_filter - Optional filter to apply to transactions
  • events_filter - Optional filter to apply to events
§Example
let client = Client::connect("http://localhost:9000").await?;
let mut stream = client
    .stream_checkpoints(Some(0), Some(10), None, None, None)
    .await?;

while let Some(checkpoint) = stream.body_mut().next().await {
    let checkpoint = checkpoint?;
    println!("Received checkpoint {}", checkpoint.sequence_number);
}
Source

pub async fn stream_checkpoints_filtered( &self, start_sequence_number: Option<CheckpointSequenceNumber>, end_sequence_number: Option<CheckpointSequenceNumber>, read_mask: Option<&str>, transactions_filter: Option<TransactionFilter>, events_filter: Option<EventFilter>, progress_interval_ms: Option<u32>, ) -> Result<MetadataEnvelope<Pin<Box<dyn Stream<Item = Result<CheckpointStreamItem>> + Send>>>>

Stream checkpoints, skipping those with no matching data.

Unlike stream_checkpoints, this method sets filter_checkpoints = true on the server, which means checkpoints without any matching transactions or events are skipped entirely.

The returned stream yields CheckpointStreamItem, which is either a CheckpointStreamItem::Checkpoint or a CheckpointStreamItem::Progress. Progress messages are sent periodically during scanning to indicate liveness and the current scan position (default every 2 seconds, configurable via progress_interval_ms).

For liveness detection, wrap stream.next() in tokio::time::timeout() — if neither a Checkpoint nor a Progress arrives within your chosen duration plus some buffer for connection latency, the connection is likely dead.

At least one of transactions_filter or events_filter must be set.

§Parameters
  • start_sequence_number - Optional starting checkpoint. If None, starts from the latest checkpoint.
  • end_sequence_number - Optional ending checkpoint. If None, streams indefinitely.
  • read_mask - Optional field mask specifying which fields to include. If None, uses crate::api::GET_CHECKPOINT_READ_MASK as default. See module-level documentation for all available fields.
  • transactions_filter - Optional filter to apply to transactions
  • events_filter - Optional filter to apply to events
  • progress_interval_ms - Optional progress message interval in milliseconds. Defaults to 2000ms. Minimum 500ms.
§Example
let client = Client::connect("http://localhost:9000").await?;
// At least one filter is required
let tx_filter = grpc_filter::TransactionFilter::default();
let mut stream = client
    .stream_checkpoints_filtered(Some(0), None, None, Some(tx_filter), None, None)
    .await?;

while let Some(item) = stream.body_mut().next().await {
    match item? {
        CheckpointStreamItem::Checkpoint(cp) => {
            println!("Matched checkpoint {}", cp.sequence_number);
        }
        CheckpointStreamItem::Progress {
            latest_scanned_sequence_number,
        } => {
            println!("Scanned up to {latest_scanned_sequence_number}");
        }
    }
}
Source§

impl Client

Source

pub async fn get_epoch( &self, epoch: Option<u64>, read_mask: Option<&str>, ) -> Result<MetadataEnvelope<Epoch>>

Get epoch information.

Returns the [Epoch] proto type with fields populated according to the read_mask.

§Parameters
  • epoch - The epoch to query. If None, returns the current epoch.
  • read_mask - Optional field mask specifying which fields to include. If None, uses GET_EPOCH_READ_MASK.
§Available Read Mask Fields
§Epoch Fields
  • epoch - the epoch number
  • committee - the validator committee for this epoch
  • bcs_system_state - the BCS-encoded system state at the beginning of the epoch for past epochs or the current system state for the current epoch, which can be used for historical state queries or to get the current state respectively
§Checkpoint Fields
  • first_checkpoint - the first checkpoint included in the epoch
  • last_checkpoint - the last checkpoint included in the epoch, which may be unavailable for the current epoch if it has not ended yet
§Timing Fields
  • start - the timestamp of the first checkpoint included in the epoch
  • end - the timestamp of the last checkpoint included in the epoch, which may be unavailable for the current epoch if it has not ended yet
§Gas Fields
  • reference_gas_price - the reference gas price during the epoch, denominated in NANOS
§Protocol Configuration Fields
  • protocol_config - the protocol configuration during the epoch

    • protocol_config.protocol_version - the protocol version during the epoch
    • protocol_config.feature_flags - the individual protocol feature flags during the epoch (use protocol_config.feature_flags.<key> to filter specific flags)
    • protocol_config.attributes - the individual protocol attributes during the epoch (use protocol_config.attributes.<key> to filter specific attributes)

    Note: Other than for all other fields, wildcards don’t work for protocol_config.feature_flags and protocol_config.attributes since they are maps (protocol_config is not enough). If you want all entries, you must specify the map directly, or single entries of it by name. (e.g. protocol_config.feature_flags to get all entries, or protocol_config.feature_flags.zklogin_auth to get a single flag)

§Example
let client = Client::connect("http://localhost:9000").await?;

// Get current epoch with default fields
let epoch = client.get_epoch(None, None).await?;
println!("Epoch: {:?}", epoch.body().epoch);

// Get specific epoch with custom fields
let epoch = client
    .get_epoch(Some(0), Some("epoch,reference_gas_price,first_checkpoint"))
    .await?;

// Get all feature flags for the current epoch
let epoch = client
    .get_epoch(None, Some("protocol_config.feature_flags"))
    .await?
    .into_inner();
let flags = epoch.protocol_config.unwrap().feature_flags.unwrap().flags;

// Get a single named feature flag
let epoch = client
    .get_epoch(None, Some("protocol_config.feature_flags.zklogin_auth"))
    .await?;

// Get all protocol attributes for the current epoch
let epoch = client
    .get_epoch(None, Some("protocol_config.attributes"))
    .await?
    .into_inner();
let attributes = epoch
    .protocol_config
    .unwrap()
    .attributes
    .unwrap()
    .attributes;

// Get a single named attribute
let epoch = client
    .get_epoch(None, Some("protocol_config.attributes.max_tx_gas"))
    .await?;
Source

pub async fn get_reference_gas_price(&self) -> Result<MetadataEnvelope<u64>>

Get the reference gas price for the current epoch.

§Example
let client = Client::connect("http://localhost:9000").await?;
let gas_price = client.get_reference_gas_price().await?.into_inner();
println!("Reference gas price: {gas_price} NANOS");
Source§

impl Client

Source

pub async fn get_health( &self, threshold_ms: Option<u64>, ) -> Result<MetadataEnvelope<GetHealthResponse>>

Check the health of the node.

Returns a MetadataEnvelope<[GetHealthResponse]> with the latest checkpoint sequence number and an estimated validator latency field (reserved for future use).

If the node’s latest checkpoint is stale (beyond the threshold), the server returns an UNAVAILABLE error.

§Parameters
  • threshold_ms - Optional threshold in milliseconds. If provided, the node is considered healthy only if the latest executed checkpoint timestamp is within this many milliseconds of the current system time. If None, the server applies its default threshold (5 seconds).
Source§

impl Client

Source

pub async fn get_objects( &self, refs: &[(ObjectId, Option<Version>)], read_mask: Option<&str>, ) -> Result<MetadataEnvelope<Vec<Object>>>

Get objects by their IDs and optional versions.

Returns proto Object types. Use obj.object() to convert to SDK type, or use obj.object_reference() to get the object reference.

Results are returned in the same order as the input refs. If an object is not found, an error is returned.

§Errors

Returns Error::EmptyRequest if refs is empty.

§Available Read Mask Fields

The optional read_mask parameter controls which fields the server returns. If None, uses GET_OBJECTS_READ_MASK.

§Reference Fields
  • reference - includes all reference fields
    • reference.object_id - the ID of the object to fetch
    • reference.version - the version of the object, which can be used to fetch a specific historical version or the latest version if not provided
    • reference.digest - the digest of the object contents, which can be used for integrity verification
§Data Fields
  • bcs - the full BCS-encoded object
§Example
let client = Client::connect("http://localhost:9000").await?;
let object_id: ObjectId = "0x2".parse()?;

// Get proto objects
let objs = client.get_objects(&[(object_id, None)], None).await?;

for obj in objs.body() {
    // Convert proto object to SDK type
    let sdk_obj = obj.object()?;
    println!("Got object ID: {:?}", sdk_obj.object_id());
    let obj_ref = obj.object_reference()?;
    println!("Object version: {:?}", obj_ref.version());
}
Source§

impl Client

Source

pub async fn get_service_info( &self, read_mask: Option<&str>, ) -> Result<MetadataEnvelope<GetServiceInfoResponse>>

Get service info from the node.

Returns the [GetServiceInfoResponse] proto type with fields populated according to the read_mask.

§Available Read Mask Fields

The optional read_mask parameter controls which fields the server returns. If None, uses GET_SERVICE_INFO_READ_MASK.

§Network Fields
  • chain_id - the ID of the chain, which can be used to identify the network
  • chain - the chain identifier, which can be used to identify the network
§Current State Fields
  • epoch - the current epoch
  • executed_checkpoint_height - the height of the last executed checkpoint
  • executed_checkpoint_timestamp - the timestamp of the last executed checkpoint
§Availability Fields
  • lowest_available_checkpoint - lowest available checkpoint for which transaction and checkpoint data can be requested
  • lowest_available_checkpoint_objects - lowest available checkpoint for which object data can be requested
§Server Fields
  • server - the server version
§Example
let client = Client::connect("http://localhost:9000").await?;

// Get service info with default fields
let info = client.get_service_info(None).await?;
println!("Chain ID: {:?}", info.body().chain_id);
println!("Epoch: {:?}", info.body().epoch);

// Get service info with all fields
let info = client
    .get_service_info(Some(
        "chain_id,chain,epoch,executed_checkpoint_height,\
         executed_checkpoint_timestamp,lowest_available_checkpoint,\
         lowest_available_checkpoint_objects,server",
    ))
    .await?;
Source§

impl Client

Source

pub async fn get_transactions( &self, digests: &[Digest], read_mask: Option<&str>, ) -> Result<MetadataEnvelope<Vec<ExecutedTransaction>>>

Get transactions by their digests.

Returns proto ExecutedTransaction for each transaction. Use the lazy conversion methods to extract data:

  • tx.digest() - Get transaction digest
  • tx.transaction() - Deserialize transaction
  • tx.signatures() - Deserialize signatures
  • tx.effects() - Deserialize effects
  • tx.events() - Deserialize events (if available)
  • tx.checkpoint_sequence_number() - Get checkpoint number
  • tx.timestamp_ms() - Get timestamp

Results are returned in the same order as the input digests. If a transaction is not found, an error is returned.

§Errors

Returns Error::EmptyRequest if digests is empty.

§Available Read Mask Fields

The optional read_mask parameter controls which fields the server returns. If None, uses GET_TRANSACTIONS_READ_MASK.

§Transaction Fields
  • transaction - includes all transaction fields
    • transaction.digest - the transaction digest
    • transaction.bcs - the full BCS-encoded transaction
  • signatures - includes all signature fields
    • signatures.bcs - the full BCS-encoded signature
  • effects - includes all effects fields
    • effects.digest - the effects digest
    • effects.bcs - the full BCS-encoded effects
§Event Fields
  • events - includes all event fields
    • events.digest - the events digest
    • events.events - includes all event fields
      • events.events.bcs - the full BCS-encoded event
      • events.events.package_id - the ID of the package that emitted the event
      • events.events.module - the module that emitted the event
      • events.events.sender - the sender that triggered the event
      • events.events.event_type - the type of the event
      • events.events.bcs_contents - the full BCS-encoded contents of the event
      • events.events.json_contents - the JSON-encoded contents of the event
§Timing Fields
  • checkpoint - the checkpoint that included the transaction
  • timestamp - the timestamp of the checkpoint that included the transaction
§Object Fields
  • input_objects - includes all input object fields
    • input_objects.reference - includes all reference fields
      • input_objects.reference.object_id - the ID of the input object
      • input_objects.reference.version - the version of the input object, which can be used to fetch a specific historical version or the latest version if not provided
      • input_objects.reference.digest - the digest of the input object contents, which can be used for integrity verification
    • input_objects.bcs - the full BCS-encoded object
  • output_objects - includes all output object fields
    • output_objects.reference - includes all reference fields
      • output_objects.reference.object_id - the ID of the output object
      • output_objects.reference.version - the version of the output object, which can be used to fetch a specific historical version or the latest version if not provided
      • output_objects.reference.digest - the digest of the output object contents, which can be used for integrity verification
    • output_objects.bcs - the full BCS-encoded object
§Example
let client = Client::connect("http://localhost:9000").await?;
let digest: Digest = todo!();

// Get transactions - returns proto types
let txs = client.get_transactions(&[digest], None).await?;

for tx in txs.body() {
    // Lazy conversion - only deserialize what you need
    let effects = tx.effects()?.effects()?;
    println!("Status: {:?}", effects.status());

    // Access checkpoint number
    let checkpoint = tx.checkpoint_sequence_number()?;
    println!("Checkpoint: {}", checkpoint);
}
Source§

impl Client

Source

pub fn list_package_versions( &self, package_id: ObjectId, page_size: Option<u32>, page_token: Option<Bytes>, ) -> ListPackageVersionsQuery

List all versions of a Move package.

Returns a query builder. Await it directly for a single page (with access to next_page_token), or call .collect(limit) to auto-paginate through all results.

§Parameters
  • package_id - The object ID of any version of the package.
  • page_size - Optional maximum number of versions per page.
  • page_token - Optional continuation token from a previous page.
§Examples

Single page:

let client = Client::connect("http://localhost:9000").await?;
let package_id: ObjectId = "0x2".parse()?;

let page = client.list_package_versions(package_id, None, None).await?;
for version in &page.body().items {
    println!("Package version: {:?}", version);
}

Auto-paginate:

let client = Client::connect("http://localhost:9000").await?;
let package_id: ObjectId = "0x2".parse()?;

let all = client
    .list_package_versions(package_id, Some(50), None)
    .collect(None)
    .await?;
for version in all.body() {
    println!("Package version: {:?}", version);
}
Source§

impl Client

Source

pub async fn get_coin_info( &self, coin_type: StructTag, ) -> Result<MetadataEnvelope<GetCoinInfoResponse>>

Get information about a coin type.

Returns the [GetCoinInfoResponse] proto type with metadata, treasury, and regulation information for the specified coin type.

§Parameters
  • coin_type - The coin type as a [StructTag].
§Example
let client = Client::connect("http://localhost:9000").await?;
let coin_type: StructTag = "0x2::iota::IOTA".parse()?;

let response = client.get_coin_info(coin_type).await?;
let info = response.body();
println!("Coin info: {:?}", info);
Source§

impl Client

Source

pub fn list_dynamic_fields( &self, parent: ObjectId, page_size: Option<u32>, page_token: Option<Bytes>, read_mask: Option<&str>, ) -> ListDynamicFieldsQuery

List dynamic fields owned by a parent object.

Returns a query builder. Await it directly for a single page (with access to next_page_token), or call .collect(limit) to auto-paginate through all results.

§Parameters
  • parent - The object ID of the parent object.
  • page_size - Optional maximum number of fields per page.
  • page_token - Optional continuation token from a previous page.
  • read_mask - Optional field mask. If None, uses LIST_DYNAMIC_FIELDS_READ_MASK.
§Examples

Single page:

let client = Client::connect("http://localhost:9000").await?;
let parent: ObjectId = "0x2".parse()?;

let page = client.list_dynamic_fields(parent, None, None, None).await?;
for field in &page.body().items {
    println!("Dynamic field: {:?}", field);
}

Auto-paginate:

let client = Client::connect("http://localhost:9000").await?;
let parent: ObjectId = "0x2".parse()?;

let all = client
    .list_dynamic_fields(parent, Some(50), None, None)
    .collect(None)
    .await?;
for field in all.body() {
    println!("Dynamic field: {:?}", field);
}
Source§

impl Client

Source

pub fn list_owned_objects( &self, owner: Address, object_type: Option<StructTag>, page_size: Option<u32>, page_token: Option<Bytes>, read_mask: Option<&str>, ) -> ListOwnedObjectsQuery

List objects owned by an address.

Returns a query builder. Await it directly for a single page (with access to next_page_token), or call .collect(limit) to auto-paginate through all results.

§Parameters
  • owner - The address that owns the objects.
  • object_type - Optional type filter as a [StructTag].
  • page_size - Optional maximum number of objects per page.
  • page_token - Optional continuation token from a previous page.
  • read_mask - Optional field mask. If None, uses LIST_OWNED_OBJECTS_READ_MASK.
§Examples

Single page:

let client = Client::connect("http://localhost:9000").await?;
let owner: Address = "0x1".parse()?;

let page = client
    .list_owned_objects(owner, None, None, None, None)
    .await?;
for obj in &page.body().items {
    println!("Owned object: {:?}", obj);
}
if let Some(token) = &page.body().next_page_token {
    // Fetch the next page using the token
    let next = client
        .list_owned_objects(owner, None, None, Some(token.clone()), None)
        .await?;
}

Auto-paginate:

let client = Client::connect("http://localhost:9000").await?;
let owner: Address = "0x1".parse()?;

let all = client
    .list_owned_objects(owner, None, Some(50), None, None)
    .collect(Some(500))
    .await?;
for obj in all.body() {
    println!("Owned object: {:?}", obj);
}
Source§

impl Client

Source

pub async fn connect<T>(uri: T) -> Result<Self>
where T: TryInto<Uri>, T::Error: Into<Box<dyn Error + Send + Sync + 'static>>,

Connect to a gRPC server and create a new Client instance.

Source

pub fn uri(&self) -> &Uri

Source

pub fn channel(&self) -> &Channel

Get a reference to the underlying channel.

This can be useful for creating additional service clients that aren’t yet integrated into Client.

Source

pub fn headers(&self) -> &HeadersInterceptor

Source

pub fn max_decoding_message_size(&self) -> Option<usize>

Source

pub fn with_headers(self, headers: HeadersInterceptor) -> Self

Source

pub fn with_max_decoding_message_size(self, limit: usize) -> Self

Source

pub fn ledger_service_client(&self) -> LedgerServiceClient<InterceptedChannel>

Get a ledger service client.

Source

pub fn execution_service_client( &self, ) -> TransactionExecutionServiceClient<InterceptedChannel>

Get a transaction execution service client.

Source

pub fn state_service_client(&self) -> StateServiceClient<InterceptedChannel>

Get a state service client.

Source

pub fn move_package_service_client( &self, ) -> MovePackageServiceClient<InterceptedChannel>

Get a move package service client.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pipe for T
where T: ?Sized,

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more