Option categories
All related to each option category
Single Token Category
The Level option of Single Token category has one ERC20 token for staking, and one ERC20 token for rewarding.
/zombie-farm/get-level-options/:session_id/:level_id/:wallet_address
Here is the description of custom parameters that are shown for the Single Token Category. The array that is returned from the API endpoint has three objects. Those objects are representing the each option in the game client.
Here is the example Option object returned from API endpoint:
Here you see the API endpoint returned an array with a one object. For saving our time we kept in our example only of the Option objects. But two other remaining objects will have the same property structures.
The object element of array contains the information to show it correctly on the game client. Let's go through the important parameters of the object.
The first parameter category
indicates the type of the Option. The "single-token" indicates that this option should allow Single Token for staking, and and provides the Single token for earning.
Next important parameter is singleTokenParams
. This parameter includes data about staking token, and earning token.
ThesingleTokenParams
parameter is included into the response, if the category of option is "single-token".
The next parameter called playerParams
. It keeps the information about player's staked token and earning token information. The values of playerParams is different for each depending category.
Let's explain what is the value of singleTokenParams
, and then playerParams
, to understand how to represent them in the game.
singleTokenParams
Here is the structure of the singleTokenParams:
Let's go through each parameter.
earnToken
- contains the Token information that is used for rewarding users.
earnToken.address
- The Earning token address on blockchain network. We don't use it in the game, but provided by server for future usage.
earnToken.icon
- The URL to the icon logo. Load the logo image and cache in the user's browser. And use it to show in the option card in the game. Supported image types: .png and .jpg.
earnToken.name
- The full name of the token. Its used in the hint texts and descriptions.
earnToken.symbol
- The token tick to show in the Option card in the game.
stakeToken
- contains the Token information that user has to stake.
stakeToken.address
- The Staking token address on blockchain network. The game client in the background should create a contract instance along with stakeToken.address
and CrownsToken.json. Name the contract asstakeToken.name
.
For example let's say we create our game in Cocos Creator, and our staking token is Crowns.
Then instantiniated token would be:
var instantName = stakeToken.name.toLowerCase();
cc[instantName] = new web3.Contract(CrownsTokenAbi, stakeToken.address);
stakeToken.icon
- The URL to the icon logo. Load the logo image and cache in the user's browser. And use it to show in the option card in the game. Supported image types: .png and .jpg.
stakeToken.name
- The full name of the token. Its used in the hint texts and descriptions.
stakeToken.symbol
- The token tick to show in the Option card in the game.
minDeposit
and maxDeposit
are the limit gaps for staking. User can stake the amount that is equal or greater than minDeposit
, and less or equal to maxDeposit
.
playerParams
Here is the structure of the playerParams
object:
The parameters of playerParams
are generated according to Single Token Option category. For other option categories it may be different.
claimed
- the amount of singleTokenParams.earnToken
that user already withdraw through the game. Its in decimal format.
staked
- the amount of singleTokenParams.stakeToken
that user already staked. Its value is changing if user increases or decreases the his token.
stakeTime
- This is a time in unix timestamp format in seconds. It indicates the last time when user staked enough tokens for completing the game. This time is holding a timestamp since the latest staked token amount. Otherwise it's value is 0.
stakedDuration
- period in seconds that user keeps the staking before the update of stakeTime
.
withdrawn
- amount of singleTokenParams.stakeToken
that user withdraw from the smart contract. It updates the stakeTime
, as well as staked
too.
Stake
Staking the Single Token challenge.
The third parameter that is passed to the window.zombieFarm.methods.stake()
is in the bytes form.
For single token, the stake
method accepts only one argument: amount of token to stake.
Here is the steps to convert it to the bytes:
Unstake
Unstaking the Single Token challenge.
The third parameter that is passed to the window.zombieFarm.methods.unstake()
is in the bytes form.
For single token, the unstake
method accepts only one argument: amount of token to unstake.
Here is the steps to convert it to the bytes:
LP Token Category
The Level option of LP Token category has one LP token for staking, and one ERC20 token for rewarding.
/zombie-farm/get-level-options/:session_id/:level_id/:wallet_address
Here is the description of custom parameters that are shown for the LP Token Category. The array that is returned from the API endpoint has three objects. Those objects are representing the each option in the game client.
Here is the example Option object returned from API endpoint:
Here you see the API endpoint returned an array with a one object.
For saving our time we kept in our example only one Option object. But two other remaining objects will have the same property structures.
The object element of array contains all information about Challenge option to show it on the game client. Let's go through the important parameters of the object.
The first parameter category
indicates the type of the Option. The "lp-token" indicates that this option should allow LP Token for staking, and and provides the Single token for earning.
Next important parameter is lpTokenParams
. This parameter includes data about staking token, and earning token.
ThelpTokenParams
parameter is included into the response, if the category of option is "lp-token".
The next parameter called playerParams
. It keeps the information about player's staked token and earning token information. The values of playerParams is different for each depending category.
Let's explain what is the value of lpTokenParams
, and then playerParams
, to understand how to represent them in the game.
lpTokenParams
Here is the structure of the singleTokenParams:
Let's go through each parameter.
earnToken
- contains the Token information that is used for rewarding users.
earnToken.address
- The Earning token address on blockchain network. We don't use it in the game, but provided by server for future usage.
earnToken.icon
- The URL to the icon logo. Load the logo image and cache in the user's browser. And use it to show in the option card in the game. Supported image types: .png and .jpg.
earnToken.name
- The full name of the token. Its used in the hint texts and descriptions.
earnToken.symbol
- The token ticker to show in the Option card in the game.
stakeToken
- contains the Token information that user has to stake.
stakeToken.address
- The LP token address on blockchain network. The game client in the background should create a contract instance along with stakeToken.address
and CrownsToken.json. Name the contract asstakeToken.name
.
For example let's say we create our game in Cocos Creator, and our staking token is Crowns.
Then instantiniated token would be:
var instantName = stakeToken.name.toLowerCase();
cc[instantName] = new web3.Contract(CrownsTokenAbi, stakeToken.address);
stakeToken.icon1
and stakeToken.icon2
- The icon URLs to the paired token in LP. Load the logo image and cache in the user's browser. And use it to show in the option card in the game. Supported image types: .png and .jpg.
stakeToken.name
- The full name of the token. Its used in the hint texts and descriptions.
stakeToken.symbol
- The token ticker to show in the Option card in the game.
minDeposit
and maxDeposit
are the limit gaps for staking. User can stake the amount that is equal or greater than minDeposit
, and less or equal to maxDeposit
.
playerParams
Here is the structure of the playerParams
object:
The parameters of playerParams
are generated according to Lp Token Option category. For other option categories it may be different.
claimed
- the amount of lpTokenParams.earnToken
that user already withdraw through the game. Its in decimal format.
staked
- the amount of lpTokenParams.stakeToken
that user already staked. Its value is changing if user increases or decreases the his token.
stakeTime
- This is a time in unix timestamp format in seconds. It indicates the last time when user staked enough tokens for completing the game. This time is holding a timestamp since the latest staked token amount. Otherwise it's value is 0.
stakedDuration
- period in seconds that user keeps the staking before the update of stakeTime
.
withdrawn
- amount of lpTokenParams.stakeToken
that user withdraw from the smart contract. It updates the stakeTime
, as well as staked
too.
Scape NFT
The Scape NFT Staking option has one Scape NFT for staking, and one ERC20 token for rewarding.
/zombie-farm/get-level-options/:session_id/:level_id/:wallet_address
Here is the example Option object returned from API endpoint:
For saving our time we kept in our example only one Option object. But two other remaining objects will have the same property structures.
The object element of array contains all information about Challenge option to show it on the game client. Let's go through the important parameters of the object.
The first parameter category
indicates the type of the Option. The "scape-nft" indicates that this option should allow Scape NFT for staking, and provides the Single token for earning.
Next important parameter is scapeNftParams
. This parameter includes data about staking nft, and earning token.
ThescapeNftParams
parameter is included into the response, if the category of option is "scape-nft".
The next parameter called playerParams
. It keeps the information about player's staked token and earning token information. The values of playerParams is different for each option category.
Let's explain what is the value of scapeNftParams
, and then playerParams
, to understand how to represent them in the game.
scapeNftParams
Here is the structure of the scapeNftParams:
Let's go through each parameter.
earnToken
- contains the Token information that is used for rewarding users.
earnToken.address
- The Earning token address on blockchain network. We don't use it in the game, but provided by server for future usage.
earnToken.icon
- The URL to the icon logo. Load the logo image and cache in the user's browser. And use it to show in the option card in the game. Supported image types: .png and .jpg.
earnToken.name
- The full name of the token. Its used in the hint texts and descriptions.
earnToken.symbol
- The token ticker to show in the Option card in the game.
stakeNft
- contains the Nft information that user has to stake.
stakeNft.address
- The Nft address on blockchain network. The game client in the background should create a contract instance along with stakeNft.address
and ScapeNft.json. Name the contract asstakeNft.symbol
.
For example let's say we create our game in Cocos Creator, and our staking nft is Scape NFT.
Then instantiniated token would be:
var instantName = stakeToken.symbol.toLowerCase();
cc[instantName] = new web3.Contract(ScapeAbi, stakeNft.address);
stakeNft.icon
- The icon URL that represents Nft group. Load the logo image and cache in the user's browser. And use it to show in the option card in the game. Supported image types: .png and .jpg.
stakeNft.name
- The nft group name. Its used in the hint texts and descriptions.
stakeNft.symbol
- The nft ticker to show in the Option card in the game.
stakeNft.filters
- The list of parameters of acceptable nft for staking.
The stakeNft.filters doesn't return all parameters. But only those that are used for determination.
For example, the Scape NFT will have Generation, Quality, Image ID parameters. And if stakeNft.filters contains only "quality" parameter, then it means, Staking accepts only quality type nfts.
stakeNft.filters.quality
- The Scape NFT quality. If this parameter wasn't defined, then it won't be included.
stakeNft.filters.generation
- The Scape NFT generation. If this parameter wasn't defined, then it won't be included.
stakeNft.filters.imgId
- The Scape NFT image id. If this parameter wasn't defined, then it won't be included.
stakeNft.filterNames
- The list of parameter names to show in the Game. The values of stakeNft.filterNames
is identical to stakeNft.filters
. Use this values in the card.
playerParams
Here is the structure of the playerParams
object:
The parameters of playerParams
are generated according to Lp Token Option category. For other option categories it may be different.
claimed
- the amount of lpTokenParams.earnToken
that user already withdraw through the game. Its in decimal format.
stakedId
- the token ID that user used for staking.
stakeTime
- This is a time in unix timestamp format in seconds. It indicates the last time when user staked enough tokens for completing the game. This time is holding a timestamp since the latest staked token amount. Otherwise it's value is 0.
stakedDuration
- period in seconds that user keeps the staking before the update of stakeTime
.
Last updated