Dynamic Flow and Smart Contracts
Flow and Smart Contracts
Considering the fact that some substantial changes are needed for redesigning the Smart Contracts to the advanced way of handling all the transactions, we'll structure them from the beginning using a two-layer architecture:
the first layer will contain one main wrapper contract that will operate just like a control tower
the second one will be represented by permanent contracts which handle resources, items and new potential collections.
We will introduce a new collection-1 Smart Contract. The whole structure will be the following: The new Smart Contract we have introduced is meant to come up with some major improvements. It is supposed to allow the user not only to accomplish story fights and other basic operations but also to mine and harvest. For this, it will contain new resources and items: gold-bar, ruby, axe and pickaxe.

SIP Contracts
If until now we had one single contract that used to handle all the flow, now we have to restructure it a little bit. Firstly, we will split the main semi-fungible-token Smart Contract into two other contracts:
one that will handle the resources (gold, energy-power, wood, and iron)
another one for the items (swords, armor, etc.).
Then, we will introduce the new collection-1 contract.
Resources Contract
This contract will keep all the initial resources tokens' information. Here will be defined all tokens having the ids between u1 and u4: gold, energy-power, wood, iron. This is what the token-name and token-uri dictionaries will look like in the resources contract:
Then, we will keep in the resources contract the SIP functions, too: mint, mint-user, burn, is-owned-needed, balance functions, transfer functions, set-token-uri, get-token-uri. These functions will have the exact same structure as the ones in the Base SFTs chapter.
Items Contract
The Items Contract's structure will follow the Resources Contract's. The main difference is the token-ids handled inside it. Instead of handling the resources flows, we will handle here the initial items tokens:
Collection-1 Contract
This contract is intended to be one the game's owner decided to add after the game's first launch. It comes with some major improvements: introducing the axe and the pickaxe and the gold-bar and ruby resources. The two resources added can be obtained through the gameplay after successfully mining. This implies new functions: one for mining, and one for harvesting which will be found inside Main-SC.
This is how token-name and token-uri look inside collection-1 contract:
Main-SC
As we have said before, the Main-SC contract works just like a control tower for all other contracts located on the second architectural layer. For this, all the SIP characteristic functions, the ones that handle the whole token flow will be found inside the permanent contracts (resources, items, collection-1). For calling them, we will need wrappers inside Main-SC. Furthermore, the main operations' functions will be held in the wrapper contract, too. In conclusion, all the token functions will have wrappers: mint-wrapper, mint-wrapper-user, mint-wrapper-admin, burn-wrapper, get-balance-wrapper, is-owned-needed-wrapper, transfer-wrapper. To clarify, this is what the mint-wrapper looks like:
It can be observed that the wrapper has three conditionals. This is the exactly same number as the permanent contracts, and this is not a coincidence. Technically, the mint-wrapper checks whether the given token-id belongs to the resources contract, items contract, or collection-1 contract. After this step, it calls the mint function located in the proper token contract. The same happens for the other wrappers:
The operations' functions (level-up, crafting, acquisition) will be held here, too. The difference from the previous SFTs basic is represented by the new functions: reward-mining and reward-harvesting. These are a result of the collection-1 improvements and will imply two additional dictionaries, too. Also, when the user first starts the game he will be allowed to call the claim-starter-kit function and get the resources needed in the beginning.
Mining dictionary
Harvesting dictionary
Starter kit dictionary
The functions that will handle each of the two new operations will be the following:
Each of the reward-mining and reward-harvesting functions will use a wrapper that handles minting resources won by the player after successfully finishing new operations.
Last updated
Was this helpful?