# Run an Aggregator Node

The Othentic CLI includes built-in node software that AVS Operators run to participate in consensus.

#### Read More

* [Node Operators: Aggregator](https://docs.othentic.xyz/main/learn/core-concepts/operator-roles#aggregators)
* [CLI Command Reference ](https://docs.othentic.xyz/main/reference/otnode/aggregator)

## Prerequisites

1. [Othentic Node Software installed](https://docs.othentic.xyz/main/welcome/getting-started/install-othentic-cli)
2. [**Registered** Operator on EigenLayer and AVS](https://docs.othentic.xyz/main/user-guide/operator-management/register-to-avs)
3. **Non zero** Voting Power in the AVS Attestation center contract
4. AVS Contract addresses&#x20;

{% stepper %}
{% step %}

### Environment Setup

Create or edit a `.env` file with your configuration:

* ﻿﻿Specify `L1_CHAIN` and `L2_CHAIN` variables; See [Supported Networks](https://docs.othentic.xyz/main/reference/supported-networks) page for chain names
* ﻿﻿Specify `L1_RPC` and `L2_RPC`, ensure you are using paid, reliable RPC endpoints
* ﻿﻿Specify the&#x20;
  * `PRIVATE_KEY`: Set this to the Consensus Key
  * `OPERATOR_ADDRESS`: Set this to the public address of the Controller Key.\
    the public address of the account that has signed up with the shared security protocol - the address to which stakers delegate their staked assets

```sh
# Network Configuration
BOOTSTRAP_NODE_ID=12D3KooW... # Bootstrap Peer ID

# Chain Configuration
L1_CHAIN=holesky              # Single L1 chain
L2_CHAIN=amoy,base-sepolia    # Comma-separated L2 chains

# RPC Endpoints
L1_RPC=<HOLESKY_RPC_URL>
L2_RPC=amoy@<AMOY_RPC_URL>,base-sepolia@<BASE_SEPOLIA_RPC_URL> # Comma-separated L2 names@RPCs

# Operator Configuration
OPERATOR_ADDRESS=0x...        # Operator public address
PRIVATE_KEY=0x...             # Consensus Key if separating operator keys
```

{% endstep %}

{% step %}

### Running Aggregator Nodes

{% tabs %}
{% tab title="Basic Command" %}

```
otnode run aggregator \
  --json-rpc \
  --l1-chain holesky \
  --l2-chain amoy,base-sepolia \
  --internal-tasks \
  --metrics \
  --delay 1500
```

{% endtab %}

{% tab title="Production Command" %}

```
otnode run aggregator \
  "/ip4/10.0.1.100/tcp/9876/p2p/12D3KooWAgg1,/ip4/10.0.1.101/tcp/9876/p2p/12D3KooWAgg2" \
  --l1-chain mainnet \
  --l2-chain base,polygon \
  --metrics \
  --p2p.datadir ./aggregator-data \
  --status-check-interval 8000 \
  --announced-addresses "/dnsaddr/aggregator.mynode.com/tcp/9876/p2p/12D3KooWMyPeerID"
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}
**Health Check**

When running the node with the `--json-rpc` flag, the RPC server starts and provides a `/healthcheck` endpoint to verify its status. For example:&#x20;

```bash
curl -X GET http://localhost:8545/healthcheck
```

This endpoint should return `OK` if the node is functioning properly, indicating the RPC service is active. For more detailed monitoring, use [Metrics](https://docs.othentic.xyz/main/learn/advanced-concepts/p2p-networking/metrics-and-monitoring) or [Logging](https://docs.othentic.xyz/main/learn/advanced-concepts/p2p-networking/logging).
{% endstep %}
{% endstepper %}

## Advanced Features

<details>

<summary>Custom P2P Messaging</summary>

Use `--json-rpc.custom-message-enabled`  flag to enable custom p2p messaging if required by the AVS.

```
otnode run aggregator \
    --json-rpc \
    --json-rpc.custom-message-enabled
```

For more information, see the [Custom Messaging](#custom-p2p-messaging) page.

</details>

<details>

<summary>Operator Status Throttling</summary>

Use `--status-check-interval` to enable throttling mechanism to reduce idle RPC usage, with a default of 5000 milliseconds.

```
otnode run aggregator \
  --json-rpc \
  --status-check-interval 8000 
```

</details>

The following configurations are **mandatory** for production AVSs.

<details>

<summary>Metric Collection &#x26; Monitoring</summary>

Enable performance metrics collection:

```
otnode run aggregator \
  --json-rpc \
  --metrics
```

For more information, see the [**Metrics and Monitoring**](https://docs.othentic.xyz/main/learn/advanced-concepts/p2p-networking/metrics-and-monitoring) page.

</details>

<details>

<summary>Persistent Storage</summary>

Enable P2P layer data caching and peerStore usage:

```
otnode run aggregator \
  --json-rpc \
  --p2p.datadir ./data
```

For more information, see the [**Persistent Storage**](https://docs.othentic.xyz/main/learn/advanced-concepts/p2p-networking/persistent-storage) page.

</details>

<details>

<summary>Announced Addresses (NAT/Load Balancer Support)</summary>

The `announce` option in libp2p allows nodes to explicitly define which addresses they advertise to peers, **overriding** any automatically detected addresses. This is particularly useful when running behind a **load balancer or NAT**, where the external address needs to be manually set.

Use the following flags to configure how your node builds its announced addresses:&#x20;

`--p2p.public-ip`&#x20;

e.g., `--p2p.public-ip 203.0.113.1`&#x20;

`--p2p.dns-url`&#x20;

e.g., `--p2p.dns-url aggregator.example.com`&#x20;

The node will automatically generate multiaddresses in the following format:&#x20;

```bash
othentic-cli node aggregator \
--json-rpc \
--p2p.public-ip 203.0.113.1 \
--p2p.dns-url aggregator.example.com
```

***

1. Get **Peer ID** using following command

```bash
othentic-cli node get-id --node-type aggregator
```

2. Add the **Peer ID** from above step in the below option&#x20;

```bash
othentic-cli node aggregator \
  --json-rpc \
  --announced-addresses "/dnsaddr/my-node.example.com/tcp/9876/p2p/{Peer ID},/ip4/203.0.113.1/tcp/9876/p2p/{Peer ID}"
```

</details>

Here is a [link](https://github.com/Othentic-Labs/simple-price-oracle-avs-example/blob/7b500b8ebb9073da66ae42d7276d73f7a79aeece/docker-compose.prod.yml#L8) to the docker file to run an <mark style="color:orange;">Aggregator node</mark>

### Next Steps :

Refer to the AVS-specific documentation for detailed instructions on running an Operator.
