Skip to content

Architecture

decent-dev edited this page Feb 6, 2019 · 16 revisions

The architecture for the PlayDBET platform are based on the assumptions that all quest and tournament entries are to be paid for and validation on-chain on the deployed Quest and Tournament smart contracts.

Quests and tournaments can be added by DBET admins. Quest outcomes are also pushed by DBET admins on-chain after verifying whether a user has successfully completed a quest within the prescribed time to complete it.

A platform wallet address is assigned to handle user entry fees and successful quest completion prize payouts. This address would be periodically replenished with DBETs allowing users to receive payouts for all completed quests.

An overview of the PlayDBET Quest architecture is outlined in the diagram below:

Quest contracts architecture

The Quest contract has the following functions as outlined in the overview:

setPlatformWallet()

This is callable by the owner of the contract. It requires the following arguments:

address _platformWallet

Allows the owner to change the platform wallet address, which is used for receiving entry fees and processing payouts.

addQuest()

This is callable by admins of the contract. It requires the following arguments:

bytes32 id,
uint256 entryFee,
uint256 timeToComplete,
uint256 prize

Allows admins to add quests to the contract from the off-chain admin UI. Quests are required to be passed unique quest IDs along with the entry fee and prize amount in DBETs. Also, the time to complete a quest from the point of starting it - for which the prize would be valid.

If successfully executed a LogNewQuest(bytes32 id) event will be emitted.

setQuestOutcome()

This is callable by admins of the contract. It requires the following arguments:

bytes32 id,
address user,
uint8 outcome

The outcome passed here stems from the following QuestStatus enum:

enum QuestStatus {
    STARTED,
    SUCCESS,
    FAILED
}

Base on PlayVig's verification of a user's quest completion status, admins can pass whether the user successfully completed or failed to complete a quest.

If successfully executed, a LogSetQuestOutcome(id, user) event will be emitted.

payForQuest()

This is callable by users of the contract. It requires the following arguments:

bytes32 id

The contract will check whether the user has already started the quest and whether the user has a balance of and has approved entryFee DBETs for the contract to transfer. If all conditions are true, a UserQuestEntry will be added with a QuestStatus of QuestStatus.STARTED.

If successfully executed, a LogPayForQuest(id, user) event will be emitted.

payForQuestWithCoupon()

Clone this wiki locally