# Tally Votes

At the end of each epoch, the votes cast in that epoch need to tallied to determine the new `desiredEgl` value. This can be called directly by any wallet, or will get called automatically on any `vote(...)` or `reVote(...)` call if the epoch has ended.

See [Voting Threshold](/protocol-overview/voting/voting-threshold.md) for details regarding participation requirements

See [Calculating desiredEgl](/protocol-overview/voting/calculating-desiredegl.md) for details regarding how the `desiredEgl` is calculated

### 1.`tallyVotes()`

#### Function Signature

```javascript
function tallyVotes() public whenNotPaused
```

#### Validations

| Validation **Rule**                                        | Description                                                          |
| ---------------------------------------------------------- | -------------------------------------------------------------------- |
| `block.timestamp > currentEpochStartDate.add(epochLength)` | Epoch must have ended before the votes for that epoch can be tallied |

#### Events Emitted

* `VoteThresholdMet` (Conditional)
* `VoteThresholdFailed` (Conditional)
* `CreatorRewardsClaimed` (Conditional)
* `VotesTallied`

#### Web3 Example

```javascript
await eglVotingInstance.tallyVotes({ from: "0x2be650ba..."})
```


---

# 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://docs.egl.vote/documentation/tally-votes.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.
