Skip to main content

GrpcClientInterface

type GrpcClientInterface​

The gRPC client for interacting with the IOTA blockchain.

type GrpcClientInterface interface {
// Execute a signed transaction.
//
// If `checkpoint_inclusion_timeout_ms` is provided, the server waits up to that long for the
// transaction to be included in a checkpoint before responding. Include `checkpoint` and
// `timestamp` in the `read_mask` to receive that data.
//
// The optional `read_mask` controls which fields the server returns. If `None`, the
// transaction digest, effects, events, and input/output objects are returned.
ExecuteTransaction(signedTransaction SignedTransaction, checkpointInclusionTimeoutMs *uint64, readMask *[]GrpcTransactionField) (GrpcExecutedTransaction, error)
// Execute a batch of signed transactions.
//
// An error the server reports for one transaction does not abort the rest of the batch;
// reading that transaction's item throws the server's error message. A transaction the server
// returns but that cannot be decoded fails the whole call.
//
// If `checkpoint_inclusion_timeout_ms` is provided, the server waits up to that long for the
// transactions to be included in a checkpoint before responding. Include `checkpoint` and
// `timestamp` in the `read_mask` to receive that data.
//
// The optional `read_mask` controls which fields the server returns. If `None`, the
// transaction digest, effects, events, and input/output objects are returned.
ExecuteTransactions(transactions []SignedTransaction, checkpointInclusionTimeoutMs *uint64, readMask *[]GrpcTransactionField) (*GrpcExecutedTransactionResults, error)
// Simulate a transaction.
//
// If `skip_checks` is `true`, the VM checks are skipped during the simulation.
//
// The optional `read_mask` controls which fields the server returns.
SimulateTransaction(transaction *Transaction, skipChecks bool, readMask *[]GrpcSimulateField) (GrpcSimulatedTransaction, error)
// Simulate a batch of transactions.
//
// An error the server reports for one transaction does not abort the rest of the batch; each
// result carries either the simulated transaction or the server's error message. A transaction
// the server returns but that cannot be decoded fails the whole call.
SimulateTransactions(transactions []GrpcSimulateTransactionInput, readMask *[]GrpcSimulateField) ([]GrpcSimulatedTransactionResult, error)
// Call a Move view function and read back what it returns, without submitting a transaction.
//
// Only a function declared with the `#[view]` attribute can be called this way.
// `fq_function_name` is the fully qualified name `<package>::<module>::<function>`.
//
// A call that ran and aborted is not an error: the abort is reported in the `execution_error`
// field of the outputs. The call fails only if the node refused to run it (unknown function,
// wrong argument count, not a view function).
//
// The optional `read_mask` controls which fields the server returns.
ViewFunctionCall(fqFunctionName string, typeArgs []*TypeTag, callArgs []*MoveViewArg, readMask *[]GrpcViewFunctionCallField) (GrpcViewFunctionCallOutputs, error)
// Call a batch of Move view functions.
//
// Each call runs in its own transaction on the server, so one call being rejected leaves the
// rest untouched. Results are returned in the same order as the input; each result carries
// either the outputs of the call or the error the node returned for it. A call that ran and
// aborted lands in `outputs`, with the abort in its `execution_error` field.
//
// The optional `read_mask` controls which fields the server returns.
ViewFunctionCalls(functionCalls []GrpcViewFunctionCallInput, readMask *[]GrpcViewFunctionCallField) ([]GrpcViewFunctionCallResult, error)
// Get a checkpoint by its digest.
//
// The optional `transactions_filter` and `events_filter` narrow the transactions and events
// returned for the checkpoint.
//
// The optional `read_mask` controls which fields the server returns.
// If `None`, only the checkpoint summary is returned.
CheckpointByDigest(digest *CheckpointDigest, transactionsFilter **GrpcTransactionFilter, eventsFilter **GrpcEventFilter, readMask *[]GrpcCheckpointResponseField) (GrpcCheckpointResponse, error)
// Get a checkpoint by its sequence number.
//
// The optional `transactions_filter` and `events_filter` narrow the transactions and events
// returned for the checkpoint.
//
// The optional `read_mask` controls which fields the server returns.
// If `None`, only the checkpoint summary is returned.
CheckpointBySequenceNumber(sequenceNumber uint64, transactionsFilter **GrpcTransactionFilter, eventsFilter **GrpcEventFilter, readMask *[]GrpcCheckpointResponseField) (GrpcCheckpointResponse, error)
// Get the latest checkpoint.
//
// The optional `transactions_filter` and `events_filter` narrow the transactions and events
// returned for the checkpoint.
//
// The optional `read_mask` controls which fields the server returns.
// If `None`, only the checkpoint summary is returned.
CheckpointLatest(transactionsFilter **GrpcTransactionFilter, eventsFilter **GrpcEventFilter, readMask *[]GrpcCheckpointResponseField) (GrpcCheckpointResponse, error)
// Stream checkpoints across a range of sequence numbers.
//
// Every checkpoint in the range is yielded, even if the filters produce no matching
// transactions or events within it.
//
// If `start_sequence_number` is `None`, the stream starts from the latest checkpoint. If
// `end_sequence_number` is `None`, the stream continues indefinitely.
//
// The optional `transactions_filter` and `events_filter` narrow the transactions and events
// returned for each checkpoint.
//
// The optional `read_mask` controls which fields the server returns for each checkpoint. If
// `None`, only the checkpoint summary is returned.
CheckpointsStream(startSequenceNumber *uint64, endSequenceNumber *uint64, transactionsFilter **GrpcTransactionFilter, eventsFilter **GrpcEventFilter, readMask *[]GrpcCheckpointResponseField) (*GrpcCheckpointStream, error)
// Stream checkpoints across a range of sequence numbers, skipping checkpoints with no data
// matching the filters.
//
// Unlike [`GrpcClient::checkpoints_stream`], the filters decide which checkpoints are returned
// at all; checkpoints without any matching transactions or events are skipped entirely. At
// least one of `transactions_filter` or `events_filter` must be set.
//
// While the server scans non-matching checkpoints, the stream yields progress items indicating
// the current scan position (default every 2000ms, configurable via `progress_interval_ms`,
// minimum 500ms).
//
// If `start_sequence_number` is `None`, the stream starts from the latest checkpoint. If
// `end_sequence_number` is `None`, the stream continues indefinitely.
//
// The optional `read_mask` controls which fields the server returns for each checkpoint. If
// `None`, only the checkpoint summary is returned.
CheckpointsStreamFiltered(startSequenceNumber *uint64, endSequenceNumber *uint64, transactionsFilter **GrpcTransactionFilter, eventsFilter **GrpcEventFilter, progressIntervalMs *uint32, readMask *[]GrpcCheckpointResponseField) (*GrpcFilteredCheckpointStream, error)
// Get information about an epoch. If `epoch` is `None`, the current epoch is returned.
//
// The optional `read_mask` controls which fields the server returns.
Epoch(epoch *uint64, readMask *[]GrpcEpochField) (GrpcEpochInfo, error)
// Get the reference gas price of the current epoch, denominated in NANOS.
ReferenceGasPrice() (uint64, error)
// Get the health of the node serving the gRPC service.
//
// If `threshold_ms` is provided, the server returns an `UNAVAILABLE` error when the most
// recently executed checkpoint is older than the threshold.
Health(thresholdMs *uint64) (GrpcHealthInfo, error)
// Get the latest version of objects by their ids.
//
// Results are returned in the same order as the input ids, one per id. An object the serving
// node cannot return — because it is not found, was deleted, or has been pruned — fails only
// its own item, which reading throws with the server's error message. An object the server
// returns but that cannot be decoded fails the whole call.
//
// The optional `read_mask` controls which fields the server returns. If `None`, the reference
// and the object are returned.
Objects(objectIds []*ObjectId, readMask *[]GrpcObjectField) (*GrpcObjectResults, error)
// Get objects by their ids and optional versions.
//
// Results are returned in the same order as the input requests, one per request. An object the
// serving node cannot return — because it is not found, was deleted, or has been pruned —
// fails only its own item, which reading throws with the server's error message. An object the
// server returns but that cannot be decoded fails the whole call.
//
// The optional `read_mask` controls which fields the server returns. If `None`, the reference
// and the object are returned.
ObjectsWithVersions(requests []GrpcObjectRequest, readMask *[]GrpcObjectField) (*GrpcObjectResults, error)
// Get information about the gRPC service and the node serving it.
//
// The optional `read_mask` controls which fields the server returns.
ServiceInfo(readMask *[]GrpcServiceInfoField) (GrpcServiceInfo, error)
// Get transactions by their digests.
//
// Results are returned in the same order as the input digests, one per digest. A transaction
// the serving node cannot return — because it is not found or has been pruned — fails only its
// own item, which reading throws with the server's error message. A transaction the server
// returns but that cannot be decoded fails the whole call.
//
// The optional `read_mask` controls which fields the server returns.
// If `None`, the transaction, signatures, checkpoint, and timestamp are returned.
Transactions(digests []*TransactionDigest, readMask *[]GrpcTransactionField) (*GrpcExecutedTransactionResults, error)
// Wait for the indexing (on the node) or finalization of a transaction by its digest, polling
// the node until then. Returns an error after 60s.
WaitForTransaction(digest *TransactionDigest, waitFor WaitForTransaction) error
// List all versions of a Move package, auto-paginating up to `limit` versions. If `limit` is
// `None`, all versions are returned.
AllPackageVersions(packageId *ObjectId, limit *uint32) ([]GrpcPackageVersion, error)
// List a single page of versions of a Move package.
//
// Pass the returned `next_page_token` back in to retrieve the next page.
PackageVersions(packageId *ObjectId, pageSize *uint32, pageToken *[]byte) (GrpcPackageVersionPage, error)
// Get information about a coin type, including its metadata, treasury, and regulated metadata.
//
// `coin_type` is the inner type `T` of `Coin<T>`, e.g. `0x2::iota::IOTA`, not the `Coin<T>`
// wrapper.
CoinInfo(coinType *StructTag) (GrpcCoinInfo, error)
// List all coins owned by an address, optionally filtered by coin type (the inner type `T` of
// `Coin<T>`), auto-paginating up to `limit` coins. If `coin_type` is `None`, coins of all
// types are returned. If `limit` is `None`, all coins are returned.
AllCoins(owner *Address, coinType **StructTag, limit *uint32) ([]*Coin, error)
// List a single page of coins owned by an address, optionally filtered by coin type (the inner
// type `T` of `Coin<T>`). If `coin_type` is `None`, coins of all types are returned.
//
// Pass the returned `next_page_token` back in to retrieve the next page.
Coins(owner *Address, coinType **StructTag, pageSize *uint32, pageToken *[]byte) (GrpcCoinPage, error)
// List all dynamic fields of an object, auto-paginating up to `limit` fields. If `limit` is
// `None`, all fields are returned.
//
// The optional `read_mask` controls which fields the server returns.
// If `None`, the parent and field id are returned.
AllDynamicFields(parent *ObjectId, limit *uint32, readMask *[]GrpcDynamicFieldField) ([]GrpcDynamicField, error)
// List a single page of dynamic fields of an object.
//
// Pass the returned `next_page_token` back in to retrieve the next page.
//
// The optional `read_mask` controls which fields the server returns.
// If `None`, the parent and field id are returned.
DynamicFields(parent *ObjectId, pageSize *uint32, pageToken *[]byte, readMask *[]GrpcDynamicFieldField) (GrpcDynamicFieldPage, error)
// List all objects owned by an address, optionally filtered by object type, auto-paginating up
// to `limit` objects. If `limit` is `None`, all objects are returned.
//
// The optional `read_mask` controls which fields the server returns. If `None`, the object
// reference and the BCS-encoded object are returned.
AllOwnedObjects(owner *Address, objectType **StructTag, limit *uint32, readMask *[]GrpcOwnedObjectField) ([]GrpcObject, error)
// List a single page of objects owned by an address, optionally filtered by object type.
//
// Pass the returned `next_page_token` back in to retrieve the next page.
//
// The optional `read_mask` controls which fields the server returns. If `None`, the object
// reference and the BCS-encoded object are returned.
OwnedObjects(owner *Address, objectType **StructTag, pageSize *uint32, pageToken *[]byte, readMask *[]GrpcOwnedObjectField) (GrpcOwnedObjectPage, error)
// Set a basic auth `Authorization` header that is sent with every request.
SetBasicAuth(username string, password *string)
// Set a bearer auth `Authorization` header that is sent with every request.
SetBearerAuth(token string) error
// Set the maximum size in bytes that a response message can be.
SetMaxDecodingMessageSize(limit uint64)
// Create a new transaction builder with the given sender address, backed by this client.
TransactionBuilder(sender *Address) *GrpcTransactionBuilder
}