# Quick Start

## Prerequisites

* Linux/macOS system
* Go 1.21+ installed
* 8GB RAM minimum (32GB for multi-node)
* 50GB disk space

## Deployment Options

QuantumWing supports **4 deployment methods**:

| Method             | Script                          | Use Case                         | Nodes        |
| ------------------ | ------------------------------- | -------------------------------- | ------------ |
| **🧪 Development** | `secure-three-layer.sh`         | Local testing, single machine    | 1 (3 layers) |
| **🏭 Production**  | `production-setup.sh`           | Real validators, true separation | 3 validators |
| **🌐 Multi-Node**  | `start-3node-dht-testnet.sh`    | P2P testing, DHT discovery       | 3 nodes      |
| **🐳 Docker**      | `docker-compose-production.yml` | Container deployment             | 5 nodes      |

## Option 1: Development (Fastest)

```bash
# Clone repository
git clone https://github.com/quantumwing/blockchain
cd blockchain

# Run secure three-layer setup
./scripts/secure-three-layer.sh
```

This script starts all three layers:

* **Execution Layer** (Port 8546) - Transaction processing + QWVM
* **Beacon Chain** (Port 8080) - PoR consensus
* **Validator** (3 instances) - Block proposals and attestations

## Option 2: Production Setup

For **real validator separation** (enterprise deployment):

```bash
./scripts/production-setup.sh
```

**What this does**:

* Creates 3 **production validator wallets** with Dilithium Mode 3 keys
* Generates **production genesis** (`quantum-production-1` chain ID)
* Starts **Beacon Coordinator** (no self-validation)
* Launches **3 external validators** (submit blocks via API)
* True separation: validators are **independent processes**

**Verify**:

```bash
# Check validator registration
curl http://localhost:8080/api/v1/validators | jq '.'

# Monitor validator 0 logs
tail -f logs/validators/production-validator-0.log
```

## Option 3: Multi-Node P2P Network

For **DHT peer discovery** testing:

```bash
./scripts/start-3node-dht-testnet.sh
```

**Network topology**:

* **Node 1**: Bootstrap seed (Execution: 8546, Beacon: 8080)
* **Node 2**: Bootstraps to Node 1 (Execution: 8547, Beacon: 8081)
* **Node 3**: Discovers Node 2 via DHT (Execution: 8548, Beacon: 8082)

**Verify P2P connectivity**:

```bash
# Check Node 1 peers
curl http://localhost:8080/api/v1/p2p/peers | jq '.peers | length'

# Check Node 3 discovered Node 2 via DHT
grep "Discovered peer via DHT" logs/node3/beacon/beacon.log
```

## Option 4: Docker Multi-Node

For **containerized** production deployment:

```bash
cd deployments

# Start 5-node network
docker-compose -f docker-compose-production.yml up -d

# Check status
docker-compose -f docker-compose-production.yml ps

# View logs
docker-compose -f docker-compose-production.yml logs -f node-0
```

**Architecture**:

* 5 blockchain nodes (ports 8080-8084)
* HAProxy load balancer (port 80)
* Prometheus + Grafana monitoring
* Persistent volumes for data

## Verify It's Running

### Check Execution Layer

```bash
curl http://localhost:8546/health
```

Expected output:

```json
{
  "status": "healthy",
  "layer": "execution",
  "latest_block": 42,
  "peers": 3
}
```

### Check Beacon Chain

```bash
curl http://localhost:8080/beacon/v1/node/syncing
```

Expected output:

```json
{
  "data": {
    "head_slot": "64",
    "sync_distance": "0",
    "is_syncing": false
  }
}
```

### Check Validator

```bash
tail -f logs/validators/validator-0.log
```

Look for:

```
INFO Successfully proposed block slot=64 block_root=0x1234...
INFO Attestation included slot=65 committee_index=0
```

## Create Your First Wallet

```bash
quantum-wing crypto generate-key --mode 3 --output wallet.json
```

This generates a Dilithium Mode 3 key pair with EVM-compatible address:

```json
{
  "address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb5",
  "public_key": "base64_encoded_dilithium_public_key...",
  "created_at": "2025-10-28T12:34:56Z"
}
```

## Fund Your Wallet (Testnet)

```bash
curl -X POST http://localhost:8546/faucet \
  -H "Content-Type: application/json" \
  -d '{"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb5"}'
```

Returns:

```json
{
  "tx_hash": "0xabcd1234...",
  "amount": "10000000000000000000",
  "address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb5"
}
```

You now have **10 ETH** test tokens!

## Send Your First Transaction

```bash
quantum-wing wallet send \
  --from wallet.json \
  --to 0x1234567890abcdef1234567890abcdef12345678 \
  --amount 1.5 \
  --gas-price 20 \
  --rpc http://localhost:8546
```

Output:

```
✅ Transaction sent successfully!
├─ Hash: 0xdef5678...
├─ From: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb5
├─ To: 0x1234567890abcdef1234567890abcdef12345678
├─ Amount: 1.5 ETH
├─ Gas Price: 20 Gwei
└─ Status: Pending...

⏳ Waiting for confirmation...
✅ Confirmed in block 127 (finalized in ~12.8 min)
```

## Next Steps

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>📦 Full Installation</strong></td><td>Build from source and configure production setup</td><td><a href="installation">installation</a></td></tr><tr><td><strong>🏗️ Architecture</strong></td><td>Understand the three-layer design</td><td><a href="../architecture/overview">overview</a></td></tr><tr><td><strong>🤖 Deploy Smart Contracts</strong></td><td>Learn QWVM WebAssembly contracts</td><td><a href="../smart-contracts/qwvm">qwvm</a></td></tr></tbody></table>

## Troubleshooting

### Port Already in Use

```bash
# Check what's using port 8546
lsof -i :8546

# Kill the process
kill -9 <PID>
```

### Genesis File Mismatch

```bash
# Regenerate genesis
quantum-wing genesis generate genesis.json --chain-id quantum-wing-1

# Clear old data
rm -rf data/execution data/beacon
```

### Validator Not Proposing

Check validator logs:

```bash
grep "ERROR" logs/validators/validator-0.log
```

Common issues:

* Clock not synced (run `sudo ntpdate pool.ntp.org`)
* Insufficient stake (need 32 ETH minimum)
* Wrong genesis file

## Performance Tips

{% hint style="success" %}
**Production Optimization**: For high-throughput deployments, see [https://github.com/dolfrin/QuantumWing/blob/master/docs/operations/performance.md](https://github.com/dolfrin/QuantumWing/blob/master/docs/operations/performance.md "mention") for BadgerDB configuration and P2P networking optimizations.
{% endhint %}

{% hint style="info" %}
**Monitoring**: Enable Prometheus metrics with `--metrics-enabled` flag. See [https://github.com/dolfrin/QuantumWing/blob/master/docs/operations/monitoring.md](https://github.com/dolfrin/QuantumWing/blob/master/docs/operations/monitoring.md "mention") for Grafana dashboards.
{% endhint %}
