Asset Contracts

In web3 gaming, assets refer to various in-game items, currencies, loot boxes, and other virtual goods that hold value within the game economy. Asset management is a crucial aspect of a web3 game, as it involves the creation, verification, and delegation of assets to enable various functionalities within the game.

Overview

Asset management is important in a web3 game as it allows players to easily control their in-game resources. These assets may have different on-chain actions associated with them, such as buying, selling, trading, or using them in-game. Additionally, asset management may involve interactions with external item contracts or marketplaces.

In a web3 game, supporting different types of assets is crucial. This includes:

  • In-game items: virtual items that players can acquire, trade, or use within the game. Examples include weapons, armor, or virtual pets.
  • In-game currencies: These are virtual currencies that players can use to purchase items or services within the game. Examples include gold, gems, or tokens specific to the game's economy.

How Asset Contracts Work

Assets in a web3 game are defined by smart contracts on the blockchain. These smart contracts contain the logic and data associated with the assets, including ownership, transferability, and functionality. Players can interact with these smart contracts to acquire, trade, and use the assets within the game.

Asset contracts are encompassed of several functions (ie. minting, transfer, etc.) to enable different features within the game. For example, a smart contract for an in-game item may include functionality for transferring ownership, upgrading the item, or being staked in the gameplay. Similarly, an asset contract for an in-game currency may include functionality for transferring, exchanging, or using the currency for in-game purchases.

Openfort supports your own asset contracts:

  • External Item Contract Support: This involves interacting with external smart contracts that govern the behavior of in-game items, such as their attributes, properties, or functionality.
  • External Marketplace Support: This involves interacting with external marketplaces where players can buy, sell, or trade in-game assets with other players.

Asset Verification

To create and manage assets in a web3 game, developers need to verify the smart contracts of such assets. Verification ensures that the smart contracts are legitimate, secure, and compatible with the game's mechanics.

Quickstart

In this guide, we'll use a simple ERC721 contract on the Mumbai network deployed at 0x38090d1636069c0ff1Af6bc1737Fb996B7f63AC0.

1. (Dashboard) Add an asset contract to your game project

Create a new contract by clicking the Add contract button in the Asset contracts section, then enter:

  • The name of the contract (it can be any name you want; the name is only for identification purposes)
  • The network (chain_id) where the smart contract is located.
  • The address of the contract.
  • The Application Binary Interface (ABI) of the contract (if not verified in the block explorer of that network).

1. (API) Add an asset contract to your game project

You can also add an asset by directly using the API:

Create a contract of an asset

POST
/v1/contracts
curl https://api.openfort.xyz/v1/contracts \
  -H "Authorization: Bearer $YOUR_SECRET_KEY" \
  -d name="SimpleNFT" \
  -d address=0x416c...354D \
  -d chain_id=80001

Check the guide on Execute Transaction to know how to mint and transfer the asset into an account.