Skip to content

readObject(address_)

MarcoDotIO edited this page Jun 26, 2023 · 2 revisions

readObject(address:)

Fetches and returns a ReadObject from the given account address.

public func readObject(address: AccountAddress)

This function communicates asynchronously with a client to fetch account resources. For each fetched resource, it parses the resource data according to the resource type found in the resourceMap of the ReadObject class. The parsed resource is then stored in a dictionary using an AnyHashableReadObject as the key. Finally, a ReadObject is created with the constructed dictionary and returned.

Note: This function is marked with the async keyword, which means it returns a future that represents a result that is produced at some point in the future. When you call a function that’s marked with the async keyword, you need to use the await keyword.

Parameters

  • address: The address of the account from which the resources are to be read.

Throws

If the function fails to fetch resources from the account, parse resource data, or initialize the AnyHashableReadObject, it propagates the error thrown by the underlying calls to client.accountResources(address), resourceClass.parse(resource["data"]), or the AnyHashableReadObject initializer, respectively.

Returns

A ReadObject that contains all the parsed resources of the account at the provided address.

Types
Protocols
Global Variables
Global Functions
Extensions
Clone this wiki locally