# Drinkers

Drinkers (holders of $HOUR): These are the users and community members interacting with the Happy Hour Protocol Engine. These are the happy hour goers, nightlife fist-pumpers, bartenders, and all other alcoholics who make it a priority to support the F\&B industry.

*Start earning $HOUR function. Requires a minimum happy hour fee stake, the PDE's PDEid and its Access Code.*

```
function startHOUR(uint _PDEid, uint _accessCode) public payable {

    uint validPDE;

    for (uint i = 0; i < pdes.length; i++) {
        if (pdes[i]._PDEid == _PDEid && pdes[i]._accessCode == _accessCode) {
            validPDE = 1;
        } else {
            validPDE = 0;
        }
    }

    require(validPDE == 1);
    require(msg.value == happyHourFee, "Invalid Happy Hour Fee.");
    givePoolDrinkingId();
    drinkingIDtoPDEid[drinkingID[msg.sender]] = _PDEid;
    happyHourFeePool += 1;
    timeIN = block.timestamp;
}
```

*Function to stop earning $HOUR*

```
function endHOUR(address payable wiped) public {

    address PDEcommission;
    require(msg.sender == wiped);
    timeOUT = block.timestamp;

    for (uint i = 0; i < pdes.length; i++) {
        if (pdes[i]._PDEid == drinkingIDtoPDEid[drinkingID[msg.sender]]) {
            PDEcommission = pdes[i]._address;
        }
    }

    nullPoolDrinkingId();
    happyHourFeePool -= 1;
    wiped.transfer(1 ether);
    hoursSpentDrinking = (timeOUT - timeIN) / 60 / 60;
    uint HOURearned = hoursSpentDrinking * HOURperhour;
    uint PDEcommissionEarned = HOURearned / PDEcommissionRate;
    _mint(wiped, HOURearned);
    _mint(PDEcommission, PDEcommissionEarned);
    emit endHOURresults(hoursSpentDrinking, HOURearned, PDEcommissionEarned);
}
```

*Each Drinker is designated an ID in order to keep track of current hours accumulated per Drinker during 1 session.*

```
contract poolDrinkingID {

    mapping(address => uint256) public drinkingID;
    uint256 drinkingIDcounter;

    event createdDrinkingID(address user, uint256 id);

    function givePoolDrinkingId() internal returns (uint256)  { 
        require(drinkingID[msg.sender]==0, "You are already drinking.");
        drinkingIDcounter += 1;
        drinkingID[msg.sender] = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender)));
        emit createdDrinkingID(msg.sender,drinkingID[msg.sender]);
        return drinkingID[msg.sender];
    }

    function nullPoolDrinkingId() internal {
        require(drinkingID[msg.sender] != 0, "You haven't started drinking yet.");
        drinkingIDcounter -= 1;
        drinkingID[msg.sender] = 0;
    }

    function getPoolDrinkingId() public view returns(uint256) {
        return drinkingID[msg.sender];
    }

    function getNumberOfCurrentDrinkers() public view returns(uint) {
        return drinkingIDcounter;
    }
}
```

*Getter function to view ETH amount staked in current happy hour fee pool.*

```
function gethappyHourFeePool() public view returns (uint) {
    return happyHourFeePool;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://happy-hour-1.gitbook.io/happyhourdao/the-happyhourdao/drinkers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
