Skip to main content

GrpcClient

type GrpcClient​

The gRPC client for interacting with the IOTA blockchain.

type GrpcClient struct {
// contains filtered or unexported fields
}

func GrpcClientNewDevnet​

func GrpcClientNewDevnet() (*GrpcClient, error)

Create a new gRPC client connected to the `devnet` gRPC server.

func GrpcClientNewLocalnet​

func GrpcClientNewLocalnet() (*GrpcClient, error)

Create a new gRPC client connected to a `localnet` gRPC server: <http://localhost:50051\>.

func GrpcClientNewMainnet​

func GrpcClientNewMainnet() (*GrpcClient, error)

Create a new gRPC client connected to the `mainnet` gRPC server.

func GrpcClientNewTestnet​

func GrpcClientNewTestnet() (*GrpcClient, error)

Create a new gRPC client connected to the `testnet` gRPC server.

func LiftFromExternalGrpcClient​

func LiftFromExternalGrpcClient(handle uint64) *GrpcClient

func NewGrpcClient​

func NewGrpcClient(uri string) (*GrpcClient, error)

Create a new gRPC client with the provided server URI.

func (*GrpcClient) AllCoins​

func (_self *GrpcClient) AllCoins(owner *Address, coinType **StructTag, limit *uint32) ([]*Coin, 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.

func (*GrpcClient) AllDynamicFields​

func (_self *GrpcClient) AllDynamicFields(parent *ObjectId, limit *uint32, readMask *[]GrpcDynamicFieldField) ([]GrpcDynamicField, 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.

func (*GrpcClient) AllOwnedObjects​

func (_self *GrpcClient) AllOwnedObjects(owner *Address, objectType **StructTag, limit *uint32, readMask *[]GrpcOwnedObjectField) ([]GrpcObject, 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.

func (*GrpcClient) AllPackageVersions​

func (_self *GrpcClient) AllPackageVersions(packageId *ObjectId, limit *uint32) ([]GrpcPackageVersion, error)

List all versions of a Move package, auto-paginating up to `limit` versions. If `limit` is `None`, all versions are returned.

func (*GrpcClient) CheckpointByDigest​

func (_self *GrpcClient) CheckpointByDigest(digest *CheckpointDigest, transactionsFilter **GrpcTransactionFilter, eventsFilter **GrpcEventFilter, readMask *[]GrpcCheckpointResponseField) (GrpcCheckpointResponse, 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.

func (*GrpcClient) CheckpointBySequenceNumber​

func (_self *GrpcClient) CheckpointBySequenceNumber(sequenceNumber uint64, 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.

func (*GrpcClient) CheckpointLatest​

func (_self *GrpcClient) CheckpointLatest(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.

func (*GrpcClient) CheckpointsStream​

func (_self *GrpcClient) CheckpointsStream(startSequenceNumber *uint64, endSequenceNumber *uint64, transactionsFilter **GrpcTransactionFilter, eventsFilter **GrpcEventFilter, readMask *[]GrpcCheckpointResponseField) (*GrpcCheckpointStream, 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.

func (*GrpcClient) CheckpointsStreamFiltered​

func (_self *GrpcClient) CheckpointsStreamFiltered(startSequenceNumber *uint64, endSequenceNumber *uint64, transactionsFilter **GrpcTransactionFilter, eventsFilter **GrpcEventFilter, progressIntervalMs *uint32, readMask *[]GrpcCheckpointResponseField) (*GrpcFilteredCheckpointStream, 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.

func (*GrpcClient) CoinInfo​

func (_self *GrpcClient) CoinInfo(coinType *StructTag) (GrpcCoinInfo, 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.

func (*GrpcClient) Coins​

func (_self *GrpcClient) Coins(owner *Address, coinType **StructTag, pageSize *uint32, pageToken *[]byte) (GrpcCoinPage, 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.

func (*GrpcClient) Destroy​

func (object *GrpcClient) Destroy()

func (*GrpcClient) DynamicFields​

func (_self *GrpcClient) DynamicFields(parent *ObjectId, pageSize *uint32, pageToken *[]byte, readMask *[]GrpcDynamicFieldField) (GrpcDynamicFieldPage, 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.

func (*GrpcClient) Epoch​

func (_self *GrpcClient) Epoch(epoch *uint64, readMask *[]GrpcEpochField) (GrpcEpochInfo, 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.

func (*GrpcClient) ExecuteTransaction​

func (_self *GrpcClient) ExecuteTransaction(signedTransaction SignedTransaction, checkpointInclusionTimeoutMs *uint64, readMask *[]GrpcTransactionField) (GrpcExecutedTransaction, error)

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.

func (*GrpcClient) ExecuteTransactions​

func (_self *GrpcClient) ExecuteTransactions(transactions []SignedTransaction, checkpointInclusionTimeoutMs *uint64, readMask *[]GrpcTransactionField) (*GrpcExecutedTransactionResults, 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.

func (*GrpcClient) Health​

func (_self *GrpcClient) Health(thresholdMs *uint64) (GrpcHealthInfo, 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.

func (*GrpcClient) Objects​

func (_self *GrpcClient) Objects(objectIds []*ObjectId, readMask *[]GrpcObjectField) (*GrpcObjectResults, 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.

func (*GrpcClient) ObjectsWithVersions​

func (_self *GrpcClient) ObjectsWithVersions(requests []GrpcObjectRequest, 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.

func (*GrpcClient) OwnedObjects​

func (_self *GrpcClient) OwnedObjects(owner *Address, objectType **StructTag, pageSize *uint32, pageToken *[]byte, readMask *[]GrpcOwnedObjectField) (GrpcOwnedObjectPage, 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.

func (*GrpcClient) PackageVersions​

func (_self *GrpcClient) PackageVersions(packageId *ObjectId, pageSize *uint32, pageToken *[]byte) (GrpcPackageVersionPage, error)

List a single page of versions of a Move package.

Pass the returned `next_page_token` back in to retrieve the next page.

func (*GrpcClient) ReferenceGasPrice​

func (_self *GrpcClient) ReferenceGasPrice() (uint64, error)

Get the reference gas price of the current epoch, denominated in NANOS.

func (*GrpcClient) ServiceInfo​

func (_self *GrpcClient) ServiceInfo(readMask *[]GrpcServiceInfoField) (GrpcServiceInfo, error)

Get information about the gRPC service and the node serving it.

The optional `read_mask` controls which fields the server returns.

func (*GrpcClient) SetBasicAuth​

func (_self *GrpcClient) SetBasicAuth(username string, password *string)

Set a basic auth `Authorization` header that is sent with every request.

func (*GrpcClient) SetBearerAuth​

func (_self *GrpcClient) SetBearerAuth(token string) error

Set a bearer auth `Authorization` header that is sent with every request.

func (*GrpcClient) SetMaxDecodingMessageSize​

func (_self *GrpcClient) SetMaxDecodingMessageSize(limit uint64)

Set the maximum size in bytes that a response message can be.

func (*GrpcClient) SimulateTransaction​

func (_self *GrpcClient) SimulateTransaction(transaction *Transaction, skipChecks bool, readMask *[]GrpcSimulateField) (GrpcSimulatedTransaction, 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.

func (*GrpcClient) SimulateTransactions​

func (_self *GrpcClient) SimulateTransactions(transactions []GrpcSimulateTransactionInput, readMask *[]GrpcSimulateField) ([]GrpcSimulatedTransactionResult, 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.

func (*GrpcClient) TransactionBuilder​

func (_self *GrpcClient) TransactionBuilder(sender *Address) *GrpcTransactionBuilder

Create a new transaction builder with the given sender address, backed by this client.

func (*GrpcClient) Transactions​

func (_self *GrpcClient) Transactions(digests []*TransactionDigest, readMask *[]GrpcTransactionField) (*GrpcExecutedTransactionResults, 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.

func (*GrpcClient) ViewFunctionCall​

func (_self *GrpcClient) ViewFunctionCall(fqFunctionName string, typeArgs []*TypeTag, callArgs []*MoveViewArg, readMask *[]GrpcViewFunctionCallField) (GrpcViewFunctionCallOutputs, 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.

func (*GrpcClient) ViewFunctionCalls​

func (_self *GrpcClient) ViewFunctionCalls(functionCalls []GrpcViewFunctionCallInput, readMask *[]GrpcViewFunctionCallField) ([]GrpcViewFunctionCallResult, 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.

func (*GrpcClient) WaitForTransaction​

func (_self *GrpcClient) WaitForTransaction(digest *TransactionDigest, waitFor WaitForTransaction) 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.