# Using Binary

This guide describes how to deploy a Pharos node using pre-compiled binaries and the ops tool.

## **Prerequisites**

| Component         | Specification                                                     |
| ----------------- | ----------------------------------------------------------------- |
| CPU               | 32 cores, 2.8GHz or faster, AMD Milan EPYC or Intel Xeon Platinum |
| Memory            | 256 GB                                                            |
| Storage           | 5 TB SSD with at least 350MiB/s bandwidth and 30000 IOPS          |
| Network Bandwidth | 0.5 Gbps                                                          |
| Open Files Limit  | ulimit -n ≥ 10000000                                              |

## **1. Create working directory and download binary package**

```bash
export WORKSPACE=pharos
mkdir -p /data/$WORKSPACE && cd /data/$WORKSPACE
```

Download the latest binary release from GitHub:

```bash
wget https://github.com/PharosNetwork/resources/releases/latest/download/pharos-v0.12.2-f301031a.tar.gz
tar -zxvf pharos-v0.12.2-f301031a.tar.gz
```

The extracted package contains:

* `bin/pharos_light` - Pharos node binary
* `bin/pharos_cli` - Pharos CLI tool
* `bin/libevmone.so` - EVM execution engine library

## **2. Download configuration files**

Download the genesis configuration and VERSION file based on your network:

**For Atlantic Testnet:**

```bash
wget -O genesis.conf https://raw.githubusercontent.com/PharosNetwork/resources/refs/heads/main/atlantic.genesis
wget -O bin/VERSION https://raw.githubusercontent.com/PharosNetwork/resources/refs/heads/main/atlantic.version
```

**For Mainnet:**

```bash
wget -O genesis.conf https://raw.githubusercontent.com/PharosNetwork/resources/refs/heads/main/mainnet.genesis
wget -O bin/VERSION https://raw.githubusercontent.com/PharosNetwork/resources/refs/heads/main/mainnet.version
```

> **Note:** When upgrading to a new version, you must also re-download the VERSION file to keep it in sync.

Download the node configuration file (choose one based on your node type):

**For Archive/Full/Validator Node:**

```bash
wget -O pharos.conf https://raw.githubusercontent.com/PharosNetwork/resources/refs/heads/main/conf/full.conf
```

> **Note:** Pruning is disabled by default. To enable pruning, see [Enable Pruning in Pharos Node](/enable-pruning-in-pharos-node.md).

**For TraceDB Node:**

```bash
wget -O pharos.conf https://raw.githubusercontent.com/PharosNetwork/resources/refs/heads/main/conf/traceDB.conf
```

## **3. Download and setup ops tool**

Download the latest ops tool for Linux:

```bash
wget https://github.com/PharosNetwork/ops/releases/latest/download/ops-linux-amd64 -O ops
chmod +x ops
```

## **4. Set password for key encryption**

Set a password that will be used to encrypt your node's cryptographic keys:

```bash
./ops set-password YOUR_SECURE_PASSWORD
```

**Important:**

* Remember this password - you'll need it to start your node
* The password is stored in `./.password` file
* Keep this password secure and backed up

## **5. Generate cryptographic keys**

Generate the domain and stabilizing keys for your node:

```bash
./ops generate-keys
```

This will create the following files in the `./keys/` directory:

* `domain.key` - ECDSA private key (prime256v1)
* `domain.pub` - ECDSA public key
* `stabilizing.key` - BLS12-381 private key
* `stabilizing.pub` - BLS12-381 public key

## **6. Bootstrap the node**

Initialize the node with genesis state:

```bash
./ops bootstrap --config ./pharos.conf
```

This command will:

* Create the storage database
* Initialize the genesis block
* Prepare the node for first startup

## **7. Start the node**

Start the Pharos node service:

```bash
./ops start --config ./pharos.conf
```

The node will start in daemon mode and begin syncing with the network.

Check the logs to verify the node is running:

```bash
tail -f log/aldaba.log
```

## **8. (Optional) Setup systemd service**

For production deployments, it's recommended to manage the Pharos node with systemd.

Create a systemd service file:

```bash
sudo tee /etc/systemd/system/pharos.service > /dev/null <<EOF
[Unit]
Description=Pharos Node
After=network.target

[Service]
Type=simple
User=$USER
WorkingDirectory=/data/$WORKSPACE/bin
Environment="CONSENSUS_KEY_PWD=$(cat /data/$WORKSPACE/.password)"
Environment="PORTAL_SSL_PWD=$(cat /data/$WORKSPACE/.password)"
Environment="LD_PRELOAD=/data/$WORKSPACE/bin/libevmone.so"
ExecStart=/data/$WORKSPACE/bin/pharos_light -c /data/$WORKSPACE/pharos.conf
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal

# Resource limits
LimitNOFILE=10000000

[Install]
WantedBy=multi-user.target
EOF
```

Enable and start the service:

```bash
sudo systemctl daemon-reload
sudo systemctl enable pharos
sudo systemctl start pharos
```

Check service status:

```bash
sudo systemctl status pharos
```

View logs:

```bash
sudo journalctl -u pharos -f
```

**Note:** If not using systemd, you can manually stop the node with `pkill pharos_light` and restart with `./ops start --config ./pharos.conf`

## **Directory Structure**

After deployment, your directory structure should look like:

```
/data/pharos/
├── bin/
│   ├── pharos_light
│   ├── pharos_cli
│   ├── libevmone.so
│   └── VERSION
├── keys/
│   ├── domain.key
│   ├── domain.pub
│   ├── stabilizing.key
│   └── stabilizing.pub
├── data/
│   └── (blockchain data)
├── log/
│   ├── aldaba.log
│   ├── pamir.log
│   └── (other logs)
├── genesis.conf
├── pharos.conf
├── ops
└── .password
```

## **9. (Optional) Register as Validator**

If you want to run a validator node, you need to register your node on-chain after it has synced with the network.

### Set up your validator private key

The validator registration requires an Ethereum-compatible private key that holds sufficient tokens for staking. Set it as an environment variable:

```bash
export VALIDATOR_PRIVATE_KEY=your_private_key_hex
```

> **Security Note:** Do not pass the private key via command-line arguments. Always use the environment variable.

### Register the validator

```bash
./ops add-validator \
  --rpc-endpoint http://127.0.0.1:18100 \
  --domain-label "My Validator Node" \
  --domain-endpoint "your-node-public-endpoint:20000" \
  --domain-pubkey ./keys/domain.pub \
  --stabilizing-pubkey ./keys/stabilizing.pub \
  --stake 1000000
```

Parameters:

* `--rpc-endpoint` - RPC endpoint of a synced Pharos node (default: `http://127.0.0.1:18100`)
* `--domain-label` - A description for your validator
* `--domain-endpoint` - The public-facing endpoint of your node for P2P communication
* `--domain-pubkey` - Path to the domain public key file generated in Step 5
* `--stabilizing-pubkey` - Path to the stabilizing public key file generated in Step 5
* `--stake` - Stake amount in tokens (default: 1,000,000 tokens)

On success, the command will output the transaction hash and your Node ID.

### Exit the validator (if needed)

To voluntarily exit your validator from the network:

```bash
export VALIDATOR_PRIVATE_KEY=your_private_key_hex

./ops exit-validator \
  --rpc-endpoint http://127.0.0.1:18100 \
  --domain-pubkey ./keys/domain.pub
```

## **Security Recommendations**

1. **Protect your keys**: The files in `keys/` directory contain your node's private keys
2. **Secure your password**: Keep the `.password` file secure with proper permissions
3. **Backup important files**: Backup `keys/`, `.password`, and `pharos.conf`
4. **Firewall configuration**: Ensure required ports are open (18100, 19000, 20000)
5. **Regular updates**: Keep your node software up to date with latest releases

## **Next Steps**

* [Node Monitoring Setup](/node-and-validator-guide/node-monitoring-setup.md) - Configure Prometheus metrics for your node
* To register as a validator, see Step 9 above


---

# 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.pharos.xyz/node-and-validator-guide/validator-node-deployment/using-binary-deployment.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.
