Game Settlement
All About Game Settlement API
Before utilizing these APIs, it is essential to have a clear understanding of the concept of game settlement and ZooGames user wallets.
Ready
You can utilize this API to verify the eligibility of players who wish to join a game while they are in the lobby or waiting room. The API allows you to perform several checks to ensure that each player meets the necessary requirements. These checks include:
Validating the vZOO balance of each player: Ensuring that each player has a sufficient balance of vZOO tokens to participate in the game.
Checking if a player has been banned from the platform: Verifying if a player has been restricted from accessing the game due to violations or other reasons.
Verifying that the cost of joining the game does not exceed the maximum vZOO spending limit set for the game.
Grant access to the user if they pass all the validations of the game settlement.
Checking if the number of players exceeds the limit set for the game: Ensuring that the number of players attempting to join does not exceed the specified limit.
Verifying if the game owner's mirror address has sufficient vZOO balance: This check is useful if the game owner needs to top-up the reward or provide additional funds.
Verifying if the game has been verified by Zoo.Games: This check ensures that the game has undergone the necessary verification process by Zoo.Games.
We recommend that the game server performs these checks for each player upon entry. By calling this API with the relevant player information, the game server can determine if a player meets the criteria. If a player fails to pass any of the checks, the game server should reject their entry and remove them from the lobby or waiting room. This process helps maintain the integrity and fairness of the game environment.
Verify all information of players before starting the game
POST
API_END_POINT_URL/API_KEY/game/ready
SDK Preparation
You need to prepare for SignedSignatureFromPayload by
Installing zoo-game-sdk by npm install zoo-game-sdk
Import SDK by import * as ApiKey from 'zoo-game-sdk/src/auth/apikey/index'
Signing by SDK
let bodyMessage =JSON.stringify(payload);
let hmac = ApiKey.signData(bodyMessage, SEC_KEY);
*Use "hmac" as SignedSignatureFromPayload
Query Parameters
Request Body
This roundId doesn't be used on this time.
Start
After using the "Ready" API to verify the validity of the game settlement, you can proceed to use the "Start" function to initiate the game round. The Start API allows you to lock the specified amounts from the users and the game developer based on your provided parameters.
When calling the "Start" API, it will internally trigger the "Ready" API again for a final check. This ensures that the game settlement is verified before proceeding. Additionally, it is important to maintain the order of user entries, preserving the index of the array to accurately track and process each player's participation.
After executing the "Start" function, remember to record the "roundId" provided by the API. This identifier will be required for subsequent API calls such as the "Game Over" API or "Game Cancel" API, enabling proper tracking and management of the game round.
It is crucial to keep track of the total vZOO spent by the users and the game address during the game round. This information will be necessary for broadcasting the final reward. By accurately recording and storing these values, you can ensure the proper distribution of rewards to the participants.
Overall, by following these guidelines and maintaining the necessary data and order, you can effectively utilize the "Start" API to initiate the game round and proceed with subsequent actions, including reward distribution and game conclusion.
Start the game round
POST
API_END_POINT_URL/API_KEY/game/start
SDK Preparation
You need to prepare for SignedSignatureFromPayload by
Installing zoo-game-sdk by npm install zoo-game-sdk
Import SDK by import * as ApiKey from 'zoo-game-sdk/src/auth/apikey/index'
Signing by SDK
let bodyMessage =JSON.stringify(payload);
let hmac = ApiKey.signData(bodyMessage, SEC_KEY);
*Use "hmac" as SignedSignatureFromPayload
Query Parameters
Request Body
This roundId need to be saved locally to use on futher APIs
Over
The Over API is used to finalize the game round and broadcast the rewards that each user will receive from the locked vZOO pool of a specific game. The rules for distributing rewards are as follows:
The total amount paid by players should not exceed the total locked vZOO in the pool.
Assume you have two players with an entry fee of 100 vZOO each, resulting in a locked vZOO pool of 200 vZOO. If the final reward is 190 vZOO for Player A and 10 vZOO for Player B (determined by the game), you need to call the "Game Over" API with adjusted rewards.
If the game developer is entitled to receive a fee from the players' rewards, it should be deducted accordingly. This deduction occurs after the platform fee calculation.
It's essential to ensure that the total amount paid by players, including the platform fee, does not exceed the locked vZOO pool amount.
If the game developer has topped up additional rewards for this round, it is necessary to follow the rule of "Total paid + Platform Fee <= Locked vZOO Pool amount."
By adhering to these rules and providing the adjusted rewards (after deducting the platform fee and game developer's fee, if applicable), the "Game Over" API can be used to distribute the final rewards to the players.
Finalize the game round with broadcast a reward
POST
API_END_POINT_URL/API_KEY/game/over
SDK Preparation
You need to prepare for SignedSignatureFromPayload by
Installing zoo-game-sdk by npm install zoo-game-sdk
Import SDK by import * as ApiKey from 'zoo-game-sdk/src/auth/apikey/index'
Signing by SDK
let bodyMessage =JSON.stringify(payload);
let hmac = ApiKey.signData(bodyMessage, SEC_KEY);
*Use "hmac" as SignedSignatureFromPayload
Query Parameters
Request Body
This roundId need to be saved locally to use on futher APIs
Over V2
This is similar to V1, but there’s no need to deduct a fee. You can input the full amount of rewards. The only condition is that the total reward amount must match exactly.
For example, if you startAPI request with 4 players and each player has locked 100 vZOO, then the total locked vZOO is 400 vZOO.
With this Over V2 API, you need to distribute all 400 vZOO to the players. The reward amount cannot be less or more than this. It must be exactly 400 vZOO.
Finalize the game round with broadcast a reward
POST
API_END_POINT_URL/API_KEY/game/over_v2
SDK Preparation
You need to prepare for SignedSignatureFromPayload by
Installing zoo-game-sdk by npm install zoo-game-sdk
Import SDK by import * as ApiKey from 'zoo-game-sdk/src/auth/apikey/index'
Signing by SDK
let bodyMessage =JSON.stringify(payload);
let hmac = ApiKey.signData(bodyMessage, SEC_KEY);
*Use "hmac" as SignedSignatureFromPayload
Query Parameters
Request Body
This roundId need to be saved locally to use on futher APIs
Cancel
The Cancel API is used when there is an issue with a specific game round, and you need to cancel it. By calling this API, all the vZOO tokens that were locked, both from the users and the game address, will be returned in their full amount.
Cancel the game round and return all locked vZOO
POST
API_END_POINT_URL/API_KEY/game/cancel
SDK Preparation
You need to prepare for SignedSignatureFromPayload by
Installing zoo-game-sdk by npm install zoo-game-sdk
Import SDK by import * as ApiKey from 'zoo-game-sdk/src/auth/apikey/index'
Signing by SDK
let bodyMessage =JSON.stringify(payload);
let hmac = ApiKey.signData(bodyMessage, SEC_KEY);
*Use "hmac" as SignedSignatureFromPayload
Query Parameters
Request Body
Last updated