IGraphQlClient
Namespace: IotaSdk
The GraphQL client for interacting with the IOTA blockchain.
public interface IGraphQlClient
Attributes NullableContextAttribute
Methods
Balance(Address, StructTag)
Get the balance of all the coins owned by address for the provided coin type. Coin type will
default to 0x2::iota::IOTA if not provided.
Task<ulong?> Balance(Address address, StructTag? coinType = null)
Parameters
address Address
coinType StructTag?
Returns
Exceptions
Checkpoint(CheckpointDigest, UInt64?)
Get the CheckpointSummary for a given checkpoint digest or checkpoint id. If none is
provided, it will use the last known checkpoint id.
Task<CheckpointSummary?> Checkpoint(CheckpointDigest? digest = null, ulong? sequenceNumber = null)
Parameters
digest CheckpointDigest?
sequenceNumber UInt64?
Returns
Exceptions
Checkpoints(GraphQlPaginationFilter)
Get a page of CheckpointSummary for the provided parameters.
Task<GraphQlCheckpointSummaryPage> Checkpoints(GraphQlPaginationFilter? paginationFilter = null)
Parameters
paginationFilter GraphQlPaginationFilter?
Returns
Task<GraphQlCheckpointSummaryPage>
Exceptions
LatestCheckpointSequenceNumber()
Return the sequence number of the latest checkpoint that has been executed.
Task<ulong?> LatestCheckpointSequenceNumber()
Returns
Exceptions
TotalTransactionBlocks()
The total number of transaction blocks in the network by the end of the last known checkpoint.
Task<ulong?> TotalTransactionBlocks()
Returns
Exceptions
TotalTransactionBlocksByDigest(CheckpointDigest)
The total number of transaction blocks in the network by the end of the provided checkpoint digest.
Task<ulong?> TotalTransactionBlocksByDigest(CheckpointDigest digest)
Parameters
digest CheckpointDigest
Returns
Exceptions
TotalTransactionBlocksBySequenceNumber(UInt64)
The total number of transaction blocks in the network by the end of the provided checkpoint sequence number.
Task<ulong?> TotalTransactionBlocksBySequenceNumber(ulong sequenceNumber)
Parameters
sequenceNumber UInt64
Returns
Exceptions
CoinMetadata(StructTag)
Get the coin metadata for the coin type.
Task<GraphQlCoinMetadata?> CoinMetadata(StructTag coinType)
Parameters
coinType StructTag
Returns
Exceptions
Coins(Address, GraphQlPaginationFilter, StructTag)
Get the list of coins for the specified address.
If coin_type is not provided, all coins will be returned. For IOTA coins, pass in the coin
type: 0x2::iota::IOTA.
Task<GraphQlCoinPage> Coins(Address owner, GraphQlPaginationFilter? paginationFilter = null, StructTag? coinType = null)
Parameters
owner Address
paginationFilter GraphQlPaginationFilter?
coinType StructTag?
Returns
Exceptions
GasCoins(Address, GraphQlPaginationFilter)
Get the list of gas coins for the specified address.
Task<GraphQlCoinPage> GasCoins(Address owner, GraphQlPaginationFilter? paginationFilter = null)
Parameters
owner Address
paginationFilter GraphQlPaginationFilter?
Returns
Exceptions
TotalSupply(StructTag)
Get total supply for the coin type.
Task<ulong?> TotalSupply(StructTag coinType)
Parameters
coinType StructTag
Returns
Exceptions
DryRunTransaction(Transaction, Boolean)
Dry run a Transaction and return the transaction effects and dry run error (if any).
skipChecks optional flag disables the usual verification checks that prevent access to
objects that are owned by addresses other than the sender, and calling non-public, non-entry
functions, and some other checks. Defaults to false.
Task<GraphQlDryRunResult> DryRunTransaction(Transaction transaction, bool skipChecks = false)
Parameters
transaction Transaction
skipChecks Boolean
Returns
Exceptions
DryRunTransactionKind(TransactionKind, GraphQlTransactionMetadata, Boolean)
Dry run a TransactionKind and return the transaction effects and dry run error (if any).
skipChecks optional flag disables the usual verification checks that prevent access to
objects that are owned by addresses other than the sender, and calling non-public, non-entry
functions, and some other checks. Defaults to false.
transaction_metadata is the transaction metadata.
Task<GraphQlDryRunResult> DryRunTransactionKind(TransactionKind transactionKind, GraphQlTransactionMetadata transactionMetadata, bool skipChecks = false)
Parameters
transactionKind TransactionKind
transactionMetadata GraphQlTransactionMetadata
skipChecks Boolean
Returns
Exceptions
DynamicField(Address, TypeTag, String)
Access a dynamic field on an object using its name. Names are arbitrary Move values whose type have copy, drop, and store, and are specified using their type, and their BCS contents, Base64 encoded.
The name argument is a json serialized type.
This returns GraphQLDynamicFieldOutput which contains the name, the value as json, and
object.
Task<GraphQlDynamicFieldOutput?> DynamicField(Address address, TypeTag typeTag, string name)
Parameters
address Address
typeTag TypeTag
name String
Returns
Task<GraphQlDynamicFieldOutput>
Exceptions
DynamicFields(Address, GraphQlPaginationFilter)
Get a page of dynamic fields for the provided address. Note that this will also fetch dynamic fields on wrapped objects.
This returns a page of GraphQLDynamicFieldOutputs.
Task<GraphQlDynamicFieldOutputPage> DynamicFields(Address address, GraphQlPaginationFilter? paginationFilter = null)
Parameters
address Address
paginationFilter GraphQlPaginationFilter?
Returns
Task<GraphQlDynamicFieldOutputPage>
Exceptions
DynamicObjectField(Address, TypeTag, String)
Access a dynamic object field on an object using its name. Names are arbitrary Move values whose type have copy, drop, and store, and are specified using their type, and their BCS contents, Base64 encoded.
The name argument is a json serialized type.
This returns GraphQLDynamicFieldOutput which contains the name, the value as json, and
object.
Task<GraphQlDynamicFieldOutput?> DynamicObjectField(Address address, TypeTag typeTag, string name)
Parameters
address Address
typeTag TypeTag
name String
Returns
Task<GraphQlDynamicFieldOutput>
Exceptions
Epoch(UInt64?)
Return the epoch information for the provided epoch. If no epoch is provided, it will return the last known epoch.
Task<GraphQlEpoch?> Epoch(ulong? epoch = null)
Parameters
epoch UInt64?
Returns
Exceptions
EpochTotalCheckpoints(UInt64?)
Return the number of checkpoints in this epoch. This will return Ok(None) if the epoch
requested is not available in the GraphQL service (e.g., due to pruning).
Task<ulong?> EpochTotalCheckpoints(ulong? epoch = null)
Parameters
epoch UInt64?
Returns
Exceptions
EpochTotalTransactionBlocks(UInt64?)
Return the number of transaction blocks in this epoch. This will return Ok(None) if the
epoch requested is not available in the GraphQL service (e.g., due to pruning).
Task<ulong?> EpochTotalTransactionBlocks(ulong? epoch = null)
Parameters
epoch UInt64?
Returns
Exceptions
Events(GraphQlEventFilter, GraphQlPaginationFilter)
Return a page of tuple (event, transaction digest) based on the (optional) event filter.
Task<GraphQlEventPage> Events(GraphQlEventFilter? filter = null, GraphQlPaginationFilter? paginationFilter = null)
Parameters
filter GraphQlEventFilter?
paginationFilter GraphQlPaginationFilter?
Returns
Exceptions
IotaNamesDefaultName(Address, NameFormat?)
Get the default name pointing to this address, if one exists.
Task<Name?> IotaNamesDefaultName(Address address, NameFormat? format)
Parameters
address Address
format NameFormat?
Returns
Exceptions
IotaNamesLookup(Name)
Return the resolved address for the given name.
Task<Address?> IotaNamesLookup(Name name)
Parameters
name Name
Returns
Exceptions
IotaNamesRegistrations(Address, GraphQlPaginationFilter)
Find all registration NFTs for the given address.
Task<GraphQlNameRegistrationPage> IotaNamesRegistrations(Address address, GraphQlPaginationFilter paginationFilter)
Parameters
address Address
paginationFilter GraphQlPaginationFilter
Returns
Task<GraphQlNameRegistrationPage>
Exceptions
MoveViewCall(ObjectId, String, String, TypeTag[], MoveViewArg[])
Execute a Move View Function.
A View Function is a function in a Move module with a return type that does not alter the state of the ledger. When using this interface, no transactions are submitted to the network for inclusion into the ledger.
This method allows calling nearly any Move function with a return type and any arguments. The function's result values are provided and decoded using the appropriate Move type, then formatted in JSON.
The use of this interface does not require signature checks (even for functions that take Owned Objects as input) or gas coins, as it does not alter ledger state. Spam attacks are dealt with at the RPC level rather than execution level.
Arguments
package- The package the Move function is defined inmodule- The module the Move function is defined infunction- The name of the Move functiontype_arguments- The type arguments of the Move functionarguments- The typed arguments to be passed into the Move function
Returns
A GraphQLMoveViewResult containing either execution results (return values) or an error.
Task<GraphQlMoveViewResult> MoveViewCall(ObjectId package, string module, string function, TypeTag[]? typeArguments = null, MoveViewArg[]? arguments = null)
Parameters
package ObjectId
module String
function String
typeArguments TypeTag[]?
arguments MoveViewArg[]?
Returns
Exceptions
MoveViewCallJson(ObjectId, String, String, String[], String[])
Execute a Move View Function with raw JSON arguments.
This is an alternative to [GraphQLClient::move_view_call] that accepts raw JSON values
instead of typed arguments.
A View Function is a function in a Move module with a return type that does not alter the state of the ledger. When using this interface, no transactions are submitted to the network for inclusion into the ledger.
Arguments
package- The package the Move function is defined inmodule- The module the Move function is defined infunction- The name of the Move functiontype_arguments- The type arguments of the Move functionarguments- The arguments to be passed into the Move function, in JSON format
Returns
A GraphQLMoveViewResult containing either execution results (return values) or an error.
Task<GraphQlMoveViewResult> MoveViewCallJson(ObjectId package, string module, string function, String[]? typeArguments = null, String[]? arguments = null)
Parameters
package ObjectId
module String
function String
typeArguments String[]?
arguments String[]?
Returns
Exceptions
ActiveValidators(UInt64?, GraphQlPaginationFilter)
Get the list of active validators for the provided epoch, including related metadata. If no epoch is provided, it will return the active validators for the current epoch.
Task<GraphQlValidatorPage> ActiveValidators(ulong? epoch = null, GraphQlPaginationFilter? paginationFilter = null)
Parameters
epoch UInt64?
paginationFilter GraphQlPaginationFilter?
Returns
Exceptions
ChainId()
Get the chain identifier.
Task<string> ChainId()
Returns
Exceptions
ProtocolConfig(UInt64?)
Get the protocol configuration.
Task<GraphQlProtocolConfigs> ProtocolConfig(ulong? version = null)
Parameters
version UInt64?
Returns
Exceptions
ReferenceGasPrice(UInt64?)
Get the reference gas price for the provided epoch or the last known one if no epoch is provided.
This will return Ok(None) if the epoch requested is not available in the GraphQL service
(e.g., due to pruning).
Task<ulong?> ReferenceGasPrice(ulong? epoch = null)
Parameters
epoch UInt64?
Returns
Exceptions
MoveObjectContents(ObjectId, Version)
Return the contents' JSON of an object that is a Move object.
If the object does not exist (e.g., due to pruning), this will return Ok(None). Similarly,
if this is not an object but an address, it will return Ok(None).
Task<string?> MoveObjectContents(ObjectId objectId, Version? version = null)
Parameters
objectId ObjectId
version Version?
Returns
Exceptions
MoveObjectContentsBcs(ObjectId, Version)
Return the BCS of an object that is a Move object.
If the object does not exist (e.g., due to pruning), this will return Ok(None). Similarly,
if this is not an object but an address, it will return Ok(None).
Task<Byte[]?> MoveObjectContentsBcs(ObjectId objectId, Version? version = null)
Parameters
objectId ObjectId
version Version?
Returns
Exceptions
Object(ObjectId, Version)
Return an object based on the provided Address.
If the object does not exist (e.g., due to pruning), this will return Ok(None). Similarly,
if this is not an object but an address, it will return Ok(None).
Task<Object?> Object(ObjectId objectId, Version? version = null)
Parameters
objectId ObjectId
version Version?
Returns
Exceptions
ObjectBcs(ObjectId)
Task<Byte[]?> ObjectBcs(ObjectId objectId)
Parameters
objectId ObjectId
Returns
Objects(GraphQlObjectFilter, GraphQlPaginationFilter)
Return a page of objects based on the provided parameters.
Use this function together with the GraphQLObjectFilter::owner to get the objects owned by
an address.
Task<GraphQlObjectPage> Objects(GraphQlObjectFilter? filter = null, GraphQlPaginationFilter? paginationFilter = null)
Parameters
filter GraphQlObjectFilter?
paginationFilter GraphQlPaginationFilter?
Returns
Exceptions
NormalizedMoveFunction(Address, String, String, Version)
Return the normalized Move function data for the provided package, module, and function.
Task<GraphQlMoveFunction?> NormalizedMoveFunction(Address package, string module, string function, Version? version = null)
Parameters
package Address
module String
function String
version Version?
Returns
Exceptions
NormalizedMoveModule(Address, String, Version, GraphQlPaginationFilter, GraphQlPaginationFilter, GraphQlPaginationFilter, GraphQlPaginationFilter)
Return the normalized Move module data for the provided module.
Task<GraphQlMoveModule?> NormalizedMoveModule(Address package, string module, Version? version = null, GraphQlPaginationFilter? paginationFilterEnums = null, GraphQlPaginationFilter? paginationFilterFriends = null, GraphQlPaginationFilter? paginationFilterFunctions = null, GraphQlPaginationFilter? paginationFilterStructs = null)
Parameters
package Address
module String
version Version?
paginationFilterEnums GraphQlPaginationFilter?
paginationFilterFriends GraphQlPaginationFilter?
paginationFilterFunctions GraphQlPaginationFilter?
paginationFilterStructs GraphQlPaginationFilter?
Returns
Exceptions
Package(Address, Version)
The package corresponding to the given address (at the optionally given version). When no version is given, the package is loaded directly from the address given. Otherwise, the address is translated before loading to point to the package whose original ID matches the package at address, but whose version is version. For non-system packages, this might result in a different address than address because different versions of a package, introduced by upgrades, exist at distinct addresses.
Note that this interpretation of version is different from a historical object read (the interpretation of version for the object query).
Task<MovePackage?> Package(Address address, Version? version = null)
Parameters
address Address
version Version?
Returns
Exceptions
PackageLatest(Address)
Fetch the latest version of the package at address. This corresponds to the package with the highest version that shares its original ID with the package at address.
Task<MovePackage?> PackageLatest(Address address)
Parameters
address Address
Returns
Exceptions
PackageVersions(Address, Version, Version, GraphQlPaginationFilter)
Fetch all versions of package at address (packages that share this package's original ID), optionally bounding the versions exclusively from below with afterVersion, or from above with beforeVersion.
Task<GraphQlMovePackagePage> PackageVersions(Address address, Version? afterVersion = null, Version? beforeVersion = null, GraphQlPaginationFilter? paginationFilter = null)
Parameters
address Address
afterVersion Version?
beforeVersion Version?
paginationFilter GraphQlPaginationFilter?
Returns
Exceptions
Packages(UInt64?, UInt64?, GraphQlPaginationFilter)
The Move packages that exist in the network, optionally filtered to be strictly before beforeCheckpoint and/or strictly after afterCheckpoint.
This query returns all versions of a given user package that appear between the specified checkpoints, but only records the latest versions of system packages.
Task<GraphQlMovePackagePage> Packages(ulong? afterCheckpoint = null, ulong? beforeCheckpoint = null, GraphQlPaginationFilter? paginationFilter = null)
Parameters
afterCheckpoint UInt64?
beforeCheckpoint UInt64?
paginationFilter GraphQlPaginationFilter?
Returns
Exceptions
AddressTransactions(Address, GraphQlAddressTransactionRelationship?, GraphQlTransactionsFilter, GraphQlPaginationFilter)
Get a page of transactions related to the given address.
relation selects how the address relates to them, defaulting to the transactions it sent.
Task<GraphQlSignedTransactionPage> AddressTransactions(Address address, GraphQlAddressTransactionRelationship? relation = null, GraphQlTransactionsFilter? filter = null, GraphQlPaginationFilter? paginationFilter = null)
Parameters
address Address
relation GraphQlAddressTransactionRelationship?
filter GraphQlTransactionsFilter?
paginationFilter GraphQlPaginationFilter?
Returns
Task<GraphQlSignedTransactionPage>
Exceptions
ExecuteTransaction(UserSignature[], Transaction, WaitForTransaction?)
Execute a transaction.
If the wait fails, the error is returned although the transaction was executed, and its
effects are lost. To keep them, pass no wait_for and call wait_for_transaction on the
client afterwards.
Task<TransactionEffects> ExecuteTransaction(UserSignature[] signatures, Transaction transaction, WaitForTransaction? waitFor = null)
Parameters
signatures UserSignature[]
transaction Transaction
waitFor WaitForTransaction?
Returns
Exceptions
IsTransactionFinalized(TransactionDigest)
Returns whether the transaction for the given digest has been included in a checkpoint (finalized).
Task<bool> IsTransactionFinalized(TransactionDigest digest)
Parameters
digest TransactionDigest
Returns
Exceptions
IsTransactionIndexedOnNode(TransactionDigest)
Returns whether the transaction for the given digest has been indexed on the node. This
means that it can be queried by its digest and its effects will be usable for subsequent
transactions. To check for full finalization, use is_transaction_finalized.
Task<bool> IsTransactionIndexedOnNode(TransactionDigest digest)
Parameters
digest TransactionDigest
Returns
Exceptions
Transaction(TransactionDigest)
Get a transaction by its digest.
Task<SignedTransaction?> Transaction(TransactionDigest digest)
Parameters
digest TransactionDigest
Returns
Exceptions
TransactionDataEffects(TransactionDigest)
Get a transaction's data and effects by its digest.
Task<GraphQlTransactionDataEffects?> TransactionDataEffects(TransactionDigest digest)
Parameters
digest TransactionDigest
Returns
Task<GraphQlTransactionDataEffects>
Exceptions
TransactionEffects(TransactionDigest)
Get a transaction's effects by its digest.
Task<TransactionEffects?> TransactionEffects(TransactionDigest digest)
Parameters
digest TransactionDigest
Returns
Exceptions
Transactions(GraphQlTransactionsFilter, GraphQlPaginationFilter)
Get a page of transactions based on the provided filters.
Task<GraphQlSignedTransactionPage> Transactions(GraphQlTransactionsFilter? filter = null, GraphQlPaginationFilter? paginationFilter = null)
Parameters
filter GraphQlTransactionsFilter?
paginationFilter GraphQlPaginationFilter?
Returns
Task<GraphQlSignedTransactionPage>
Exceptions
TransactionsDataEffects(GraphQlTransactionsFilter, GraphQlPaginationFilter)
Get a page of transactions' data and effects based on the provided filters.
Task<GraphQlTransactionDataEffectsPage> TransactionsDataEffects(GraphQlTransactionsFilter? filter = null, GraphQlPaginationFilter? paginationFilter = null)
Parameters
filter GraphQlTransactionsFilter?
paginationFilter GraphQlPaginationFilter?
Returns
Task<GraphQlTransactionDataEffectsPage>
Exceptions
TransactionsEffects(GraphQlTransactionsFilter, GraphQlPaginationFilter)
Get a page of transactions' effects based on the provided filters.
Task<GraphQlTransactionEffectsPage> TransactionsEffects(GraphQlTransactionsFilter? filter = null, GraphQlPaginationFilter? paginationFilter = null)
Parameters
filter GraphQlTransactionsFilter?
paginationFilter GraphQlPaginationFilter?
Returns
Task<GraphQlTransactionEffectsPage>
Exceptions
WaitForTransaction(TransactionDigest, WaitForTransaction, TimeSpan?)
Wait for the indexing (on the node, not the indexer) or finalization of a transaction by its digest. An optional timeout can be provided, which, if exceeded, will return an error (default 60s).
Task WaitForTransaction(TransactionDigest digest, WaitForTransaction waitFor, TimeSpan? timeout = null)
Parameters
digest TransactionDigest
waitFor WaitForTransaction
timeout TimeSpan?
Returns
Exceptions
MaxPageSize()
Lazily fetch the max page size
Task<int> MaxPageSize()
Returns
Exceptions
RunQuery(GraphQlQuery)
Run a query.
Task<string> RunQuery(GraphQlQuery query)
Parameters
query GraphQlQuery
Returns
Exceptions
ServiceConfig()
Get the GraphQL service configuration, including complexity limits, read and mutation limits, supported versions, and others.
Task<GraphQlServiceConfig> ServiceConfig()
Returns
Exceptions
TransactionBuilder(Address)
Create a new transaction builder with the given sender address, backed by this client.
GraphQlTransactionBuilder TransactionBuilder(Address sender)
Parameters
sender Address
Returns
WithSubscriptionUrl(String)
A copy of this client whose subscriptions connect to url instead of the subscriptions
endpoint under the RPC URL. An http or https URL is upgraded to ws or wss.
GraphQlClient WithSubscriptionUrl(string url)
Parameters
url String
Returns
Exceptions
EventsSubscription(GraphQlSubscriptionEventFilter, TransactionDigest)
Subscribe to a live stream of events matching the (optional) filter.
start_after optionally resumes from the transaction immediately following the given
transaction digest; thereafter the subscription tracks its own resume point across
reconnects.
Note: subscriptions are served over a WebSocket, which the node has to have enabled —
serviceConfig.enabledFeatures includes SUBSCRIPTIONS when it is available.
GraphQlEventSubscription EventsSubscription(GraphQlSubscriptionEventFilter? filter = null, TransactionDigest? startAfter = null)
Parameters
filter GraphQlSubscriptionEventFilter?
startAfter TransactionDigest?
Returns
TransactionsSubscription(GraphQlSubscriptionTransactionFilter, TransactionDigest)
Subscribe to a live stream of transactions matching the (optional) filter.
start_after optionally resumes from the transaction immediately following the given
digest; thereafter the subscription tracks its own resume point across reconnects.
Note: subscriptions are served over a WebSocket, which the node has to have enabled —
serviceConfig.enabledFeatures includes SUBSCRIPTIONS when it is available.
GraphQlTransactionSubscription TransactionsSubscription(GraphQlSubscriptionTransactionFilter? filter = null, TransactionDigest? startAfter = null)
Parameters
filter GraphQlSubscriptionTransactionFilter?
startAfter TransactionDigest?