# Installation

{% hint style="info" %}
For any additional questions or needed support please access our Discord\
<https://discord.com/invite/ACqqn8d5>
{% endhint %}

## Prerequisites

### Hardware Requirements

* [RDDL Energy Agent](https://docs.rddl.io/rddl-network/getting-started/the-energyagent)
* [Trust Wallet](https://docs.rddl.io/rddl-network/getting-started/trust-anchor)
* Network connection (Ethernet or WiFi)
* Power supply for Energy Agent
* [Smart Metering Device (SMD)](https://docs.rddl.io/rddl-network/getting-started/smd-smart-metering-device)

### Initial Setup

#### **Finding Your Device on the Network**

You first need to identify the IP Address for your Energy Agent via you local network.&#x20;

Using your router's admin interface:

* Look for connected devices
* Find the device named "recomputer", "r1000" or similar
* Once identified, set the Energy Agent to a static IP on the Network&#x20;

#### **Connecting to Your Device**

Once identified you need to ssh to the Energy Agent:

* open up a terminal
* Enter the SSH command: \
  `ssh recomputer@<YOUR_DEVICE_IP>`\
  and hit Enter
* On first connection, you'll see a security prompt about the host's authenticity:\
  `The authenticity of host '<IP>' can't be established... Are you sure you want to continue connecting (yes/no/[fingerprint])?`\
  Type "yes" and press Enter
* When prompted for password, enter:\
  `12345678`
* For security purposes, it's strongly recommended to change the default password immediately after first login.\
  Run the password change command:\
  `sudo passwd`

## Energy Agent Installation

Once connected via ssh maneuver to a desired directory to run the following 3 commands:

{% tabs %}
{% tab title="Copy the following command:" %}
{% code overflow="wrap" %}

```bash
wget https://raw.githubusercontent.com/rddl-network/EnergyAgent/main/prepare_energy_agent.sh
```

{% endcode %}
{% endtab %}
{% endtabs %}

Confirm with Enter

{% tabs %}
{% tab title="Copy and paste the following command:" %}

```bash
chmod 755 prepare_energy_agent.sh
```

{% endtab %}
{% endtabs %}

Confirm with Enter

{% tabs %}
{% tab title="Copy and paste the command:" %}

```bash
./prepare_energy_agent.sh
```

{% endtab %}
{% endtabs %}

Confirm with Enter

The above commands will download an installation script that executes the following tasks:

a) Updates your system

b) Installs docker

c) Downloads the latest docker-compose file

d) Loads the docker-compose file and starts the Energy Agent and its dependencies

## Configuration

The client's default configuration should be sufficient to start working on this set-up guide. The [EnergyAgents Readme on Git Hub](https://github.com/rddl-network/EnergyAgent) gives an overview of the environment variables that can be adjusted.

The EnergyAgent appears on the device's IP at port 2138 per default. \
In a browser, open up \<YOUR\_DEVICE\_IP>:2138 \
example: 192.168.1.100:2138

### Initialize the TrustWallet

The TrustWallet comes pre-provisioned and attested to be used on the mainnet. However, the EnergyAgnt needs a set of unique keys before connecting to the mainnet, so the TrustWallet needs to be configured. Within the TrustWallet menu (select Trust Wallet Icon on the left), then click **Create Mnemonic**.&#x20;

<figure><img src="https://2459376652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3ylQ6zh9lLdOSSmCZHg4%2Fuploads%2FfmiWoS63roldsWjgYP4H%2Fimage.png?alt=media&#x26;token=b903ffd6-ec6c-4656-bacf-4274bbd01bb5" alt=""><figcaption></figcaption></figure>

Click **Create Mnemonic** a second time to generate your Mnemonic Phrase.

{% hint style="warning" %}
Please write down and store the resulting mnemonic phrase in a safe and private place. It's the only way to recover your funds if necessary.
{% endhint %}

<figure><img src="https://2459376652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3ylQ6zh9lLdOSSmCZHg4%2Fuploads%2FFPTcTIMZ9TwDB856IE2H%2F02-mnemonoic_result.png?alt=media&#x26;token=9f646a36-bf62-4a7c-b39e-33b8da684841" alt=""><figcaption></figcaption></figure>

### On-chain account creation

The machine attestation process to register EnergyAgent on the chain is free. However, the chain must know about your account in advance to accept signed transactions.  That's why the account needs to be created after the TrustWallet is initialized.\
\
Select Trust Wallet Icon on the left. Then select **Create Account**. And then hit **Create Account** a second time.

<figure><img src="https://2459376652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3ylQ6zh9lLdOSSmCZHg4%2Fuploads%2FsRnJoJHfFS7FUgNRugXy%2F04-create_on_chain_account.png?alt=media&#x26;token=3919b118-67c7-4129-ab08-75023e4437c9" alt=""><figcaption></figcaption></figure>

Please wait for a successful response. Retry if the requests aren't successful.

<figure><img src="https://2459376652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3ylQ6zh9lLdOSSmCZHg4%2Fuploads%2FOWcNdk8UwNKaRTrfiHO4%2F05-onc-chain-account-success.png?alt=media&#x26;token=cbe83810-e96c-49cb-a9bd-428f2ed04ed9" alt=""><figcaption></figcaption></figure>

### RDDL-Network interaction

The initial RDDL Network interaction can be broken down into the following aspects.

Both can be accessed via the RDDL Network Icon on the left side of the screen.

Before attesting your Machine please change the **Machine Name** and **Additional Information** (must be data filled) to something private.\ <br>

<figure><img src="https://2459376652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3ylQ6zh9lLdOSSmCZHg4%2Fuploads%2FuOY5nUNYO9bx3XRmi6L6%2F06-rddl-page.png?alt=media&#x26;token=636b094a-51d3-4170-baeb-c67a3d15d0db" alt=""><figcaption></figcaption></figure>

The page will initially show:&#x20;

* The address on planetmint
* an initial balance of 1 plmnt
* a sequence number of 0
* a non-existing attestation

Then click **Attest Machine** which will create and broadcast a machine attestation transaction on Planetmint. Then Select **NOTARIZE.**

<figure><img src="https://2459376652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3ylQ6zh9lLdOSSmCZHg4%2Fuploads%2FStFEr7OASLgiD96vadzk%2F08-rddl-page-see-log-result.png?alt=media&#x26;token=bddb7da9-e7bd-4730-b3bb-4e7f2df81f93" alt=""><figcaption></figcaption></figure>

The Logline will contain an error message or the transaction ID of the transaction being created and broadcasted. The transaction ID can be inspected on the [explorer](https://explorer.rddl.io/planetmint) after the next block consensus which happens every 24 seconds.

Notarization requests can be issued by clicking the Notarize button on the RDDL Network page.

### Connecting to SMDs (MQTT configuration)

The MQTT Config page enables connecting to SMDs.

&#x20;Enter the local IP, the default port 1883, or any other MQTT service used with the SMD's

* Select Energy Agent MQTT

The local MQTT service comes without a user/password per default. This can of course be changed.

<figure><img src="https://2459376652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3ylQ6zh9lLdOSSmCZHg4%2Fuploads%2FejfTHIJXkYS7QQp7AyDN%2Fimage.png?alt=media&#x26;token=a8c4845b-47eb-4e19-a123-49f6d4653f22" alt=""><figcaption></figcaption></figure>

### Starting the EnergyAgent

Select **Start Agent** button on the upper right side.\
The Energy Agent will start notarizing periodically after clicking the **Start Agent.**

<figure><img src="https://2459376652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3ylQ6zh9lLdOSSmCZHg4%2Fuploads%2FWj5HoXjDT3x0lK6QjB0B%2FMqtt%20Start%20Agent.png?alt=media&#x26;token=bbccedaa-5e76-4c16-8a24-ffb998d9d885" alt=""><figcaption></figcaption></figure>
