# I Want to Become a Keeper

To become a keeper, you have to do the following:

1. Register a keeper in the PowerAgent contract;
2. Install the PowerAgent software;
3. Activate the keeper in the PowerAgent contract.

## Keeper registration

Keeper registration, activation, management, stake deposit and withdrawal, compensation withdrawal are done via PowerAgent [DApp](https://app.powerpool.finance/#/gnosis/ppv2/agents-contracts).

To register a new keeper, follow the instructions below:

1. Navigate to the PowerAgent Web UI for [Sepolia](https://app.powerpool.finance/#/sepolia/ppv2/my-keepers) or [Gnosis](https://app.powerpool.finance/#/gnosis/ppv2/my-keepers).
2. Press “Connect” and connect with your Admin wallet.
3. Press the “**Create Keeper**” button:
4. Select the most recent agent version. Press the “**Create Keeper**” button at the bottom:
5. In the keeper creation pop-up window, specify the amount of CVP to stake (no less than 1000) and the Worker address which you created beforehand:
6. An “**Unlock”** button will light up. Press and confirm the transaction. Afterwards, press “**Create keeper**”.
7. Afterwards, a keeper will be created, but not activated. Proceed to **Installation Section** and install the node software.

***

## Node installation

Follow one of guides listed below based on the chosen method:

{% tabs %}
{% tab title="Standalone" %}

#### Installation

* Start with a clean **AMD-64** architecture distribution (the code is given for Ubuntu or Debian.
* Install **NodeJS**, **npm**, **Docker**, and **Docker-Compose**
  * Install **NodeJS** and **npm**

    Refer to the [official installation documentation](https://nodejs.org/en/download/package-manager).
  * Install **Docker** and **Docker Compose**

    Refer to the [official installation documentation](https://docs.docker.com/get-docker/).
* Navigate to a directory of your choice:

  ```bash
  cd /path/to/the/directory/of/your/choice
  ```
* Clone the standalone repository and `cd` to it:

  ```bash
  git clone https://github.com/powerpool-finance/powerpool-agent-v2-compose
  cd powerpool-agent-v2-compose
  ```
* Generate the worker keyfile:

  ```bash
  npm i
  node jsongen.js ${YOUR_WORKER_PRIVATE_KEY} ${A_PASSWORD_OF_YOUR_CHOICE}
  ```

  Mind that the password will be specified in the config later on, so remember it.
* Open the config file with a text editor of your choice. For the sake of an example, here we open it with nano

  ```bash
  nano config/main.yaml
  ```
* Fill the file out according to the schema, substituting the variables where needed (numerical values can also be changed, if you so desire). Do not remove `‘’` (quotation marks).

{% hint style="info" %}
&#x20;Do not forget to replace `${variable_name}` with actual variable.
{% endhint %}

* **\[OPTIONAL]** Change the name of the package if you want to run several instances of the PowerAgent on the same machine.

  <pre class="language-bash" data-title="docker-compose.yaml"><code class="lang-bash">version: "3.9"
  services:
      ${SERVICE_NAME}:
          container_name: ${CONTAINER_NAME}
          image: powerpool/power-agent-node:latest
          restart: always
          volumes: 
          - ./config:/usr/app/config 
          - ./keys:/usr/app/keys
          environment:
              NODE_ENV: ${NODE_ENV}
  </code></pre>
* Launch the node.

  ```bash
  docker compose up -d
  docker logs -f ${CONTAINER_NAME}
  ```

{% hint style="info" %}
To get the `${CONTAINER_NAME}`, execute `docker ps` and find the container id. If you changed the name of the container, use it instead.
{% endhint %}

#### Update

In the folder with the `docker-compose.yaml` file run:

```bash
docker compose down --rmi local
docker compose pull
docker compose up -d
```

#### Stop

In the folder with the `docker-compose.yaml` file run:

```bash
docker compose down --rmi local
```

Afterwards, proceed to the [keeper activaton section](https://www.notion.so/I-want-to-become-a-keeper-87d8387be8514c0cb82004d7855243f2?pvs=21).
{% endtab %}

{% tab title="DAppNode" %}

#### Preparation of the keyfile

On your personal machine, clone this repository:

{% embed url="<https://github.com/princesslunaequestrian/keyfile-generator.git>" %}
Temporary repository for keyfile generation
{% endembed %}

And execute the following command:

```bash
npm i
node jsongen.js ${WORKER_PRIVATE_ADDRESS} ${ANY_PASSWORD}
```

The generated keyfile will be written into `./keys/` directory.

***

#### Installation

In order to locate the PowerAgent package,

* Switch your IPFS mode to “**Local**”
* Add the following peers to your DAppNode’s IPFS peer list:

{% code title="Peers List" lineNumbers="true" %}

```http
/ip4/134.122.84.162/tcp/4001/p2p/12D3KooWPJk93THACnrk2LayhBuafoKQTypvssZSQTASU365c8v2
/ip4/134.122.84.162/udp/4001/quic/p2p/12D3KooWPJk93THACnrk2LayhBuafoKQTypvssZSQTASU365c8v2
/ip4/134.122.84.162/udp/40202/quic/p2p/12D3KooWPJk93THACnrk2LayhBuafoKQTypvssZSQTASU365c8v2
```

{% endcode %}

{% hint style="info" %}
To add peers in DAppNode,&#x20;

* Locate the IPFS package in the System Packages menu;

* Navigate to Peers - Add Connection;

* Open WebUI;
  {% endhint %}

* Navigate to the [most recent package version](https://www.notion.so/59ab36698b8e417db9be39bdd432a42f?pvs=21) either through the installer link or by the IPFS hash. Accept “<mark style="background-color:yellow;">bypass unsigned restriction</mark>” and press install.

* Fill in the fields when prompted by DAppNode installation UI:

{% code title="Fields to fill" overflow="wrap" lineNumbers="true" %}

```yaml
Worker address          #This field should contain
                        #the address of your worker.
                        
Worker key              #Remember the keyfile you generated?
                        #Upload it here.
                        
Worker keyfile password #The password to the keyfile you chose
                        #during generation
                        
Network                 #Sepolia or Gnosis, whichever network
                        #you are running on
                        
Execution client RPC    #The Websockets RPC address
                        #of the execution client,
                        #which PowerAgent will connect to.
                        #Look it up in the logs tab
                        #of your execution client you installed earlier.
                        #The default for Sepolia Geth may be like
                        #ws://sepolia-geth.dappnode:8546.
                        
Agent address           #The address of the latest version
                        #of the PowerAgent contract
                        #on the appropriate chain.
       
####Leave these empty:####             
Data source
Graph URL
API Server
Sentry SDK data source name
##########################

Number of blocks to elapse before a tx is resent or dropped #4
Max gase price in GWei for tx resending                     #500
Maximal resending attempts number                           #4
Logging level                                               #"debug"

Accrue reward on the poweragent address
#True/False. Default: False.
#This value governs whether you accrue the rewards on your worker address or have them transferred immediately upon conferring. Keep in mind that the former option is more gas-efficient.

Execute tasks when block base fee is greater than max base fee
#True/False. Default: False.
#This field also accepts a Boolean value. In PowerAgent, the Job owner may set an upper bound on the gas cost for the purposes of reward computation. If you wish to execute the transaction even in the case of such an upper bound depressing your reward amount, select True.

Max Priority Fee Per Gas
#Default: 60000 This field accepts an integer value, to which the max priority fee per gas shall be set.
```

{% endcode %}

#### Update

The package update is as straightforward as possible: locate the new package by its IPFS hash and press “Update”. The configuration from the previous version will persist.
{% endtab %}

{% tab title="Compose Integration" %}
PowerAgent Node can be added as a service into another docker container.

* Create `/config` and `/keys` folders alongside your `docker-compose.yaml` file.
* Follow the Standalone instructions to obtain the keyfile and the `main.yaml` config file and place them into the corresponding folders.
* Add the following service into the `docker-compose.yaml`:

```yaml
        agent-latest:
                image: powerpool/power-agent-node:latest
                restart: always
                volumes: 
                - ./config:/usr/app/config 
                - ./keys:/usr/app/keys
                environment:
                    NODE_ENV: ${NODE_ENV}
```

* Execute `docker-compose up -d agent-latest` in the folder with `docker-compose.yaml`.
  {% endtab %}
  {% endtabs %}

#### Example configs for standalone installation:

{% tabs %}
{% tab title="Gnosis" %}

```yaml
networks:
  enabled:
     - gnosis
  details:
    gnosis:
      rpc: 'your_rpc_address'
      block_logs_mode: true
      agents:
        '0x071412e301C2087A4DAA055CF4aFa2683cE1e499':
          data_source: subgraph
          subgraph_url: https://api.studio.thegraph.com/proxy/48711/ppav2-rd-gnosis-b12-ui/version/latest
          executor: pga
          keeper_worker_address: 'your_keeper_worker_address'
          key_pass: 'your_password'
          accrue_reward: false
```

{% endtab %}

{% tab title="Sepolia Testnet" %}

```yaml
networks:
  enabled:
     - sepolia
  details:
    sepolia:
      rpc: 'your_rpc_address'
      block_logs_mode: true
      agents:
        '0xbde2aed54521000dc033b67fb522034e0f93a7e5':
          data_source: subgraph
          subgraph_url: https://api.studio.thegraph.com/query/48711/ppav2-rd-sepolia-b12-ui/version/latest
          executor: pga
          keeper_worker_address: 'your_keeper_worker_address'
          key_pass: 'your_password'
          accrue_reward: false
```

{% endtab %}

{% tab title="Mainnet" %}

```yaml
networks:
  enabled:
     - mainnet
  details:
    mainnet:
      rpc: 'your_rpc_address'
      block_logs_mode: true
      agents:
        '0xc9ce4CdA5897707546F3904C0FfCC6e429bC4546':
          data_source: subgraph
          subgraph_url: https://api.studio.thegraph.com/query/48711/ppav2-rd-maintest-ui/version/latest
          executor: pga
          keeper_worker_address: 'your_keeper_worker_address'
          key_pass: 'your_password'
          accrue_reward: false
```

{% endtab %}
{% endtabs %}

***

🥳 This concludes the installation + configuration process. Good job! Now the keeper must be activated in order to be able to execute transactions.

***

## Keeper activation

After installation, go back to the [DApp](https://app.powerpool.finance/#/gnosis/ppv2/my-keepers), open “My Keepers” tab and expand the entry for your newly registered keeper.

The status of the keeper will be “**Activating**”. Next to it, locate the “**Complete**” button and confirm the transaction:

<figure><img src="https://1086986195-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJqrcOKqAefjDPcq_0d%2Fuploads%2FYcfeJTTHVkITsBu9cmEh%2FUntitled(1).png?alt=media&#x26;token=b1399ff5-3fa4-4075-93c1-29bccd95352f" alt="" width="375"><figcaption></figcaption></figure>

Verify that the keeper is active:

<figure><img src="https://1086986195-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJqrcOKqAefjDPcq_0d%2Fuploads%2FH5eAXcCxJGtSCtBNIOh4%2FUntitled(2).png?alt=media&#x26;token=63630fc8-07a9-410f-91ba-46e803607baf" alt="" width="351"><figcaption></figcaption></figure>

***

## Managing Keepers

On the **My Keepers** tab you can see all your registered keepers; both active and inactive.

Click on the keeper entry to expand the detailed view:

<figure><img src="https://1086986195-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJqrcOKqAefjDPcq_0d%2Fuploads%2FDz0hGEbxqS8wmpeLh5Si%2FUntitled.png?alt=media&#x26;token=fe96295e-c394-4d21-bdec-769df6375977" alt=""><figcaption></figcaption></figure>

1. Summary tab.

   Here you can see the total number of your keepers, sum of all their CVP stakes and their total earnings in native token.
2. Keeper stats tab.

   Here the key metrics of your keeper are presented: active and pending withdrawal CVP stake, number of jobs completed, and detailed balance.
3. Control tab.

   On this tab you can stake or withdraw CVP for your keeper, as well as withdraw native token earnings.


---

# 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.powerpool.finance/powerpool-and-poweragent-network/power-agent/user-guides-and-instructions/i-want-to-become-a-keeper.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.
