dossinstitute / sidequest

Apache License 2.0
0 stars 0 forks source link

Quest Definition and Setup #2

Closed wvwatson closed 1 week ago

wvwatson commented 2 weeks ago

Quest Definition and Setup

Description: Develop a smart contract to enable an admin to create an "Event Quest" with specific parameters.

Depends on #19

Acceptance Criteria:

  1. The contract must allow an admin to create a quest with the following parameters:
    • Event ID (unique identifier for the event)
    • Start and end dates
    • Number of required interactions (minimum three)
    • Reward details (either NFT or token)
  2. Ensure that these parameters are stored securely in the contract.
  3. Provide functions to access these parameters later.

Solidity Smart Contract:

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

contract EventAmbassadorQuest {

    address public admin;

    struct Quest {

        uint256 eventId;

        uint256 startDate;

        uint256 endDate;

        uint256 requiredInteractions;

        string rewardType; // "NFT" or "token"

    }

    mapping(uint256 => Quest) public quests;

    event QuestCreated(uint256 eventId, uint256 startDate, uint256 endDate, uint256 requiredInteractions, string rewardType);

    modifier onlyAdmin() {

        require(msg.sender == admin, "Only admin can perform this action");

        _;

    }

    constructor() {

        admin = msg.sender;

    }

    function createQuest(

        uint256 _eventId, 

        uint256 _startDate, 

        uint256 _endDate, 

        uint256 _requiredInteractions, 

        string memory _rewardType

    ) public onlyAdmin {

        require(_requiredInteractions >= 3, "Required interactions must be at least three");

        require(bytes(_rewardType).length > 0, "Reward type must be specified");

        quests[_eventId] = Quest({

            eventId: _eventId,

            startDate: _startDate,

            endDate: _endDate,

            requiredInteractions: _requiredInteractions,

            rewardType: _rewardType

        });

        emit QuestCreated(_eventId, _startDate, _endDate, _requiredInteractions, _rewardType);

    }

    function getQuest(uint256 _eventId) public view returns (Quest memory) {

        return quests[_eventId];

    }

}

Acceptance Criteria Validation:

This contract meets the specified requirements and ensures that the necessary parameters are both stored and retrievable, with appropriate validation and access control.

wvwatson commented 2 weeks ago

points: 1, 2, 3, 5, 8, 13, 21

@russlive215 5 @Fr0z0n3 5 @noireconnect2024 3 @wvwatson 8

points: 5

noireconnect2024 commented 4 days ago

image

Sponsor Creation worked well - confusion on whether or not I need to add in the Sponsor ID or if that will generate a number after submission.