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:

[
{
"category":"single-token",
"duration":25200,
"optionId":2,
"playerParams":{
"claimed":2.12,
"stakeTime":0,
"staked":0,
"stakedDuration":23,
"withdrawn":0
},
"rewardPool":2000,
"singleTokenParams":{
"earnToken":{
"address":"0x168840Df293413A930d3D40baB6e1Cd8F406719D",
"icon":"https://s2.coinmarketcap.com/static/img/coins/200x200/8365.png",
"name":"Crowns",
"symbol":"CWS"
},
"maxDeposit":100,
"minDeposit":10,
"stakeToken":{
"address":"0x3b00ef435fa4fcff5c209a37d1f3dcff37c705ad",
"icon":"https://icons.iconarchive.com/icons/cjdowner/cryptocurrency-flat/1024/Tether-USDT-icon.png",
"name":"USD Tether",
"symbol":"USDT"
}
}
}, // Two other option objects
]

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.

ThesingleTokenParamsparameter 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:

"singleTokenParams":{
"earnToken": {
"address": "Token address",
"icon": "Logo Url",
"name": "Name of the token: Crowns, Eth, USD Tether...",
"symbol": "Symbol of the token: CWS, ETH, USDT..."
},
"stakeToken":{
"address": "Token address",
"icon":" Logo Url",
"name": "Name of the token: Crowns, Eth, USD Tether...",
"symbol": "Symbol of the token: CWS, ETH, USDT..."
},
"maxDeposit": 0,
"minDeposit": 0
}

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:

"playerParams":{
"claimed": 0,
"staked": 0,
"stakeTime": 0,
"stakedDuration": 0,
"withdrawn": 0
}

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:

// The "amount" here is received from the popup.
let amount = web3.utils.toWei(amount, "ether");
let data= web3.eth.abi.encodePacked(['uint256'], [amount]);
// rest of the code
window.zombieFarm.methods.stake(sessionId, challengeId, data).send()// handling tx

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:

// The "amount" here is received from the popup.
let amount = web3.utils.toWei(amount, "ether");
let data= web3.eth.abi.encodePacked(['uint256'], [amount]);
// rest of the code
window.zombieFarm.methods.unstake(sessionId, challengeId, data).send()// handling tx

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:

[
{
"category":"single-token",
"duration":25200,
"stakeAmount": 100,
"optionId":2,
"playerParams":{
"claimed":2.12,
"stakeTime":0,
"staked":0,
"stakedDuration":23,
"withdrawn":0
},
"rewardPool":2000,
"lpTokenParams":{
"earnToken":{
"address":"0x168840Df293413A930d3D40baB6e1Cd8F406719D",
"icon":"https://s2.coinmarketcap.com/static/img/coins/200x200/8365.png",
"name":"Crowns",
"symbol":"CWS"
},
"maxDeposit":100,
"minDeposit":10,
"stakeToken":{
"address":"0x3b00ef435fa4fcff5c209a37d1f3dcff37c705ad",
"icon1":"https://icons.iconarchive.com/icons/cjdowner/cryptocurrency-flat/1024/Tether-USDT-icon.png",
"icon2":"https://s2.coinmarketcap.com/static/img/coins/200x200/8365.png",
"name":"Uniswap LP-V2",
"symbol":"USDT-CWS"
}
}
}, // Two other option objects
]

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.

ThelpTokenParamsparameter 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:

"singleTokenParams":{
"earnToken": {
"address": "Token address",
"icon": "Logo Url",
"name": "Name of the token: Crowns, Eth, USD Tether...",
"symbol": "Symbol of the token: CWS, ETH, USDT..."
},
"stakeToken":{
"address": "Token address",
"icon1":" Logo Url",
"icon2":" Logo Url",
"name": "Name of the token: Crowns, Eth, USD Tether...",
"symbol": "Symbol of the token: CWS, ETH, USDT..."
},
"maxDeposit": 0,
"minDeposit": 0
}

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:

"playerParams":{
"claimed": 0,
"staked": 0,
"stakeTime": 0,
"stakedDuration": 0,
"withdrawn": 0
}

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:

[
{
"category": "scape-nft",
"duration": 25200,
"stakeAmount": 1,
"optionId": 3,
"playerParams": {
"claimed": 2.12,
"stakeTime": 0,
"stakedId": 0,
"stakedDuration": 23
},
"rewardPool": 2000,
"scapeNftParams": {
"earnToken": {
"address": "0x168840Df293413A930d3D40baB6e1Cd8F406719D",
"icon": "https://s2.coinmarketcap.com/static/img/coins/200x200/8365.png",
"name": "Crowns",
"symbol": "CWS"
},
"stakeNft":{
"address": "0x3b00ef435fa4fcff5c209a37d1f3dcff37c705ad",
"icon": "https://icons.iconarchive.com/icons/cjdowner/cryptocurrency-flat/1024/Tether-USDT-icon.png",
"name": "Scape NFT",
"symbol": "SCAPE",
"filters": {
"img_id": 27,
"quality": 5
},
"filterNames": {
"quality": "Legendary",
"imgId": "Mercy",
}
}
}
}, // Two other option objects
]

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.

ThescapeNftParamsparameter 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:

"scapeNftParams": {
"earnToken": {
"address": "0x168840Df293413A930d3D40baB6e1Cd8F406719D",
"icon": "https://s2.coinmarketcap.com/static/img/coins/200x200/8365.png",
"name": "Crowns",
"symbol": "CWS"
},
"stakeNft":{
"address": "0x3b00ef435fa4fcff5c209a37d1f3dcff37c705ad",
"icon": "https://icons.iconarchive.com/icons/cjdowner/cryptocurrency-flat/1024/Tether-USDT-icon.png",
"name": "Scape NFT",
"symbol": "SCAPE",
"filters": {
"imgId": 27,
"quality": 5
},
"filterNames": {
"quality": "Legendary",
"imgId": "Mercy"
}
}
}

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:

"playerParams":{
"claimed": 0,
"stakedId": 0,
"stakeTime": 0,
"stakedDuration": 0
}

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.