Skip to main content

Asset Definition

The AssetDefinition is a key object, representing any kind of asset that a player can hold.

In this section, we'll:

  • Detail the types of assets we support
  • Demonstrate how to create an asset definition and how to fetch it from the client side.

Before proceeding, make sure you've already gone through the Getting Started and Installation Guide guides. The code snippets here assume that you've created and are using a test user.

What is an Asset Definition?

AssetDefinitions are blueprints for the actual assets that players can own. They outline common properties of the asset:

  • name - The name of the asset.
  • description - A short summary describing the asset.
  • developerAssetId - A unique ID that developers can assign to an asset. It's separate from the Subroutine's ID and can be used, for example, to match your visual asset names.
  • tags - A list of strings that developers can use to group assets into related categories.
  • isConsumable - If set, it allows a player to carry out the consumeAsset operation. The developer decides the effect of consuming the asset (for example, it could be a healing potion or a time booster that needs to be actively consumed).
  • cap - Sets the maximum number of instances of a particular asset a player can own at once.
  • isTradeableOnExchange - Specifies if this asset can be traded on the exchange.

Additionally, AssetDefinition includes two optional fields: fungibleProperties and uniqueProperties. These fields determine how an asset can be stored for a player.

If an asset has fungibleProperties, it can be held as a fungible holding. This means we track the quantity of the items that the player holds, and don't distinguish between the instances (coins, healing potions). This is the most common type of holding. If an asset is fungible, the asset definition can specify the decimal precision used for this asset. This is useful for assets that might not be whole numbers. For instance, while gold coins can be represented as whole integers, you might represent coal by weight and include a few decimal places for precision.

If an asset has uniqueProperties, it can be held as asset instances. This means that each instance is an individual object with its own creation time and metadata. For instance, a special type of coin or a cosmetic awarded to early game adopters could be represented in this manner.

Please note that an object can define both fungibleProperties and uniqueProperties. The system does not restrict assets to only one type, and if you wish to create special instances of an otherwise fungible item, you have the flexibility to do so.

Creating an Asset Definition

To create an asset definition, select the game from the dashboard or create one if you haven't yet.

Assets Page

Scroll to the bottom of the page, click the Create Asset button, then fill in the details about the asset. Set the asset to be fungible and click create.

Example Asset Creation Page

Fetching Asset Definitions

A game can fetch all assets directly via the SDK or GraphQL API.

Client.Game.GetAssetDefinitions(new GameAPI.GetAssetDefinitionsProps
First = 100,
}, (response) =>
var assets = response.Assets.edges;