In this article, we’ll walk through setting up a farming game on the WAX blockchain. We’ll start by creating an NFT collection and templates, followed by initializing blends, token swaps, governance, and quests.

1. Creating Atomic Assets Collection, Categories, and Templates

  • Creating a Collection
    The first step is to create a collection that will house all the templates necessary for the game’s functionality.
  • Collection Creation Parameters
    Let’s outline the key parameters required for setting up your NFT collection.
NameDescription
Collection NameUnique 12 characters name 
Display NameName which players see
Website URL
Market FeeTrading commission for game’s platform
Collection Description
Background ImageBackground scene
Logo Image
Social Media
Company Details

Here you can see an example of a collection.

  • Creating farming items

Next, we’ll create a category for instruments that will produce resources when staked. By looking over the parameters needed for setting up this category, ensuring it aligns with the game’s mechanics and resource production requirements. It is in depth described in Part 2 of our article series.

  • Creating farmable items

The next category we’ll create is for farmable items. These are essential components in the game, acting as containers that allow farming items to be put to use. Farmable items play a crucial role in managing and producing resources, as they house the tools and instruments needed for farming operations within the game. It is in described in Part 3 of our article series.

  • Creating avatars

The next category we’ll set up is avatars. These represent characters in the game that directly influence the gameplay. Avatars might affect various aspects, such as resource production, item upgrades, or player interactions, adding depth and strategy to the game. You can check on avatars creation in Part 10.

  • Creating equipment

The final category used in our game is equipment. Avatars utilize equipment to boost their characteristics, enhancing their abilities and effectiveness within the game. You can check on equipment creation in same part as avatars, so Part 10.

  • Creating templates

After setting up the categories, the next step is to populate them with templates. By creating and configuring templates, we ensure that each category, whether it’s avatars, equipment, or farmable items, is fully equipped to function within the game’s ecosystem. Creating templates is covered in many parts mentioned above.

2. Creating Blends

After setting up all the templates for the game, we move on to initializing the core mechanics, starting with blends. Blends allow players to combine specific items to create a new, more powerful item. To create a blend, you’ll need to specify a list of items that will be combined and the resulting item that players will receive after the blend.

Here you can see three templates with ids #640924, #640923, #640922. Let’s suppose you want to blend axe and fishing rod and get a basket. To add such a blend you should call method addblend() with parameters: 

blend_components = [640924, 640922],resulting_item = 640923

3. Initializing token swaps

Our next step will be initializing token swaps via setratio(). We need to go through every resource and initialize the ratio so that every swap is valid. For example in our game we use:

setratio(“wood”, 20)

setratio(“stone”, 15)

setratio(“gems”, 5)

setratio(“food”, 30)

4. Staking Tokens

To participate in voting, players need to stake tokens. This is done by using the transfer method of the game token contract with the memo set to “stake.”

For instance, if you’re using the eosio.token contract, the staking process in Anchor would look like this. [Provide code example here]. This action stakes the tokens, granting the player the ability to vote on various proposals within the game.

5. Creating voting for swaping tokens to resources

If you want to create a voting to change swap ratio for some resource, you can use action

createvoting(player, resource_name, new_ratio).

For example, let’s change ratio for wood: createvoting(name, “wood”, 10). After calling this method changeration table has a new entry with some ID. 

To vote player calls action vote(name, voting_id). In our case some player calls vote(name, 0). After having enough votes the vote is closed and new ratio is applied.

6. Creating general voting

Here we give an example of creating general voting.

After calling crgenvt there are new entries in genvtngs(scope = somevoting) table.

To vote players must use method gvote.

7. Creating automatic voting

Now let’s create automatic voting for changing fee config variable.

And then voting process is the same as for general votings.

8. Initializing config variables

Now we can add any config variable of types string, float, uint32 and int32 using config table and method setcnfg. For example, we can define some kind of fee:

9. Adding quests

To add quests one should use addquest(player, type, amount) action. Let’s introduce some types of quests we use in game.

addquest(“staking”, player, 10) – quest to stake 10 instruments

addquest(“swap”, player, 100.0) – quest to exchange resources for 100 GAME tokens

addquest(“upgrade”, player, 5) – quest to upgrade items to level 5

addquest(“tokens”, player, 50.0) – quest to stake 50 tokens

addquest(“stone”, player, 100.0) – quest to farm 100.0 stone

addquest(“food”, player, 50.0) – quest to farm 50.0 food

addquest(“wood”, player, 70.0) – quest to farm 70.0 wood

addquest(“gems”, player, 80.0) – quest to farm 80.0 gems

This article outlines the setup process for a farming game on the WAX blockchain, including creating NFT collections, templates, and categories for avatars, equipment, and farmable items. It also covers initializing game mechanics like blends, token staking for voting, and governance. Each step ensures that the game functions smoothly and that players can engage deeply with the gameplay, from collecting and blending items to participating in game governance through staking tokens.