FA Collection API Example

The following example shows the necessary steps to creating an FA collection and adding an item to a player's balance.

πŸ“˜

ERC-1155

On EVM chains, this deploys an ERC-1155 smart contract

Create Collection

The first step in creating an FA (fungible asset) is to create a Collection. This can be done by calling the Create FA Collection endpoint.

{
  "publicMetadata": {},
  "gameId": "{{gameId}}",
  "name": "Magical Swords",
  "description": "Causes some damage",
  "image": "img.url",
  "symbol": "SWORD",
  "blockchainId": "{{blockchainId}}"
}
{
    "symbol": "SWORD",
    "blockchainId": 7,
    "id": "a3ee7709-d452-4466-9b70-deda30295721",
    "gameId": 3000,
    "name": "Magical Swords",
    "type": "FA",
    "description": "Causes some damage",
    "image": "img.url",
    "publicMetadata": {
        "name": "Magical Swords",
        "description": "Causes some damage",
        "image": "img.url"
    },
    "address": "0x3407AEea937afcc40e044394A69A4E3d34a1c162"
}

In the response will be an id for the Collection, along with other data including an address that represents the smart contract address on-chain.

Create Item

Once the Collection is created, an Item can be created. This can be done by calling the Create Item endpoint. FA Items require a totalSupply to be set.

{
  "publicMetadata": {},
  "collectionId": "a3ee7709-d452-4466-9b70-deda30295721",
  "gameId": "3000",
  "name": "Fire Sword",
  "description": "Legendary long sword",
  "image": "img.url",
  "blockchainId": "7",
  "totalSupply": "10000"
}
{
    "blockchainId": 7,
    "currentSupply": "0",
    "publicMetadata": {
        "name": "Fire Sword",
        "description": "Legendary long sword",
        "image": "img.url"
    },
    "collectionId": "a3ee7709-d452-4466-9b70-deda30295721",
    "gameId": 3000,
    "name": "Fire Sword",
    "description": "Legendary long sword",
    "image": "img.url",
    "totalSupply": "10000",
    "id": "300f98e5-b03a-4564-90fc-f3ed7c16c5ee",
    "address": "1"
}

In the response will be an id for the Item, along with other data including an address that represents the blockchain token id on-chain.

Add Item Balance

Once the Item has been created, it can be added to a Player's wallet. This is done by calling the Add Item Balance endpoint.

{
  "itemId": "300f98e5-b03a-4564-90fc-f3ed7c16c5ee",
  "playerId": "0ff81141-52d6-48d8-bda1-5d83c9ec7201",
  "amount": "1"
}
{
    "id": "ccfe8475-44c6-461c-aece-1438c77a954d",
    "itemId": "300f98e5-b03a-4564-90fc-f3ed7c16c5ee",
    "playerId": "0ff81141-52d6-48d8-bda1-5d83c9ec7201",
    "gameId": 3000,
    "amount": "1",
    "item": {
        "blockchainId": 7,
        "currentSupply": "1",
        "id": "300f98e5-b03a-4564-90fc-f3ed7c16c5ee",
        "collectionId": "a3ee7709-d452-4466-9b70-deda30295721",
        "gameId": 3000,
        "totalSupply": "10000",
        "publicMetadata": {
            "name": "Fire Sword",
            "description": "Legendary long sword",
            "image": "img.url"
        },
        "name": "Fire Sword",
        "description": "Legendary long sword",
        "image": "img.url",
        "address": "1"
    }
}

To see all of a Player's Item Balances, call the endpoint List Item Balances.