GraphQlClient
type GraphQlClient
The GraphQL client for interacting with the IOTA blockchain.
type GraphQlClient struct {
// contains filtered or unexported fields
}
func GraphQlClientNewDevnet
func GraphQlClientNewDevnet() *GraphQlClient
Create a new GraphQL client connected to the `devnet` GraphQL server: {DEVNET_HOST}.
func GraphQlClientNewLocalnet
func GraphQlClientNewLocalnet() *GraphQlClient
Create a new GraphQL client connected to the `localhost` GraphQL server: {DEFAULT_LOCAL_HOST}.
func GraphQlClientNewMainnet
func GraphQlClientNewMainnet() *GraphQlClient
Create a new GraphQL client connected to the `mainnet` GraphQL server: {MAINNET_HOST}.
func GraphQlClientNewTestnet
func GraphQlClientNewTestnet() *GraphQlClient
Create a new GraphQL client connected to the `testnet` GraphQL server: {TESTNET_HOST}.
func LiftFromExternalGraphQlClient
func LiftFromExternalGraphQlClient(handle uint64) *GraphQlClient
func NewGraphQlClient
func NewGraphQlClient(server string) (*GraphQlClient, error)
Create a new GraphQL client with the provided server address.
func (*GraphQlClient) ActiveValidators
func (_self *GraphQlClient) ActiveValidators(epoch *uint64, paginationFilter *PaginationFilter) (ValidatorPage, error)
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.
func (*GraphQlClient) Balance
func (_self *GraphQlClient) Balance(address *Address, coinType *string) (*uint64, error)
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.
func (*GraphQlClient) ChainId
func (_self *GraphQlClient) ChainId() (string, error)
Get the chain identifier.
func (*GraphQlClient) Checkpoint
func (_self *GraphQlClient) Checkpoint(digest **CheckpointDigest, seqNum *uint64) (**CheckpointSummary, error)
Get the `CheckpointSummary` for a given checkpoint digest or checkpoint id. If none is provided, it will use the last known checkpoint id.
func (*GraphQlClient) Checkpoints
func (_self *GraphQlClient) Checkpoints(paginationFilter *PaginationFilter) (CheckpointSummaryPage, error)
Get a page of `CheckpointSummary` for the provided parameters.
func (*GraphQlClient) CoinMetadata
func (_self *GraphQlClient) CoinMetadata(coinType string) (*CoinMetadata, error)
Get the coin metadata for the coin type.
func (*GraphQlClient) Coins
func (_self *GraphQlClient) Coins(owner *Address, paginationFilter *PaginationFilter, coinType **StructTag) (CoinPage, error)
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`.
func (*GraphQlClient) Destroy
func (object *GraphQlClient) Destroy()
func (*GraphQlClient) DryRunTx
func (_self *GraphQlClient) DryRunTx(tx *Transaction, skipChecks bool) (DryRunResult, error)
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.
func (*GraphQlClient) DryRunTxKind
func (_self *GraphQlClient) DryRunTxKind(txKind *TransactionKind, txMeta TransactionMetadata, skipChecks bool) (DryRunResult, error)
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.
func (*GraphQlClient) DynamicField
func (_self *GraphQlClient) DynamicField(address *Address, typeTag *TypeTag, name Value) (*DynamicFieldOutput, error)
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.
func (*GraphQlClient) DynamicFields
func (_self *GraphQlClient) DynamicFields(address *Address, paginationFilter *PaginationFilter) (DynamicFieldOutputPage, error)
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 `DynamicFieldOutput`s.
func (*GraphQlClient) DynamicObjectField
func (_self *GraphQlClient) DynamicObjectField(address *Address, typeTag *TypeTag, name Value) (*DynamicFieldOutput, error)
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.
func (*GraphQlClient) Epoch
func (_self *GraphQlClient) Epoch(epoch *uint64) (*Epoch, error)
Return the epoch information for the provided epoch. If no epoch is provided, it will return the last known epoch.
func (*GraphQlClient) EpochTotalCheckpoints
func (_self *GraphQlClient) EpochTotalCheckpoints(epoch *uint64) (*uint64, error)
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).
func (*GraphQlClient) EpochTotalTransactionBlocks
func (_self *GraphQlClient) EpochTotalTransactionBlocks(epoch *uint64) (*uint64, error)
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).
func (*GraphQlClient) Events
func (_self *GraphQlClient) Events(filter *EventFilter, paginationFilter *PaginationFilter) (EventPage, error)
Return a page of tuple (event, transaction digest) based on the (optional) event filter.
func (*GraphQlClient) EventsSubscription
func (_self *GraphQlClient) EventsSubscription(filter *SubscriptionEventFilter, startAfter *string) *EventSubscription
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.
func (*GraphQlClient) ExecuteTx
func (_self *GraphQlClient) ExecuteTx(signatures []*UserSignature, tx *Transaction, waitFor *WaitForTx) (*TransactionEffects, error)
Execute a transaction.
func (*GraphQlClient) GasCoins
func (_self *GraphQlClient) GasCoins(owner *Address, paginationFilter *PaginationFilter) (CoinPage, error)
Get the list of gas coins for the specified address.
func (*GraphQlClient) IotaNamesDefaultName
func (_self *GraphQlClient) IotaNamesDefaultName(address *Address, format *NameFormat) (**Name, error)
Get the default name pointing to this address, if one exists.
func (*GraphQlClient) IotaNamesLookup
func (_self *GraphQlClient) IotaNamesLookup(name string) (**Address, error)
Return the resolved address for the given name.
func (*GraphQlClient) IotaNamesRegistrations
func (_self *GraphQlClient) IotaNamesRegistrations(address *Address, paginationFilter PaginationFilter) (NameRegistrationPage, error)
Find all registration NFTs for the given address.
func (*GraphQlClient) IsTxFinalized
func (_self *GraphQlClient) IsTxFinalized(digest *TransactionDigest) (bool, error)
Returns whether the transaction for the given digest has been included in a checkpoint (finalized).
func (*GraphQlClient) IsTxIndexedOnNode
func (_self *GraphQlClient) IsTxIndexedOnNode(digest *TransactionDigest) (bool, error)
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`.
func (*GraphQlClient) LatestCheckpointSequenceNumber
func (_self *GraphQlClient) LatestCheckpointSequenceNumber() (*uint64, error)
Return the sequence number of the latest checkpoint that has been executed.
func (*GraphQlClient) MaxPageSize
func (_self *GraphQlClient) MaxPageSize() (int32, error)
Lazily fetch the max page size
func (*GraphQlClient) MoveObjectContents
func (_self *GraphQlClient) MoveObjectContents(objectId *ObjectId, version **Version) (*Value, error)
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)`.
func (*GraphQlClient) MoveObjectContentsBcs
func (_self *GraphQlClient) MoveObjectContentsBcs(objectId *ObjectId, version **Version) (*[]byte, error)
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)`.
func (*GraphQlClient) MoveViewCall
func (_self *GraphQlClient) MoveViewCall(functionName string, typeArguments *[]*TypeTag, arguments *[]*MoveViewArg) (MoveViewResult, error)
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:#️⃣: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.
func (*GraphQlClient) MoveViewCallJson
func (_self *GraphQlClient) MoveViewCallJson(functionName string, typeArguments *[]string, arguments *[]Value) (MoveViewResult, error)
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:#️⃣: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.
func (*GraphQlClient) NormalizedMoveFunction
func (_self *GraphQlClient) NormalizedMoveFunction(varPackage *Address, module string, function string, version **Version) (**MoveFunction, error)
Return the normalized Move function data for the provided package, module, and function.
func (*GraphQlClient) NormalizedMoveModule
func (_self *GraphQlClient) NormalizedMoveModule(varPackage *Address, module string, version **Version, paginationFilterEnums *PaginationFilter, paginationFilterFriends *PaginationFilter, paginationFilterFunctions *PaginationFilter, paginationFilterStructs *PaginationFilter) (*MoveModule, error)
Return the normalized Move module data for the provided module.
func (*GraphQlClient) Object
func (_self *GraphQlClient) Object(objectId *ObjectId, version **Version) (**Object, error)
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)`.
func (*GraphQlClient) ObjectBcs
func (_self *GraphQlClient) ObjectBcs(objectId *ObjectId) (*[]byte, error)
Return the object's bcs content `Vec<u8>` based on the provided `Address`.
func (*GraphQlClient) Objects
func (_self *GraphQlClient) Objects(filter *ObjectFilter, paginationFilter *PaginationFilter) (ObjectPage, error)
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.
func (*GraphQlClient) Package
func (_self *GraphQlClient) Package(address *Address, version **Version) (**MovePackage, error)
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).
func (*GraphQlClient) PackageLatest
func (_self *GraphQlClient) PackageLatest(address *Address) (**MovePackage, error)
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.
func (*GraphQlClient) PackageVersions
func (_self *GraphQlClient) PackageVersions(address *Address, afterVersion **Version, beforeVersion **Version, paginationFilter *PaginationFilter) (MovePackagePage, error)
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.
func (*GraphQlClient) Packages
func (_self *GraphQlClient) Packages(afterCheckpoint *uint64, beforeCheckpoint *uint64, paginationFilter *PaginationFilter) (MovePackagePage, error)
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.
func (*GraphQlClient) ProtocolConfig
func (_self *GraphQlClient) ProtocolConfig(version *uint64) (ProtocolConfigs, error)
Get the protocol configuration.
func (*GraphQlClient) ReferenceGasPrice
func (_self *GraphQlClient) ReferenceGasPrice(epoch *uint64) (*uint64, error)
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).
func (*GraphQlClient) RunQuery
func (_self *GraphQlClient) RunQuery(query Query) (Value, error)
Run a query.
func (*GraphQlClient) ServiceConfig
func (_self *GraphQlClient) ServiceConfig() (ServiceConfig, error)
Get the GraphQL service configuration, including complexity limits, read and mutation limits, supported versions, and others.
func (*GraphQlClient) SetRpcServer
func (_self *GraphQlClient) SetRpcServer(server string) error
Set the server address for the GraphQL client. It should be a valid URL with a host and optionally a port number.
func (*GraphQlClient) TotalSupply
func (_self *GraphQlClient) TotalSupply(coinType string) (*uint64, error)
Get total supply for the coin type.
func (*GraphQlClient) TotalTransactionBlocks
func (_self *GraphQlClient) TotalTransactionBlocks() (*uint64, error)
The total number of transaction blocks in the network by the end of the last known checkpoint.
func (*GraphQlClient) TotalTransactionBlocksByDigest
func (_self *GraphQlClient) TotalTransactionBlocksByDigest(digest *CheckpointDigest) (*uint64, error)
The total number of transaction blocks in the network by the end of the provided checkpoint digest.
func (*GraphQlClient) TotalTransactionBlocksBySeqNum
func (_self *GraphQlClient) TotalTransactionBlocksBySeqNum(seqNum uint64) (*uint64, error)
The total number of transaction blocks in the network by the end of the provided checkpoint sequence number.
func (*GraphQlClient) Transaction
func (_self *GraphQlClient) Transaction(digest *TransactionDigest) (*SignedTransaction, error)
Get a transaction by its digest.
func (*GraphQlClient) TransactionBuilder
func (_self *GraphQlClient) TransactionBuilder(sender *Address) *ClientTransactionBuilder
Create a new `TransactionBuilder` with the given sender address.
func (*GraphQlClient) TransactionDataEffects
func (_self *GraphQlClient) TransactionDataEffects(digest *TransactionDigest) (*TransactionDataEffects, error)
Get a transaction's data and effects by its digest.
func (*GraphQlClient) TransactionEffects
func (_self *GraphQlClient) TransactionEffects(digest *TransactionDigest) (**TransactionEffects, error)
Get a transaction's effects by its digest.
func (*GraphQlClient) Transactions
func (_self *GraphQlClient) Transactions(filter *TransactionsFilter, paginationFilter *PaginationFilter) (SignedTransactionPage, error)
Get a page of transactions based on the provided filters.
func (*GraphQlClient) TransactionsDataEffects
func (_self *GraphQlClient) TransactionsDataEffects(filter *TransactionsFilter, paginationFilter *PaginationFilter) (TransactionDataEffectsPage, error)
Get a page of transactions' data and effects based on the provided filters.
func (*GraphQlClient) TransactionsEffects
func (_self *GraphQlClient) TransactionsEffects(filter *TransactionsFilter, paginationFilter *PaginationFilter) (TransactionEffectsPage, error)
Get a page of transactions' effects based on the provided filters.
func (*GraphQlClient) TransactionsSubscription
func (_self *GraphQlClient) TransactionsSubscription(filter *SubscriptionTransactionFilter, startAfter *string) *TransactionSubscription
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.
func (*GraphQlClient) WaitForTx
func (_self *GraphQlClient) WaitForTx(digest *TransactionDigest, waitFor WaitForTx, timeout *time.Duration) error
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).