Skip to main content

Interface: GraphQlClientLike

The GraphQL client for interacting with the IOTA blockchain.

Methods

activeValidators()

activeValidators(
epoch,
paginationFilter,
asyncOpts_?
): Promise<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.

Parameters

epoch

bigint | undefined

paginationFilter

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<ValidatorPage>


balance()

balance(
address,
coinType,
asyncOpts_?
): Promise<bigint | undefined>;

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.

Parameters

address

AddressLike

coinType

string | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<bigint | undefined>


chainId()

chainId(asyncOpts_?): Promise<string>;

Get the chain identifier.

Parameters

asyncOpts_?
signal

AbortSignal

Returns

Promise<string>


checkpoint()

checkpoint(
digest,
seqNum,
asyncOpts_?
): Promise<
| CheckpointSummaryLike
| undefined>;

Get the CheckpointSummary for a given checkpoint digest or checkpoint id. If none is provided, it will use the last known checkpoint id.

Parameters

digest

CheckpointDigestLike | undefined

seqNum

bigint | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise< | CheckpointSummaryLike | undefined>


checkpoints()

checkpoints(paginationFilter, asyncOpts_?): Promise<CheckpointSummaryPage>;

Get a page of CheckpointSummary for the provided parameters.

Parameters

paginationFilter

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<CheckpointSummaryPage>


coinMetadata()

coinMetadata(coinType, asyncOpts_?): Promise<CoinMetadata | undefined>;

Get the coin metadata for the coin type.

Parameters

coinType

string

asyncOpts_?
signal

AbortSignal

Returns

Promise<CoinMetadata | undefined>


coins()

coins(
owner,
paginationFilter,
coinType,
asyncOpts_?
): Promise<CoinPage>;

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.

Parameters

owner

AddressLike

paginationFilter

PaginationFilter | undefined

coinType

StructTagLike | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<CoinPage>


dryRunTx()

dryRunTx(
tx,
skipChecks,
asyncOpts_?
): Promise<DryRunResult>;

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.

Parameters

tx

TransactionLike

skipChecks

boolean

asyncOpts_?
signal

AbortSignal

Returns

Promise<DryRunResult>


dryRunTxKind()

dryRunTxKind(
txKind,
txMeta,
skipChecks,
asyncOpts_?
): Promise<DryRunResult>;

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.

Parameters

txKind

TransactionKindLike

txMeta

TransactionMetadata

skipChecks

boolean

asyncOpts_?
signal

AbortSignal

Returns

Promise<DryRunResult>


dynamicField()

dynamicField(
address,
typeTag,
name,
asyncOpts_?
): Promise<DynamicFieldOutput | undefined>;

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.

Parameters

address

AddressLike

typeTag

TypeTagLike

name

string

asyncOpts_?
signal

AbortSignal

Returns

Promise<DynamicFieldOutput | undefined>


dynamicFields()

dynamicFields(
address,
paginationFilter,
asyncOpts_?
): Promise<DynamicFieldOutputPage>;

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.

Parameters

address

AddressLike

paginationFilter

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<DynamicFieldOutputPage>


dynamicObjectField()

dynamicObjectField(
address,
typeTag,
name,
asyncOpts_?
): Promise<DynamicFieldOutput | undefined>;

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.

Parameters

address

AddressLike

typeTag

TypeTagLike

name

string

asyncOpts_?
signal

AbortSignal

Returns

Promise<DynamicFieldOutput | undefined>


epoch()

epoch(epoch, asyncOpts_?): Promise<Epoch | undefined>;

Return the epoch information for the provided epoch. If no epoch is provided, it will return the last known epoch.

Parameters

epoch

bigint | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<Epoch | undefined>


epochTotalCheckpoints()

epochTotalCheckpoints(epoch, asyncOpts_?): Promise<bigint | undefined>;

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).

Parameters

epoch

bigint | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<bigint | undefined>


epochTotalTransactionBlocks()

epochTotalTransactionBlocks(epoch, asyncOpts_?): Promise<bigint | undefined>;

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).

Parameters

epoch

bigint | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<bigint | undefined>


events()

events(
filter,
paginationFilter,
asyncOpts_?
): Promise<EventPage>;

Return a page of tuple (event, transaction digest) based on the (optional) event filter.

Parameters

filter

EventFilter | undefined

paginationFilter

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<EventPage>


eventsSubscription()

eventsSubscription(
filter,
startAfter,
asyncOpts_?
): Promise<EventSubscriptionLike>;

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.

Parameters

filter

| SubscriptionEventFilter | undefined

startAfter

string | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<EventSubscriptionLike>


executeTx()

executeTx(
signatures,
tx,
waitFor,
asyncOpts_?
): Promise<TransactionEffectsLike>;

Execute a transaction.

Parameters

signatures

UserSignatureLike[]

tx

TransactionLike

waitFor

WaitForTx | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<TransactionEffectsLike>


gasCoins()

gasCoins(
owner,
paginationFilter,
asyncOpts_?
): Promise<CoinPage>;

Get the list of gas coins for the specified address.

Parameters

owner

AddressLike

paginationFilter

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<CoinPage>


iotaNamesDefaultName()

iotaNamesDefaultName(
address,
format,
asyncOpts_?
): Promise<NameLike | undefined>;

Get the default name pointing to this address, if one exists.

Parameters

address

AddressLike

format

NameFormat | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<NameLike | undefined>


iotaNamesLookup()

iotaNamesLookup(name, asyncOpts_?): Promise<AddressLike | undefined>;

Return the resolved address for the given name.

Parameters

name

string

asyncOpts_?
signal

AbortSignal

Returns

Promise<AddressLike | undefined>


iotaNamesRegistrations()

iotaNamesRegistrations(
address,
paginationFilter,
asyncOpts_?
): Promise<NameRegistrationPage>;

Find all registration NFTs for the given address.

Parameters

address

AddressLike

paginationFilter

PaginationFilter

asyncOpts_?
signal

AbortSignal

Returns

Promise<NameRegistrationPage>


isTxFinalized()

isTxFinalized(digest, asyncOpts_?): Promise<boolean>;

Returns whether the transaction for the given digest has been included in a checkpoint (finalized).

Parameters

digest

TransactionDigestLike

asyncOpts_?
signal

AbortSignal

Returns

Promise<boolean>


isTxIndexedOnNode()

isTxIndexedOnNode(digest, asyncOpts_?): Promise<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.

Parameters

digest

TransactionDigestLike

asyncOpts_?
signal

AbortSignal

Returns

Promise<boolean>


latestCheckpointSequenceNumber()

latestCheckpointSequenceNumber(asyncOpts_?): Promise<bigint | undefined>;

Return the sequence number of the latest checkpoint that has been executed.

Parameters

asyncOpts_?
signal

AbortSignal

Returns

Promise<bigint | undefined>


maxPageSize()

maxPageSize(asyncOpts_?): Promise<number>;

Lazily fetch the max page size

Parameters

asyncOpts_?
signal

AbortSignal

Returns

Promise<number>


moveObjectContents()

moveObjectContents(
objectId,
version,
asyncOpts_?
): Promise<string | undefined>;

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).

Parameters

objectId

ObjectIdLike

version

VersionLike | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<string | undefined>


moveObjectContentsBcs()

moveObjectContentsBcs(
objectId,
version,
asyncOpts_?
): Promise<ArrayBuffer | undefined>;

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).

Parameters

objectId

ObjectIdLike

version

VersionLike | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<ArrayBuffer | undefined>


moveViewCall()

moveViewCall(
functionName,
typeArguments,
moveArguments,
asyncOpts_?
): Promise<MoveViewResult>;

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

  • function_name - The Move function fully qualified name as <package_id>::<module_name>::<function_name>, e.g., 0x2::hash::blake2b256
  • type_arguments - The type arguments of the Move function
  • arguments - The typed arguments to be passed into the Move function

Returns

A MoveViewResult containing either execution results (return values) or an error.

Parameters

functionName

string

typeArguments

TypeTagLike[] | undefined

moveArguments

MoveViewArgLike[] | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<MoveViewResult>


moveViewCallJson()

moveViewCallJson(
functionName,
typeArguments,
moveArguments,
asyncOpts_?
): Promise<MoveViewResult>;

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

  • function_name - The Move function fully qualified name as <package_id>::<module_name>::<function_name>, e.g., 0x2::hash::blake2b256
  • type_arguments - The type arguments of the Move function
  • arguments - The arguments to be passed into the Move function, in JSON format

Returns

A MoveViewResult containing either execution results (return values) or an error.

Parameters

functionName

string

typeArguments

string[] | undefined

moveArguments

string[] | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<MoveViewResult>


normalizedMoveFunction()

normalizedMoveFunction(
package_,
module,
function_,
version,
asyncOpts_?
): Promise<MoveFunctionLike | undefined>;

Return the normalized Move function data for the provided package, module, and function.

Parameters

package_

AddressLike

module

string

function_

string

version

VersionLike | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<MoveFunctionLike | undefined>


normalizedMoveModule()

normalizedMoveModule(
package_,
module,
version,
paginationFilterEnums,
paginationFilterFriends,
paginationFilterFunctions,
paginationFilterStructs,
asyncOpts_?
): Promise<MoveModule | undefined>;

Return the normalized Move module data for the provided module.

Parameters

package_

AddressLike

module

string

version

VersionLike | undefined

paginationFilterEnums

PaginationFilter | undefined

paginationFilterFriends

PaginationFilter | undefined

paginationFilterFunctions

PaginationFilter | undefined

paginationFilterStructs

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<MoveModule | undefined>


object()

object(
objectId,
version,
asyncOpts_?
): Promise<ObjectLike | undefined>;

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).

Parameters

objectId

ObjectIdLike

version

VersionLike | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<ObjectLike | undefined>


objectBcs()

objectBcs(objectId, asyncOpts_?): Promise<ArrayBuffer | undefined>;

Return the object's bcs content Vec<u8> based on the provided Address.

Parameters

objectId

ObjectIdLike

asyncOpts_?
signal

AbortSignal

Returns

Promise<ArrayBuffer | undefined>


objects()

objects(
filter,
paginationFilter,
asyncOpts_?
): Promise<ObjectPage>;

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.

Parameters

filter

ObjectFilter | undefined

paginationFilter

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<ObjectPage>


package_()

package_(
address,
version,
asyncOpts_?
): Promise<MovePackageLike | undefined>;

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).

Parameters

address

AddressLike

version

VersionLike | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<MovePackageLike | undefined>


packageLatest()

packageLatest(address, asyncOpts_?): Promise<MovePackageLike | undefined>;

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.

Parameters

address

AddressLike

asyncOpts_?
signal

AbortSignal

Returns

Promise<MovePackageLike | undefined>


packages()

packages(
afterCheckpoint,
beforeCheckpoint,
paginationFilter,
asyncOpts_?
): Promise<MovePackagePage>;

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.

Parameters

afterCheckpoint

bigint | undefined

beforeCheckpoint

bigint | undefined

paginationFilter

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<MovePackagePage>


packageVersions()

packageVersions(
address,
afterVersion,
beforeVersion,
paginationFilter,
asyncOpts_?
): Promise<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.

Parameters

address

AddressLike

afterVersion

VersionLike | undefined

beforeVersion

VersionLike | undefined

paginationFilter

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<MovePackagePage>


protocolConfig()

protocolConfig(version, asyncOpts_?): Promise<ProtocolConfigs>;

Get the protocol configuration.

Parameters

version

bigint | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<ProtocolConfigs>


referenceGasPrice()

referenceGasPrice(epoch, asyncOpts_?): Promise<bigint | undefined>;

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).

Parameters

epoch

bigint | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<bigint | undefined>


runQuery()

runQuery(query, asyncOpts_?): Promise<string>;

Run a query.

Parameters

query

Query

asyncOpts_?
signal

AbortSignal

Returns

Promise<string>


serviceConfig()

serviceConfig(asyncOpts_?): Promise<ServiceConfig>;

Get the GraphQL service configuration, including complexity limits, read and mutation limits, supported versions, and others.

Parameters

asyncOpts_?
signal

AbortSignal

Returns

Promise<ServiceConfig>


setRpcServer()

setRpcServer(server, asyncOpts_?): Promise<void>;

Set the server address for the GraphQL client. It should be a valid URL with a host and optionally a port number.

Parameters

server

string

asyncOpts_?
signal

AbortSignal

Returns

Promise<void>


totalSupply()

totalSupply(coinType, asyncOpts_?): Promise<bigint | undefined>;

Get total supply for the coin type.

Parameters

coinType

string

asyncOpts_?
signal

AbortSignal

Returns

Promise<bigint | undefined>


totalTransactionBlocks()

totalTransactionBlocks(asyncOpts_?): Promise<bigint | undefined>;

The total number of transaction blocks in the network by the end of the last known checkpoint.

Parameters

asyncOpts_?
signal

AbortSignal

Returns

Promise<bigint | undefined>


totalTransactionBlocksByDigest()

totalTransactionBlocksByDigest(digest, asyncOpts_?): Promise<bigint | undefined>;

The total number of transaction blocks in the network by the end of the provided checkpoint digest.

Parameters

digest

CheckpointDigestLike

asyncOpts_?
signal

AbortSignal

Returns

Promise<bigint | undefined>


totalTransactionBlocksBySeqNum()

totalTransactionBlocksBySeqNum(seqNum, asyncOpts_?): Promise<bigint | undefined>;

The total number of transaction blocks in the network by the end of the provided checkpoint sequence number.

Parameters

seqNum

bigint

asyncOpts_?
signal

AbortSignal

Returns

Promise<bigint | undefined>


transaction()

transaction(digest, asyncOpts_?): Promise<SignedTransaction | undefined>;

Get a transaction by its digest.

Parameters

digest

TransactionDigestLike

asyncOpts_?
signal

AbortSignal

Returns

Promise<SignedTransaction | undefined>


transactionBuilder()

transactionBuilder(sender): ClientTransactionBuilderLike;

Create a new TransactionBuilder with the given sender address.

Parameters

sender

AddressLike

Returns

ClientTransactionBuilderLike


transactionDataEffects()

transactionDataEffects(digest, asyncOpts_?): Promise<
| TransactionDataEffects
| undefined>;

Get a transaction's data and effects by its digest.

Parameters

digest

TransactionDigestLike

asyncOpts_?
signal

AbortSignal

Returns

Promise< | TransactionDataEffects | undefined>


transactionEffects()

transactionEffects(digest, asyncOpts_?): Promise<
| TransactionEffectsLike
| undefined>;

Get a transaction's effects by its digest.

Parameters

digest

TransactionDigestLike

asyncOpts_?
signal

AbortSignal

Returns

Promise< | TransactionEffectsLike | undefined>


transactions()

transactions(
filter,
paginationFilter,
asyncOpts_?
): Promise<SignedTransactionPage>;

Get a page of transactions based on the provided filters.

Parameters

filter

TransactionsFilter | undefined

paginationFilter

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<SignedTransactionPage>


transactionsDataEffects()

transactionsDataEffects(
filter,
paginationFilter,
asyncOpts_?
): Promise<TransactionDataEffectsPage>;

Get a page of transactions' data and effects based on the provided filters.

Parameters

filter

TransactionsFilter | undefined

paginationFilter

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<TransactionDataEffectsPage>


transactionsEffects()

transactionsEffects(
filter,
paginationFilter,
asyncOpts_?
): Promise<TransactionEffectsPage>;

Get a page of transactions' effects based on the provided filters.

Parameters

filter

TransactionsFilter | undefined

paginationFilter

PaginationFilter | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<TransactionEffectsPage>


transactionsSubscription()

transactionsSubscription(
filter,
startAfter,
asyncOpts_?
): Promise<TransactionSubscriptionLike>;

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.

Parameters

filter

| SubscriptionTransactionFilter | undefined

startAfter

string | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<TransactionSubscriptionLike>


waitForTx()

waitForTx(
digest,
waitFor,
timeout,
asyncOpts_?
): Promise<void>;

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).

Parameters

digest

TransactionDigestLike

waitFor

WaitForTx

timeout

number | undefined

asyncOpts_?
signal

AbortSignal

Returns

Promise<void>