GraphQlClient
Namespace: IotaSdk
The GraphQL client for interacting with the IOTA blockchain.
public class GraphQlClient : IGraphQlClient, System.IDisposable
Inheritance Object → GraphQlClient
Implements IGraphQlClient, IDisposable
Attributes NullableContextAttribute, NullableAttribute
Constructors
GraphQlClient(UInt64)
public GraphQlClient(ulong pointer)
Parameters
pointer UInt64
GraphQlClient(String)
Create a new GraphQL client with the provided server address.
public GraphQlClient(string server)
Parameters
server String
Methods
Destroy()
public void Destroy()
Dispose()
public void Dispose()
Balance(Address, String)
public async Task<ulong?> Balance(Address address, string? coinType = null)
Parameters
address Address
coinType String?
Returns
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.
public async Task<CheckpointSummary?> Checkpoint(CheckpointDigest? digest = null, ulong? seqNum = null)
Parameters
digest CheckpointDigest?
seqNum UInt64?
Returns
Exceptions
Checkpoints(PaginationFilter)
Get a page of CheckpointSummary for the provided parameters.
public async Task<CheckpointSummaryPage> Checkpoints(PaginationFilter? paginationFilter = null)
Parameters
paginationFilter PaginationFilter?
Returns
Exceptions
LatestCheckpointSequenceNumber()
Return the sequence number of the latest checkpoint that has been executed.
public async Task<ulong?> LatestCheckpointSequenceNumber()
Returns
Exceptions
TotalTransactionBlocks()
The total number of transaction blocks in the network by the end of the last known checkpoint.
public async Task<ulong?> TotalTransactionBlocks()
Returns
Exceptions
TotalTransactionBlocksByDigest(CheckpointDigest)
The total number of transaction blocks in the network by the end of the provided checkpoint digest.
public async Task<ulong?> TotalTransactionBlocksByDigest(CheckpointDigest digest)
Parameters
digest CheckpointDigest
Returns
Exceptions
TotalTransactionBlocksBySeqNum(UInt64)
The total number of transaction blocks in the network by the end of the provided checkpoint sequence number.
public async Task<ulong?> TotalTransactionBlocksBySeqNum(ulong seqNum)
Parameters
seqNum UInt64
Returns
Exceptions
CoinMetadata(String)
Get the coin metadata for the coin type.
public async Task<CoinMetadata?> CoinMetadata(string coinType)
Parameters
coinType String
Returns
Exceptions
Coins(Address, PaginationFilter, 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.
public async Task<CoinPage> Coins(Address owner, PaginationFilter? paginationFilter = null, StructTag? coinType = null)
Parameters
owner Address
paginationFilter PaginationFilter?
coinType StructTag?
Returns
Exceptions
GasCoins(Address, PaginationFilter)
Get the list of gas coins for the specified address.
public async Task<CoinPage> GasCoins(Address owner, PaginationFilter? paginationFilter = null)
Parameters
owner Address
paginationFilter PaginationFilter?
Returns
Exceptions
TotalSupply(String)
Get total supply for the coin type.
public async Task<ulong?> TotalSupply(string coinType)
Parameters
coinType String
Returns
Exceptions
DryRunTx(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.
public async Task<DryRunResult> DryRunTx(Transaction tx, bool skipChecks = false)
Parameters
tx Transaction
skipChecks Boolean
Returns
Exceptions
DryRunTxKind(TransactionKind, TransactionMetadata, 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.
tx_meta is the transaction metadata.
public async Task<DryRunResult> DryRunTxKind(TransactionKind txKind, TransactionMetadata txMeta, bool skipChecks = false)
Parameters
txKind TransactionKind
txMeta TransactionMetadata
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 DynamicFieldOutput which contains the name, the value
as json, and object.
public async Task<DynamicFieldOutput?> DynamicField(Address address, TypeTag typeTag, string name)
Parameters
address Address
typeTag TypeTag
name String
Returns
Exceptions
DynamicFields(Address, PaginationFilter)
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 DynamicFieldOutputs.
public async Task<DynamicFieldOutputPage> DynamicFields(Address address, PaginationFilter? paginationFilter = null)
Parameters
address Address
paginationFilter PaginationFilter?
Returns
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 DynamicFieldOutput which contains the name, the value
as json, and object.
public async Task<DynamicFieldOutput?> DynamicObjectField(Address address, TypeTag typeTag, string name)
Parameters
address Address
typeTag TypeTag
name String
Returns
Exceptions
Epoch(UInt64?)
Return the epoch information for the provided epoch. If no epoch is provided, it will return the last known epoch.
public async Task<Epoch?> 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).
public async 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).
public async Task<ulong?> EpochTotalTransactionBlocks(ulong? epoch = null)
Parameters
epoch UInt64?
Returns
Exceptions
Events(EventFilter, PaginationFilter)
Return a page of tuple (event, transaction digest) based on the (optional) event filter.
public async Task<EventPage> Events(EventFilter? filter = null, PaginationFilter? paginationFilter = null)
Parameters
filter EventFilter?
paginationFilter PaginationFilter?
Returns
Exceptions
IotaNamesDefaultName(Address, NameFormat?)
Get the default name pointing to this address, if one exists.
public async Task<Name?> IotaNamesDefaultName(Address address, NameFormat? format)
Parameters
address Address
format NameFormat?
Returns
Exceptions
IotaNamesLookup(String)
Return the resolved address for the given name.
public async Task<Address?> IotaNamesLookup(string name)
Parameters
name String
Returns
Exceptions
IotaNamesRegistrations(Address, PaginationFilter)
Find all registration NFTs for the given address.
public async Task<NameRegistrationPage> IotaNamesRegistrations(Address address, PaginationFilter paginationFilter)
Parameters
address Address
paginationFilter PaginationFilter
Returns
Exceptions
MoveViewCall(String, TypeTag[], MoveViewArg[])
public async Task<MoveViewResult> MoveViewCall(string functionName, TypeTag[]? typeArguments = null, MoveViewArg[]? arguments = null)
Parameters
functionName String
typeArguments TypeTag[]?
arguments MoveViewArg[]?
Returns
MoveViewCallJson(String, String[], String[])
public async Task<MoveViewResult> MoveViewCallJson(string functionName, String[]? typeArguments = null, String[]? arguments = null)
Parameters
functionName String
typeArguments String[]?
arguments String[]?
Returns
ActiveValidators(UInt64?, PaginationFilter)
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.
public async Task<ValidatorPage> ActiveValidators(ulong? epoch = null, PaginationFilter? paginationFilter = null)
Parameters
epoch UInt64?
paginationFilter PaginationFilter?
Returns
Exceptions
ChainId()
Get the chain identifier.
public async Task<string> ChainId()
Returns
Exceptions
ProtocolConfig(UInt64?)
Get the protocol configuration.
public async Task<ProtocolConfigs> 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).
public async 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).
public async 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).
public async 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).
public async Task<Object?> Object(ObjectId objectId, Version? version = null)
Parameters
objectId ObjectId
version Version?
Returns
Exceptions
ObjectBcs(ObjectId)
public async Task<Byte[]?> ObjectBcs(ObjectId objectId)
Parameters
objectId ObjectId
Returns
Objects(ObjectFilter, PaginationFilter)
Return a page of objects based on the provided parameters.
Use this function together with the ObjectFilter::owner to get the
objects owned by an address.
public async Task<ObjectPage> Objects(ObjectFilter? filter = null, PaginationFilter? paginationFilter = null)
Parameters
filter ObjectFilter?
paginationFilter PaginationFilter?
Returns
Exceptions
NormalizedMoveFunction(Address, String, String, Version)
Return the normalized Move function data for the provided package, module, and function.
public async Task<MoveFunction?> 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, PaginationFilter, PaginationFilter, PaginationFilter, PaginationFilter)
Return the normalized Move module data for the provided module.
public async Task<MoveModule?> NormalizedMoveModule(Address package, string module, Version? version = null, PaginationFilter? paginationFilterEnums = null, PaginationFilter? paginationFilterFriends = null, PaginationFilter? paginationFilterFunctions = null, PaginationFilter? paginationFilterStructs = null)
Parameters
package Address
module String
version Version?
paginationFilterEnums PaginationFilter?
paginationFilterFriends PaginationFilter?
paginationFilterFunctions PaginationFilter?
paginationFilterStructs PaginationFilter?
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).
public async 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.
public async Task<MovePackage?> PackageLatest(Address address)
Parameters
address Address
Returns
Exceptions
PackageVersions(Address, Version, Version, PaginationFilter)
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.
public async Task<MovePackagePage> PackageVersions(Address address, Version? afterVersion = null, Version? beforeVersion = null, PaginationFilter? paginationFilter = null)
Parameters
address Address
afterVersion Version?
beforeVersion Version?
paginationFilter PaginationFilter?
Returns
Exceptions
Packages(UInt64?, UInt64?, PaginationFilter)
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.
public async Task<MovePackagePage> Packages(ulong? afterCheckpoint = null, ulong? beforeCheckpoint = null, PaginationFilter? paginationFilter = null)
Parameters
afterCheckpoint UInt64?
beforeCheckpoint UInt64?
paginationFilter PaginationFilter?
Returns
Exceptions
ExecuteTx(UserSignature[], Transaction, WaitForTx?)
Execute a transaction.
public async Task<TransactionEffects> ExecuteTx(UserSignature[] signatures, Transaction tx, WaitForTx? waitFor = null)
Parameters
signatures UserSignature[]
tx Transaction
waitFor WaitForTx?
Returns
Exceptions
IsTxFinalized(TransactionDigest)
Returns whether the transaction for the given digest has been included in a checkpoint (finalized).
public async Task<bool> IsTxFinalized(TransactionDigest digest)
Parameters
digest TransactionDigest
Returns
Exceptions
IsTxIndexedOnNode(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_tx_finalized.
public async Task<bool> IsTxIndexedOnNode(TransactionDigest digest)
Parameters
digest TransactionDigest
Returns
Exceptions
Transaction(TransactionDigest)
Get a transaction by its digest.
public async Task<SignedTransaction?> Transaction(TransactionDigest digest)
Parameters
digest TransactionDigest
Returns
Exceptions
TransactionDataEffects(TransactionDigest)
Get a transaction's data and effects by its digest.
public async Task<TransactionDataEffects?> TransactionDataEffects(TransactionDigest digest)
Parameters
digest TransactionDigest
Returns
Exceptions
TransactionEffects(TransactionDigest)
Get a transaction's effects by its digest.
public async Task<TransactionEffects?> TransactionEffects(TransactionDigest digest)
Parameters
digest TransactionDigest
Returns
Exceptions
Transactions(TransactionsFilter, PaginationFilter)
Get a page of transactions based on the provided filters.
public async Task<SignedTransactionPage> Transactions(TransactionsFilter? filter = null, PaginationFilter? paginationFilter = null)
Parameters
filter TransactionsFilter?
paginationFilter PaginationFilter?
Returns
Exceptions
TransactionsDataEffects(TransactionsFilter, PaginationFilter)
Get a page of transactions' data and effects based on the provided filters.
public async Task<TransactionDataEffectsPage> TransactionsDataEffects(TransactionsFilter? filter = null, PaginationFilter? paginationFilter = null)
Parameters
filter TransactionsFilter?
paginationFilter PaginationFilter?
Returns
Task<TransactionDataEffectsPage>
Exceptions
TransactionsEffects(TransactionsFilter, PaginationFilter)
Get a page of transactions' effects based on the provided filters.
public async Task<TransactionEffectsPage> TransactionsEffects(TransactionsFilter? filter = null, PaginationFilter? paginationFilter = null)
Parameters
filter TransactionsFilter?
paginationFilter PaginationFilter?
Returns
Exceptions
WaitForTx(TransactionDigest, WaitForTx, 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).
public async Task WaitForTx(TransactionDigest digest, WaitForTx waitFor, TimeSpan? timeout = null)
Parameters
digest TransactionDigest
waitFor WaitForTx
timeout TimeSpan?
Returns
Exceptions
MaxPageSize()
Lazily fetch the max page size
public async Task<int> MaxPageSize()
Returns
Exceptions
RunQuery(Query)
Run a query.
public async Task<string> RunQuery(Query query)
Parameters
query Query
Returns
Exceptions
ServiceConfig()
Get the GraphQL service configuration, including complexity limits, read and mutation limits, supported versions, and others.
public async Task<ServiceConfig> ServiceConfig()
Returns
Exceptions
SetRpcServer(String)
Set the server address for the GraphQL client. It should be a valid URL with a host and optionally a port number.
public async Task SetRpcServer(string server)
Parameters
server String
Returns
Exceptions
EventsSubscription(SubscriptionEventFilter, String)
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 and are currently
supported on devnet and localnet only. They are unavailable altogether
in the wasm build, where next raises.
public async Task<EventSubscription> EventsSubscription(SubscriptionEventFilter? filter = null, string? startAfter = null)
Parameters
filter SubscriptionEventFilter?
startAfter String?
Returns
TransactionsSubscription(SubscriptionTransactionFilter, String)
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 and are currently
supported on devnet and localnet only. They are unavailable altogether
in the wasm build, where next raises.
public async Task<TransactionSubscription> TransactionsSubscription(SubscriptionTransactionFilter? filter = null, string? startAfter = null)
Parameters
filter SubscriptionTransactionFilter?
startAfter String?
Returns
TransactionBuilder(Address)
Create a new TransactionBuilder with the given sender address.
public ClientTransactionBuilder TransactionBuilder(Address sender)
Parameters
sender Address
Returns
NewDevnet()
Create a new GraphQL client connected to the devnet GraphQL server:
{DEVNET_HOST}.
public static GraphQlClient NewDevnet()
Returns
NewLocalnet()
Create a new GraphQL client connected to the localhost GraphQL server:
{DEFAULT_LOCAL_HOST}.
public static GraphQlClient NewLocalnet()
Returns
NewMainnet()
Create a new GraphQL client connected to the mainnet GraphQL server:
{MAINNET_HOST}.
public static GraphQlClient NewMainnet()
Returns
NewTestnet()
Create a new GraphQL client connected to the testnet GraphQL server:
{TESTNET_HOST}.
public static GraphQlClient NewTestnet()