Skip to main content

GraphQlClient

open class GraphQlClient : Disposable, AutoCloseable, GraphQlClientInterface

The GraphQL client for interacting with the IOTA blockchain.

Constructors

GraphQlClientconstructor(server: String)
Create a new GraphQL client with the provided server address.

Functions

NameSummary
activeValidatorsopen suspend override fun activeValidators(epoch: ULong?, paginationFilter: PaginationFilter?): ValidatorPage
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.
balanceopen suspend override fun balance(address: Address, coinType: String?): ULong?
Get the balance of all the coins owned by address for the provided coin type. Coin type will default to 0x2::coin::Coin<0x2::iota::IOTA> if not provided.
chainIdopen suspend override fun chainId(): String
Get the chain identifier.
checkpointopen suspend override fun checkpoint(digest: CheckpointDigest?, seqNum: ULong?): CheckpointSummary?
Get the CheckpointSummary for a given checkpoint digest or checkpoint id. If none is provided, it will use the last known checkpoint id.
checkpointsopen suspend override fun checkpoints(paginationFilter: PaginationFilter?): CheckpointSummaryPage
Get a page of CheckpointSummary for the provided parameters.
close@Synchronized
open override fun close()
coinMetadataopen suspend override fun coinMetadata(coinType: String): CoinMetadata?
Get the coin metadata for the coin type.
coinsopen suspend override fun coins(owner: Address, paginationFilter: PaginationFilter?, coinType: StructTag?): CoinPage
Get the list of coins for the specified address.
destroyopen override fun destroy()
dryRunTxopen suspend override fun dryRunTx(tx: Transaction, skipChecks: Boolean): DryRunResult
Dry run a Transaction and return the transaction effects and dry run error (if any).
dryRunTxKindopen suspend override fun dryRunTxKind(txKind: TransactionKind, txMeta: TransactionMetadata, skipChecks: Boolean): DryRunResult
Dry run a TransactionKind and return the transaction effects and dry run error (if any).
dynamicFieldopen suspend override fun dynamicField(address: Address, typeTag: TypeTag, name: Value): DynamicFieldOutput?
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.
dynamicFieldsopen suspend override fun dynamicFields(address: Address, paginationFilter: PaginationFilter?): DynamicFieldOutputPage
Get a page of dynamic fields for the provided address. Note that this will also fetch dynamic fields on wrapped objects.
dynamicObjectFieldopen suspend override fun dynamicObjectField(address: Address, typeTag: TypeTag, name: Value): DynamicFieldOutput?
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.
epochopen suspend override fun epoch(epoch: ULong?): Epoch?
Return the epoch information for the provided epoch. If no epoch is provided, it will return the last known epoch.
epochTotalCheckpointsopen suspend override fun epochTotalCheckpoints(epoch: ULong?): ULong?
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).
epochTotalTransactionBlocksopen suspend override fun epochTotalTransactionBlocks(epoch: ULong?): ULong?
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).
eventsopen suspend override fun events(filter: EventFilter?, paginationFilter: PaginationFilter?): EventPage
Return a page of tuple (event, transaction digest) based on the (optional) event filter.
eventsSubscriptionopen suspend override fun eventsSubscription(filter: SubscriptionEventFilter?, startAfter: String?): EventSubscription
Subscribe to a live stream of events matching the (optional) filter.
executeTxopen suspend override fun executeTx(signatures: List<UserSignature>, tx: Transaction, waitFor: WaitForTx?): TransactionEffects
Execute a transaction.
gasCoinsopen suspend override fun gasCoins(owner: Address, paginationFilter: PaginationFilter?): CoinPage
Get the list of gas coins for the specified address.
iotaNamesDefaultNameopen suspend override fun iotaNamesDefaultName(address: Address, format: NameFormat?): Name?
Get the default name pointing to this address, if one exists.
iotaNamesLookupopen suspend override fun iotaNamesLookup(name: String): Address?
Return the resolved address for the given name.
iotaNamesRegistrationsopen suspend override fun iotaNamesRegistrations(address: Address, paginationFilter: PaginationFilter): NameRegistrationPage
Find all registration NFTs for the given address.
isTxFinalizedopen suspend override fun isTxFinalized(digest: TransactionDigest): Boolean
Returns whether the transaction for the given digest has been included in a checkpoint (finalized).
isTxIndexedOnNodeopen suspend override fun isTxIndexedOnNode(digest: TransactionDigest): Boolean
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.
latestCheckpointSequenceNumberopen suspend override fun latestCheckpointSequenceNumber(): ULong?
Return the sequence number of the latest checkpoint that has been executed.
maxPageSizeopen suspend override fun maxPageSize(): Int
Lazily fetch the max page size
moveObjectContentsopen suspend override fun moveObjectContents(objectId: ObjectId, version: Version?): Value?
Return the contents' JSON of an object that is a Move object.
moveObjectContentsBcsopen suspend override fun moveObjectContentsBcs(objectId: ObjectId, version: Version?): ByteArray?
Return the BCS of an object that is a Move object.
moveViewCallopen suspend override fun moveViewCall(functionName: String, typeArguments: List<TypeTag>?, arguments: List<MoveViewArg>?): MoveViewResult
Execute a Move View Function.
moveViewCallJsonopen suspend override fun moveViewCallJson(functionName: String, typeArguments: List<String>?, arguments: List<Value>?): MoveViewResult
Execute a Move View Function with raw JSON arguments.
normalizedMoveFunctionopen suspend override fun normalizedMoveFunction(package: Address, module: String, function: String, version: Version?): MoveFunction?
Return the normalized Move function data for the provided package, module, and function.
normalizedMoveModuleopen suspend override fun normalizedMoveModule(package: Address, module: String, version: Version?, paginationFilterEnums: PaginationFilter?, paginationFilterFriends: PaginationFilter?, paginationFilterFunctions: PaginationFilter?, paginationFilterStructs: PaginationFilter?): MoveModule?
Return the normalized Move module data for the provided module.
objectopen suspend override fun object(objectId: ObjectId, version: Version?): Object?
Return an object based on the provided Address.
objectBcsopen suspend override fun objectBcs(objectId: ObjectId): ByteArray?
Return the object's bcs content Vec<u8> based on the provided Address.
objectsopen suspend override fun objects(filter: ObjectFilter?, paginationFilter: PaginationFilter?): ObjectPage
Return a page of objects based on the provided parameters.
packageopen suspend override fun package(address: Address, version: Version?): MovePackage?
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.
packageLatestopen suspend override fun packageLatest(address: Address): MovePackage?
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.
packagesopen suspend override fun packages(afterCheckpoint: ULong?, beforeCheckpoint: ULong?, paginationFilter: PaginationFilter?): MovePackagePage
The Move packages that exist in the network, optionally filtered to be strictly before beforeCheckpoint and/or strictly after afterCheckpoint.
packageVersionsopen suspend override fun packageVersions(address: Address, afterVersion: Version?, beforeVersion: Version?, paginationFilter: PaginationFilter?): MovePackagePage
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.
protocolConfigopen suspend override fun protocolConfig(version: ULong?): ProtocolConfigs
Get the protocol configuration.
referenceGasPriceopen suspend override fun referenceGasPrice(epoch: ULong?): ULong?
Get the reference gas price for the provided epoch or the last known one if no epoch is provided.
runQueryopen suspend override fun runQuery(query: Query): Value
Run a query.
serviceConfigopen suspend override fun serviceConfig(): ServiceConfig
Get the GraphQL service configuration, including complexity limits, read and mutation limits, supported versions, and others.
setRpcServeropen suspend override fun setRpcServer(server: String)
Set the server address for the GraphQL client. It should be a valid URL with a host and optionally a port number.
totalSupplyopen suspend override fun totalSupply(coinType: String): ULong?
Get total supply for the coin type.
totalTransactionBlocksopen suspend override fun totalTransactionBlocks(): ULong?
The total number of transaction blocks in the network by the end of the last known checkpoint.
totalTransactionBlocksByDigestopen suspend override fun totalTransactionBlocksByDigest(digest: CheckpointDigest): ULong?
The total number of transaction blocks in the network by the end of the provided checkpoint digest.
totalTransactionBlocksBySeqNumopen suspend override fun totalTransactionBlocksBySeqNum(seqNum: ULong): ULong?
The total number of transaction blocks in the network by the end of the provided checkpoint sequence number.
transactionopen suspend override fun transaction(digest: TransactionDigest): SignedTransaction?
Get a transaction by its digest.
transactionBuilderopen override fun transactionBuilder(sender: Address): ClientTransactionBuilder
Create a new TransactionBuilder with the given sender address.
transactionDataEffectsopen suspend override fun transactionDataEffects(digest: TransactionDigest): TransactionDataEffects?
Get a transaction's data and effects by its digest.
transactionEffectsopen suspend override fun transactionEffects(digest: TransactionDigest): TransactionEffects?
Get a transaction's effects by its digest.
transactionsopen suspend override fun transactions(filter: TransactionsFilter?, paginationFilter: PaginationFilter?): SignedTransactionPage
Get a page of transactions based on the provided filters.
transactionsDataEffectsopen suspend override fun transactionsDataEffects(filter: TransactionsFilter?, paginationFilter: PaginationFilter?): TransactionDataEffectsPage
Get a page of transactions' data and effects based on the provided filters.
transactionsEffectsopen suspend override fun transactionsEffects(filter: TransactionsFilter?, paginationFilter: PaginationFilter?): TransactionEffectsPage
Get a page of transactions' effects based on the provided filters.
transactionsSubscriptionopen suspend override fun transactionsSubscription(filter: SubscriptionTransactionFilter?, startAfter: String?): TransactionSubscription
Subscribe to a live stream of transactions matching the (optional) filter.
waitForTxopen suspend override fun waitForTx(digest: TransactionDigest, waitFor: WaitForTx, timeout: Duration?)
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).

Companion object functions

NameSummary
newDevnetfun newDevnet(): GraphQlClient
Create a new GraphQL client connected to the devnet GraphQL server: {DEVNET_HOST}.
newLocalnetfun newLocalnet(): GraphQlClient
Create a new GraphQL client connected to the localhost GraphQL server: {DEFAULT_LOCAL_HOST}.
newMainnetfun newMainnet(): GraphQlClient
Create a new GraphQL client connected to the mainnet GraphQL server: {MAINNET_HOST}.
newTestnetfun newTestnet(): GraphQlClient
Create a new GraphQL client connected to the testnet GraphQL server: {TESTNET_HOST}.