FT Collection API Example

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

πŸ“˜

ERC-20

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

Create Collection

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

{
  "publicMetadata": {},
  "gameId": "{{gameId}}",
  "symbol": "GOLD",
  "blockchainId": "{{blockchainId}}",
  "totalSupply": "1000000",
  "name": "Gold Coin",
  "description": "A medium of exchange for in-game goods and services.",
  "image": "img.url"
}
{
    "symbol": "GOLD",
    "blockchainId": 7,
    "id": "d8bbb658-6fec-418f-924e-86ec7f381cbc",
    "gameId": 3000,
    "name": "Gold Coin",
    "type": "FT",
    "description": "A medium of exchange for in-game goods and services.",
    "image": "img.url",
    "publicMetadata": {
        "name": "Gold Coin",
        "description": "A medium of exchange for in-game goods and services.",
        "image": "img.url"
    },
    "address": "0x4e893d50976E0577C8FFABF378A0C38d338dE74a",
    "totalSupply": "1000000",
    "itemId": "cfeba42f-2943-4b16-9222-4f39e8fbcb41"
}

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. The response will also include an itemId. Since all FT items are identical, it is not necessary to call Create Item.

Add Item Balance

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

{
  "itemId": "cfeba42f-2943-4b16-9222-4f39e8fbcb41",
  "playerId": "0ff81141-52d6-48d8-bda1-5d83c9ec7201",
  "amount": "1"
}
{
    "gameId": 3000,
    "playerId": "0ff81141-52d6-48d8-bda1-5d83c9ec7201",
    "itemId": "cfeba42f-2943-4b16-9222-4f39e8fbcb41",
    "id": "4f2693ad-9871-4a0c-93d7-f44d18687806",
    "amount": "1",
    "item": {
        "blockchainId": 7,
        "currentSupply": "1",
        "id": "cfeba42f-2943-4b16-9222-4f39e8fbcb41",
        "collectionId": "d8bbb658-6fec-418f-924e-86ec7f381cbc",
        "gameId": 3000,
        "totalSupply": "1000000",
        "publicMetadata": {
            "name": "Gold Coin",
            "description": "A medium of exchange for in-game goods and services.",
            "image": "img.url"
        },
        "name": "Gold Coin",
        "description": "A medium of exchange for in-game goods and services.",
        "image": "img.url",
        "address": "448361823489774060231064712367045358275422709578"
    }
}

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