Blockchain Query

BlockchainQuery Documentation

The BlockchainQuery component allows you to query the blockchain for asset information in the built version of your scene. It can be used to check if a blockchain asset exists, if it is owned by the local user, and to retrieve other information about the asset, such as its name and media.

Namespace

MetaverseCloudEngine.Unity.Blockchain.Components

Public Methods

  • void Query(): Performs the blockchain query.

Public Properties

  • BlockchainQueryParams parameters: The parameters to use for the blockchain query.

  • BlockchainQueryEvents queryEvents: Events that are invoked when the blockchain query is completed.

Inspector Fields

  • bool queryOnStart: Whether or not to perform the query when the component starts.

  • BlockchainQueryParams parameters: The parameters to use for the query.

  • BlockchainQueryEvents queryEvents: Events that are invoked when the query is completed.

  • BlockchainMetaData assetMetaData: Additional metadata checks to perform on the asset if the query type is set to Asset.

Behavior

  • Execution Order: This class inherits from MetaSpaceBehaviour, which uses the default Unity execution order.

Usage

  1. To use BlockchainQuery, start by adding the component to a GameObject in your scene.

  2. In the inspector, configure the parameters property to specify the details of your query.

  3. You can then use the Query() method to perform the query.

  4. You can also listen to the events in the queryEvents property to trigger other behaviors when the query is completed.

Example:

You can use the BlockchainQuery component to check if the local user owns a specific blockchain asset and to display a message if they do. To do this:

  1. Add the BlockchainQuery component to a GameObject in your scene.

  2. In the inspector, set the parameters.queryType property to Asset.

  3. Set the parameters.queryString property to the ID of the blockchain asset that you want to query.

  4. Add a Unity Event to the queryEvents.onOwnedLocally.onTrue event.

  5. In the Unity Event, display a message that indicates that the user owns the asset.

This will display a message if the local user owns the specified blockchain asset.

Additional Notes

  • The BlockchainQuery component only works in the built version of your scene. It will not work in the Unity Editor.

  • The BlockchainQueryParams class allows you to specify the details of your query, such as the query type, the blockchain type, and the query string.

  • The BlockchainQueryEvents class contains events that are invoked when the query is completed. These events can be used to trigger other behaviors in your scene.

Blockchain Types and Blockchain Assets

A blockchain type refers to the specific blockchain network that an asset is associated with. Examples of blockchain types include Cardano and Ethereum. Different blockchain networks have different rules and protocols, so it is important to specify the correct blockchain type when querying for an asset.

A blockchain asset is a unique digital asset that is stored on a blockchain network. Blockchain assets can represent a variety of things, such as digital art, collectibles, or even real-world assets like land or cars. Each blockchain asset has a unique identifier, which is used to query for and track the asset on the blockchain.

The format of the blockchain asset identifier and category varies depending on the blockchain type. For example:

  • On Cardano:

    • Asset ID: The asset ID is a combination of the Policy ID and the Hexadecimal Asset Name.

    • Category: The category is the Policy ID.

  • On Ethereum:

    • Asset ID: The asset ID is the token ID.

    • Category: The category is the Collection that the asset belongs to.

It is important to note that the BlockchainQuery component in the REACH Explorer SDK requires you to specify the correct blockchain type and asset identifier in order to successfully query for an asset.

Last updated