Why does Zapankiswap use Chainlink?
Technical Flow for Player Interaction on the Platform:
Transaction 1 — Placing Wager and VRF Fee
The initial transaction involves two key components: placing the wager and covering the VRF fee (1):
Wager Players initiate the gaming process by invoking the play function within any Game Contract, thus staking a wager. This wager, represented as a bet token, is seamlessly transferred to the relevant Game Contract.
VRF Fee The VRF fee is denominated in the platform’s native token. In the context of Chains utilizing the Chainlink VRF mechanism, the VRF fee is sent to the Game Contract. Concurrently, any surplus VRF fee paid by the player is promptly reimbursed in the same transaction.
In instances where Randomizer VRF is employed, the VRF fee is directed to the Randomizer contract. Should a player inadvertently overpay for the VRF, reimbursement is scheduled for the subsequent instance of the same game.
Transaction 2 — Random Number Generation and Payout
The subsequent transaction encompasses the Random Number Generation (RNG) procedure and the eventual payout (if applicable):
- The Game Contract initiates a request to the VRF Contract, soliciting the requisite random numbers (2).
- The VRF Contract promptly resolves the random number request and communicates the results to the Game Contract (3).
- The Game Contract proceeds to ascertain the outcome based on the random numbers received. Subsequently, the initial wager is transferred to the Diamond Contract, which functions as the bankroll (4).
- In scenarios where a player secures a winning outcome, the bankroll disburses the payout concurrently (5). Conversely, if the player experiences a loss, the bankroll retains the wager without initiating any payout.
Important Note: The safety of player funds remains paramount. In situations where the VRF request encounters an error or the bankroll is unable to facilitate a payout, the transaction either reverts to its prior state, or the wager becomes temporarily held within the Game Contract. To rectify such instances, players can utilize the refund function accessible through “Pending VRF Requests” on their profile page, ensuring the retrieval of their bet.
Betting and VRF Fees
- 1.All games are played in the game contract and funds are transferred to the contract.
- 2.VRF fees are charged in native tokens (ex. $MATIC). For chains using Chainlink VRF, the VRF fee is transferred to the game contract, and a refund of the VRF fee is sent to the player if the player pays too much in the same transaction. For chains using randomizer VRF, VRF fees are transferred to the randomizer contract. If a player overpays for VRF, the player will receive a refund the next time they play the same game.
Note: Player's funds are not at risk. If the VRF request fails or the funds are unable to pay, the transaction will be reversed or the bet will be locked in the game contract. Players can then remove their bets with the refund function in their profile page's pending VRF request.