GrpcClient
Namespace: IotaSdk
The gRPC client for interacting with the IOTA blockchain.
public class GrpcClient : IGrpcClient, System.IDisposable
Inheritance Object → GrpcClient
Implements IGrpcClient, IDisposable
Attributes NullableContextAttribute, NullableAttribute
Constructors
GrpcClient(UInt64)
public GrpcClient(ulong pointer)
Parameters
pointer UInt64
GrpcClient(String)
Create a new gRPC client with the provided server URI.
public GrpcClient(string uri)
Parameters
uri String
Methods
Destroy()
public void Destroy()
Dispose()
public void Dispose()
ExecuteTransaction(SignedTransaction, UInt64?, GrpcTransactionField[])
Execute a signed transaction.
If checkpoint_inclusion_timeout_ms is provided, the server waits up to that long for the
transaction to be included in a checkpoint before responding. Include checkpoint and
timestamp in the read_mask to receive that data.
The optional read_mask controls which fields the server returns. If None, the
transaction digest, effects, events, and input/output objects are returned.
public async Task<GrpcExecutedTransaction> ExecuteTransaction(SignedTransaction signedTransaction, ulong? checkpointInclusionTimeoutMs = null, GrpcTransactionField[]? readMask = null)
Parameters
signedTransaction SignedTransaction
checkpointInclusionTimeoutMs UInt64?
readMask GrpcTransactionField[]?
Returns
Exceptions
ExecuteTransactions(SignedTransaction[], UInt64?, GrpcTransactionField[])
Execute a batch of signed transactions.
An error the server reports for one transaction does not abort the rest of the batch; reading that transaction's item throws the server's error message. A transaction the server returns but that cannot be decoded fails the whole call.
If checkpoint_inclusion_timeout_ms is provided, the server waits up to that long for the
transactions to be included in a checkpoint before responding. Include checkpoint and
timestamp in the read_mask to receive that data.
The optional read_mask controls which fields the server returns. If None, the
transaction digest, effects, events, and input/output objects are returned.
public async Task<GrpcExecutedTransactionResults> ExecuteTransactions(SignedTransaction[] transactions, ulong? checkpointInclusionTimeoutMs = null, GrpcTransactionField[]? readMask = null)
Parameters
transactions SignedTransaction[]
checkpointInclusionTimeoutMs UInt64?
readMask GrpcTransactionField[]?
Returns
Task<GrpcExecutedTransactionResults>
Exceptions
SimulateTransaction(Transaction, Boolean, GrpcSimulateField[])
Simulate a transaction.
If skip_checks is true, the VM checks are skipped during the simulation.
The optional read_mask controls which fields the server returns.
public async Task<GrpcSimulatedTransaction> SimulateTransaction(Transaction transaction, bool skipChecks = false, GrpcSimulateField[]? readMask = null)
Parameters
transaction Transaction
skipChecks Boolean
readMask GrpcSimulateField[]?
Returns
Task<GrpcSimulatedTransaction>
Exceptions
SimulateTransactions(GrpcSimulateTransactionInput[], GrpcSimulateField[])
Simulate a batch of transactions.
An error the server reports for one transaction does not abort the rest of the batch; each result carries either the simulated transaction or the server's error message. A transaction the server returns but that cannot be decoded fails the whole call.
public async Task<GrpcSimulatedTransactionResult[]> SimulateTransactions(GrpcSimulateTransactionInput[] transactions, GrpcSimulateField[]? readMask = null)
Parameters
transactions GrpcSimulateTransactionInput[]
readMask GrpcSimulateField[]?
Returns
Task<GrpcSimulatedTransactionResult[]>
Exceptions
ViewFunctionCall(String, TypeTag[], MoveViewArg[], GrpcViewFunctionCallField[])
public async Task<GrpcViewFunctionCallOutputs> ViewFunctionCall(string fqFunctionName, TypeTag[] typeArgs = null, MoveViewArg[] callArgs = null, GrpcViewFunctionCallField[]? readMask = null)
Parameters
fqFunctionName String
typeArgs TypeTag[]
callArgs MoveViewArg[]
readMask GrpcViewFunctionCallField[]?
Returns
Task<GrpcViewFunctionCallOutputs>
ViewFunctionCalls(GrpcViewFunctionCallInput[], GrpcViewFunctionCallField[])
Call a batch of Move view functions.
Each call runs in its own transaction on the server, so one call being rejected leaves the
rest untouched. Results are returned in the same order as the input; each result carries
either the outputs of the call or the error the node returned for it. A call that ran and
aborted lands in outputs, with the abort in its execution_error field.
The optional read_mask controls which fields the server returns.
public async Task<GrpcViewFunctionCallResult[]> ViewFunctionCalls(GrpcViewFunctionCallInput[] functionCalls, GrpcViewFunctionCallField[]? readMask = null)
Parameters
functionCalls GrpcViewFunctionCallInput[]
readMask GrpcViewFunctionCallField[]?
Returns
Task<GrpcViewFunctionCallResult[]>
Exceptions
CheckpointByDigest(CheckpointDigest, GrpcTransactionFilter, GrpcEventFilter, GrpcCheckpointResponseField[])
Get a checkpoint by its digest.
The optional transactions_filter and events_filter narrow the transactions and events
returned for the checkpoint.
The optional read_mask controls which fields the server returns.
If None, only the checkpoint summary is returned.
public async Task<GrpcCheckpointResponse> CheckpointByDigest(CheckpointDigest digest, GrpcTransactionFilter? transactionsFilter = null, GrpcEventFilter? eventsFilter = null, GrpcCheckpointResponseField[]? readMask = null)
Parameters
digest CheckpointDigest
transactionsFilter GrpcTransactionFilter?
eventsFilter GrpcEventFilter?
readMask GrpcCheckpointResponseField[]?
Returns
Exceptions
CheckpointBySequenceNumber(UInt64, GrpcTransactionFilter, GrpcEventFilter, GrpcCheckpointResponseField[])
Get a checkpoint by its sequence number.
The optional transactions_filter and events_filter narrow the transactions and events
returned for the checkpoint.
The optional read_mask controls which fields the server returns.
If None, only the checkpoint summary is returned.
public async Task<GrpcCheckpointResponse> CheckpointBySequenceNumber(ulong sequenceNumber, GrpcTransactionFilter? transactionsFilter = null, GrpcEventFilter? eventsFilter = null, GrpcCheckpointResponseField[]? readMask = null)
Parameters
sequenceNumber UInt64
transactionsFilter GrpcTransactionFilter?
eventsFilter GrpcEventFilter?
readMask GrpcCheckpointResponseField[]?
Returns
Exceptions
CheckpointLatest(GrpcTransactionFilter, GrpcEventFilter, GrpcCheckpointResponseField[])
Get the latest checkpoint.
The optional transactions_filter and events_filter narrow the transactions and events
returned for the checkpoint.
The optional read_mask controls which fields the server returns.
If None, only the checkpoint summary is returned.
public async Task<GrpcCheckpointResponse> CheckpointLatest(GrpcTransactionFilter? transactionsFilter = null, GrpcEventFilter? eventsFilter = null, GrpcCheckpointResponseField[]? readMask = null)
Parameters
transactionsFilter GrpcTransactionFilter?
eventsFilter GrpcEventFilter?
readMask GrpcCheckpointResponseField[]?
Returns
Exceptions
CheckpointsStream(UInt64?, UInt64?, GrpcTransactionFilter, GrpcEventFilter, GrpcCheckpointResponseField[])
Stream checkpoints across a range of sequence numbers.
Every checkpoint in the range is yielded, even if the filters produce no matching transactions or events within it.
If start_sequence_number is None, the stream starts from the latest checkpoint. If
end_sequence_number is None, the stream continues indefinitely.
The optional transactions_filter and events_filter narrow the transactions and events
returned for each checkpoint.
The optional read_mask controls which fields the server returns for each checkpoint. If
None, only the checkpoint summary is returned.
public async Task<GrpcCheckpointStream> CheckpointsStream(ulong? startSequenceNumber = null, ulong? endSequenceNumber = null, GrpcTransactionFilter? transactionsFilter = null, GrpcEventFilter? eventsFilter = null, GrpcCheckpointResponseField[]? readMask = null)
Parameters
startSequenceNumber UInt64?
endSequenceNumber UInt64?
transactionsFilter GrpcTransactionFilter?
eventsFilter GrpcEventFilter?
readMask GrpcCheckpointResponseField[]?
Returns
Exceptions
CheckpointsStreamFiltered(UInt64?, UInt64?, GrpcTransactionFilter, GrpcEventFilter, UInt32?, GrpcCheckpointResponseField[])
Stream checkpoints across a range of sequence numbers, skipping checkpoints with no data matching the filters.
Unlike [GrpcClient::checkpoints_stream], the filters decide which checkpoints are returned
at all; checkpoints without any matching transactions or events are skipped entirely. At
least one of transactions_filter or events_filter must be set.
While the server scans non-matching checkpoints, the stream yields progress items indicating
the current scan position (default every 2000ms, configurable via progress_interval_ms,
minimum 500ms).
If start_sequence_number is None, the stream starts from the latest checkpoint. If
end_sequence_number is None, the stream continues indefinitely.
The optional read_mask controls which fields the server returns for each checkpoint. If
None, only the checkpoint summary is returned.
public async Task<GrpcFilteredCheckpointStream> CheckpointsStreamFiltered(ulong? startSequenceNumber = null, ulong? endSequenceNumber = null, GrpcTransactionFilter? transactionsFilter = null, GrpcEventFilter? eventsFilter = null, uint? progressIntervalMs = null, GrpcCheckpointResponseField[]? readMask = null)
Parameters
startSequenceNumber UInt64?
endSequenceNumber UInt64?
transactionsFilter GrpcTransactionFilter?
eventsFilter GrpcEventFilter?
progressIntervalMs UInt32?
readMask GrpcCheckpointResponseField[]?
Returns
Task<GrpcFilteredCheckpointStream>
Exceptions
Epoch(UInt64?, GrpcEpochField[])
Get information about an epoch. If epoch is None, the current epoch is returned.
The optional read_mask controls which fields the server returns.
public async Task<GrpcEpochInfo> Epoch(ulong? epoch = null, GrpcEpochField[]? readMask = null)
Parameters
epoch UInt64?
readMask GrpcEpochField[]?
Returns
Exceptions
ReferenceGasPrice()
Get the reference gas price of the current epoch, denominated in NANOS.
public async Task<ulong> ReferenceGasPrice()
Returns
Exceptions
Health(UInt64?)
Get the health of the node serving the gRPC service.
If threshold_ms is provided, the server returns an UNAVAILABLE error when the most
recently executed checkpoint is older than the threshold.
public async Task<GrpcHealthInfo> Health(ulong? thresholdMs = null)
Parameters
thresholdMs UInt64?
Returns
Exceptions
Objects(ObjectId[], GrpcObjectField[])
Get the latest version of objects by their ids.
Results are returned in the same order as the input ids, one per id. An object the serving node cannot return — because it is not found, was deleted, or has been pruned — fails only its own item, which reading throws with the server's error message. An object the server returns but that cannot be decoded fails the whole call.
The optional read_mask controls which fields the server returns. If None, the reference
and the object are returned.
public async Task<GrpcObjectResults> Objects(ObjectId[] objectIds, GrpcObjectField[]? readMask = null)
Parameters
objectIds ObjectId[]
readMask GrpcObjectField[]?
Returns
Exceptions
ObjectsWithVersions(GrpcObjectRequest[], GrpcObjectField[])
Get objects by their ids and optional versions.
Results are returned in the same order as the input requests, one per request. An object the serving node cannot return — because it is not found, was deleted, or has been pruned — fails only its own item, which reading throws with the server's error message. An object the server returns but that cannot be decoded fails the whole call.
The optional read_mask controls which fields the server returns. If None, the reference
and the object are returned.
public async Task<GrpcObjectResults> ObjectsWithVersions(GrpcObjectRequest[] requests, GrpcObjectField[]? readMask = null)
Parameters
requests GrpcObjectRequest[]
readMask GrpcObjectField[]?
Returns
Exceptions
ServiceInfo(GrpcServiceInfoField[])
Get information about the gRPC service and the node serving it.
The optional read_mask controls which fields the server returns.
public async Task<GrpcServiceInfo> ServiceInfo(GrpcServiceInfoField[]? readMask = null)
Parameters
readMask GrpcServiceInfoField[]?
Returns
Exceptions
Transactions(TransactionDigest[], GrpcTransactionField[])
Get transactions by their digests.
Results are returned in the same order as the input digests, one per digest. A transaction the serving node cannot return — because it is not found or has been pruned — fails only its own item, which reading throws with the server's error message. A transaction the server returns but that cannot be decoded fails the whole call.
The optional read_mask controls which fields the server returns.
If None, the transaction, signatures, checkpoint, and timestamp are returned.
public async Task<GrpcExecutedTransactionResults> Transactions(TransactionDigest[] digests, GrpcTransactionField[]? readMask = null)
Parameters
digests TransactionDigest[]
readMask GrpcTransactionField[]?
Returns
Task<GrpcExecutedTransactionResults>
Exceptions
WaitForTransaction(TransactionDigest, WaitForTransaction)
Wait for the indexing (on the node) or finalization of a transaction by its digest, polling the node until then. Returns an error after 60s.
public async Task WaitForTransaction(TransactionDigest digest, WaitForTransaction waitFor)
Parameters
digest TransactionDigest
waitFor WaitForTransaction
Returns
Exceptions
AllPackageVersions(ObjectId, UInt32?)
List all versions of a Move package, auto-paginating up to limit versions. If limit is
None, all versions are returned.
public async Task<GrpcPackageVersion[]> AllPackageVersions(ObjectId packageId, uint? limit = null)
Parameters
packageId ObjectId
limit UInt32?
Returns
Exceptions
PackageVersions(ObjectId, UInt32?, Byte[])
List a single page of versions of a Move package.
Pass the returned next_page_token back in to retrieve the next page.
public async Task<GrpcPackageVersionPage> PackageVersions(ObjectId packageId, uint? pageSize = null, Byte[]? pageToken = null)
Parameters
packageId ObjectId
pageSize UInt32?
pageToken Byte[]?
Returns
Exceptions
CoinInfo(StructTag)
public async Task<GrpcCoinInfo> CoinInfo(StructTag coinType)
Parameters
coinType StructTag
Returns
AllCoins(Address, StructTag, UInt32?)
public async Task<Coin[]> AllCoins(Address owner, StructTag? coinType = null, uint? limit = null)
Parameters
owner Address
coinType StructTag?
limit UInt32?
Returns
Coins(Address, StructTag, UInt32?, Byte[])
public async Task<GrpcCoinPage> Coins(Address owner, StructTag? coinType = null, uint? pageSize = null, Byte[]? pageToken = null)
Parameters
owner Address
coinType StructTag?
pageSize UInt32?
pageToken Byte[]?
Returns
AllDynamicFields(ObjectId, UInt32?, GrpcDynamicFieldField[])
List all dynamic fields of an object, auto-paginating up to limit fields. If limit is
None, all fields are returned.
The optional read_mask controls which fields the server returns.
If None, the parent and field id are returned.
public async Task<GrpcDynamicField[]> AllDynamicFields(ObjectId parent, uint? limit = null, GrpcDynamicFieldField[]? readMask = null)
Parameters
parent ObjectId
limit UInt32?
readMask GrpcDynamicFieldField[]?
Returns
Exceptions
DynamicFields(ObjectId, UInt32?, Byte[], GrpcDynamicFieldField[])
List a single page of dynamic fields of an object.
Pass the returned next_page_token back in to retrieve the next page.
The optional read_mask controls which fields the server returns.
If None, the parent and field id are returned.
public async Task<GrpcDynamicFieldPage> DynamicFields(ObjectId parent, uint? pageSize = null, Byte[]? pageToken = null, GrpcDynamicFieldField[]? readMask = null)
Parameters
parent ObjectId
pageSize UInt32?
pageToken Byte[]?
readMask GrpcDynamicFieldField[]?
Returns
Exceptions
AllOwnedObjects(Address, StructTag, UInt32?, GrpcOwnedObjectField[])
List all objects owned by an address, optionally filtered by object type, auto-paginating up
to limit objects. If limit is None, all objects are returned.
The optional read_mask controls which fields the server returns. If None, the object
reference and the BCS-encoded object are returned.
public async Task<GrpcObject[]> AllOwnedObjects(Address owner, StructTag? objectType = null, uint? limit = null, GrpcOwnedObjectField[]? readMask = null)
Parameters
owner Address
objectType StructTag?
limit UInt32?
readMask GrpcOwnedObjectField[]?
Returns
Exceptions
OwnedObjects(Address, StructTag, UInt32?, Byte[], GrpcOwnedObjectField[])
List a single page of objects owned by an address, optionally filtered by object type.
Pass the returned next_page_token back in to retrieve the next page.
The optional read_mask controls which fields the server returns. If None, the object
reference and the BCS-encoded object are returned.
public async Task<GrpcOwnedObjectPage> OwnedObjects(Address owner, StructTag? objectType = null, uint? pageSize = null, Byte[]? pageToken = null, GrpcOwnedObjectField[]? readMask = null)
Parameters
owner Address
objectType StructTag?
pageSize UInt32?
pageToken Byte[]?
readMask GrpcOwnedObjectField[]?
Returns
Exceptions
SetBasicAuth(String, String)
Set a basic auth Authorization header that is sent with every request.
public void SetBasicAuth(string username, string? password)
Parameters
username String
password String?
SetBearerAuth(String)
Set a bearer auth Authorization header that is sent with every request.
public void SetBearerAuth(string token)
Parameters
token String
Exceptions
SetMaxDecodingMessageSize(UInt64)
Set the maximum size in bytes that a response message can be.
public void SetMaxDecodingMessageSize(ulong limit)
Parameters
limit UInt64
TransactionBuilder(Address)
Create a new transaction builder with the given sender address, backed by this client.
public GrpcTransactionBuilder TransactionBuilder(Address sender)
Parameters
sender Address
Returns
NewDevnet()
Create a new gRPC client connected to the devnet gRPC server.
public static GrpcClient NewDevnet()
Returns
Exceptions
NewLocalnet()
public static GrpcClient NewLocalnet()
Returns
NewMainnet()
Create a new gRPC client connected to the mainnet gRPC server.
public static GrpcClient NewMainnet()
Returns
Exceptions
NewTestnet()
Create a new gRPC client connected to the testnet gRPC server.
public static GrpcClient NewTestnet()