# CLI (Command Line Interface)

### 1. Install & Update

#### Important Notes

* You **cannot run multiple instances** of the Datagram CLI on the same machine simultaneously (e.g., Linux CLI and Windows GUI together). Doing so may cause unexpected errors.
* Always ensure you are running the [latest version](https://github.com/Datagram-Group/datagram-cli-release/releases) of the CLI.

### 2. Download the Latest Version

You can download the latest Datagram CLI binary from the official releases page:

```
https://github.com/Datagram-Group/datagram-cli-release/releases/latest/download/datagram-cli-<target-platform>
```

**Replace \<target-platform> with your specific OS and architecture.**\
Currently supported values include

* aarch64-apple-darwin – for Apple Silicon (M-series Macs)
* x86\_64-apple-darwin – for Intel-based Macs
* x86\_64-linux – for Linux systems

**Example commands for Linux/macOS:**

```
wget https://github.com/Datagram-Group/datagram-cli-release/releases/latest/download/datagram-cli-x86_64-linux
chmod +x ./datagram-cli-x86_64-linux
```

#### License Requirement

During the Alpha Testnet, a free Full Core Node License is automatically provided to every newly created account.\
\
For more details, see the [Alpha Testnet Info](/alpha-testnet/what-is-alpha-testnet.md).

#### Run the Datagram CLI with License Key

Run the CLI with your full core license key as follows:

```
./datagram-cli-<target-platform> run -- -key <fullcore-license-key>
```

Replace **\<fullcore-license-key>** with your actual license string.

### 4. Running a Partner Core Node

#### 1. Request a Partner License

Get your partner license from the Datagram License Portal. Partner licenses support running multiple nodes under one license and distributing rewards to the license owner.

Follow the steps below to request a Partner License:

**Step 1:** Navigate to the [Datagram website](https://demo.datagram.network/) and log in to your account.

**Step 2:** Navigate to the **“Wallet”** section from the left sidebar, then click on the **“Licenses”** tab at the top of the screen.

<figure><img src="/files/ZTDrkgu0veWKn04KAfcY" alt=""><figcaption></figcaption></figure>

**Step 3:** Click the **Request partner license** button located in the upper-right corner of the screen.

<figure><img src="/files/iwDzaG1vpimq7zNVUe0b" alt=""><figcaption></figcaption></figure>

**Step 4:** In the pop-up window titled **"Request Partner Core License,"** enter the **Project Name** (e.g., NodeSync) and click the **Confirm** button.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXd2edzoYkgVDQti7oEr_4CU8KQH-h3ZwJPGQFPnxCClpHgX6ayLoHebsPZctiZp7jaZiQvSSWVD2dRCcENljdaDCtt1QAw4HB8F4dV7ol8tGc_ZJlugCNl5y6H2ERLhtz78IgNCaw?key=MilIq1SGbhZM3vtjOuu6rQ" alt=""><figcaption></figcaption></figure>

**Step 5:** Once submitted, your license request will appear in the Licenses table with the status marked as **"Requested."**

<figure><img src="/files/YQL5pzGsXP8R9YB87OF7" alt=""><figcaption></figcaption></figure>

#### 2. Partner Key Format

The partner key uses a multi-key format with key-value pairs:

```
/key_1/value_1/key_2/value_2/...
```

Key parameters include:

* **secret (required):** Partner license string.
* **id (required):** External ID for tracking within your system.
* **address (required):** Reward recipient address; defaults to the license owner's address if not provided.

#### 3. Run the CLI with Partner License

Example command:

```
./datagram-cli-<target-platform> run -- -key /secret/<partner-license>/id/<external-id>/address/<reward-address>
```

Replace placeholders with your actual values.

### 5. Running Datagram CLI with Docker

#### Docker Setup Overview

You can run the Datagram node inside a Docker container using the provided Dockerfile `entrypoint.sh` and  `run.sh` scripts.

#### Dockerfile

```
FROM ubuntu:20.04 AS base

RUN apt-get update && \
  apt-get install -y wget

# Install Datagram CLI
RUN wget https://github.com/Datagram-Group/datagram-cli-release/releases/latest/download/datagram-cli-x86_64-linux && \
  chmod +x ./datagram-cli-x86_64-linux && \
  mv datagram-cli-x86_64-linux /usr/bin/datagram

COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
```

#### Entrypoint Script (`entrypoint.sh`)

```
#!/bin/bash

# Check if DATAGRAM_KEY environment variable is set
if [ -z "$DATAGRAM_KEY" ]; then
  echo "Error: DATAGRAM_KEY environment variable is not set." >&2
  exit 1Datagram Node CLI Usage Guide
fi

# Run datagram with the provided key
datagram run -- -key "$DATAGRAM_KEY"
```

#### Run Script (`run.sh`)

```
#!/bin/sh

# Example environment variable exports:
# For full core license:
# export DATAGRAM_KEY=fullcore-license-key
# For partner license:
# export DATAGRAM_KEY=/secret/here-is-partner-license/id/here-is-external-id

export DATAGRAM_KEY=/secret/here-is-partner-license/id/here-is-external-id/address/0x00abc

docker build --platform linux/amd64 -t datagram .

docker run \
  --platform linux/amd64 \
  --env DATAGRAM_KEY=$DATAGRAM_KEY \
  --rm -it \
  datagram
```

### 6. Uninstalling

Since this is a CLI binary or Docker container, uninstalling typically involves removing the binary file or stopping/removing the container. If you used manual installation steps, simply delete the binary file:

```
rm ./datagram-cli-<target-platform>
```

For Docker, remove images and containers as usual.

### 7. Updating the CLI

To update, download the latest release from the releases page and replace your existing binary. If using Docker, rebuild the Docker image using the latest `Dockerfile` and `run.sh`.

### 8. Additional Notes

* Always verify your license key and environment variables before starting the node.
* For partner nodes, ensure your external ID and reward address are correctly set.
* Docker usage allows easier environment isolation and management, but requires Docker to be installed and configured.


---

# 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://doc.datagram.network/additional-tools/cli-command-line-interface.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.
