# Claiming Miner Rewards

Miners and mining pools are awarded EGL's when they produce a block with a gas limit that is within 1,000,000 of the `desiredEgl`. The reward amount is based on how close the block gas limit is to the `desiredEgl` value.&#x20;

See [Mining Pool Reward](/protocol-overview/miner-rewards.md) for details

The reward must claimed by calling the `sweepPoolRewards()` and rewards for the block it is included in. The function can be called by anyone but the reward always goes to the `block.coinbase` address so the intention is for miners to include this transaction when they produce the block

### 1.`sweepPoolRewards()`

#### Function Signature

```javascript
function sweepPoolRewards() external whenNotPaused
```

#### Validations

| Validation **Rule**                | Description                                                                      |
| ---------------------------------- | -------------------------------------------------------------------------------- |
| `block.number > latestRewardSwept` | If the reward for the block has already been claimed, it cannot be claimed again |

#### Events Emitted

* `BlockRewardCalculated`
* `Transfer` (Conditional)
* `PoolRewardsSwept`

#### Web3 Example

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

#### Python Example

This example shows how to create, sign and send the raw transaction which calls `sweepPoolRewards()`

```python
import sys
from web3 import Web3

if __name__ == "__main__":
    chainId = int(sys.argv[1])
    eglContractAddress = sys.argv[2]
    accountPvtKey = sys.argv[3]
    accountNonce = int(sys.argv[4])

    w3 = Web3(Web3.HTTPProvider())
    transaction = {
        "to": eglContractAddress, 
        "value": 0, 
        "gas": 78000, 
        "gasPrice": int(10*1e9), 
        "nonce": accountNonce, 
        "chainId": chainId, 
        "data": "0x112bbd1d"
    }
    signed_tx = w3.eth.account.sign_transaction(transaction, accountPvtKey)
    print(signed_tx.rawTransaction.hex())
    w3.eth.send_raw_transaction(signed_tx.rawTransaction)

```


---

# 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/functions-1.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.
