# Overview

This section documents all configuration options for NCN Network v2 components.

***

## Configuration Methods

NCN Network components can be configured through:

1. **Environment Variables** - Primary method
2. **Configuration Files** - For complex settings (e.g., `.env` files)
3. **Command Line Arguments** - For runtime overrides

### Priority Order

```
Command Line Args > Environment Variables > Config Files > Defaults
```

***

## Configuration Guides

### [Gateway Configuration](https://github.com/NeuroChainAi/docs-guides/blob/main/configuration/gateway-config.md)

Complete gateway configuration:

* Wallet settings
* Network addresses
* Blockchain configuration
* Payment settings

### [Compute Node Configuration](https://github.com/NeuroChainAi/docs-guides/blob/main/configuration/compute-config.md)

Compute node configuration:

* Sandbox settings
* Resource limits
* Model paths
* Execution settings

### [Registry Configuration](https://github.com/NeuroChainAi/docs-guides/blob/main/configuration/registry-config.md)

P2P Registry configuration:

* P2P network settings
* Validator settings
* Storage settings

### [Environment Variables Reference](https://docs.neurochain.ai/nc/neurochainai-guides/configuration/environment-vars)

Complete reference of all environment variables across all components.

### [Network Configuration](https://github.com/NeuroChainAi/docs-guides/blob/main/configuration/network-config.md)

Network-specific configurations:

* Local development
* Forknet testnet
* Sepolia testnet
* Mainnet

***

## Quick Reference

### Gateway Node

```bash
# Required
GATEWAY_WALLET_PRIVATE_KEY=0x...
RPC_URL=http://127.0.0.1:8545
CONTRACT_ADDRESS=0x4361...
REGISTRY_GRPC_ADDR=http://127.0.0.1:50050

# Optional
GRPC_ADDR=127.0.0.1:50051
HTTP_ADDR=127.0.0.1:8080
WS_ADDR=127.0.0.1:9000
SUBNET_ID=1
```

### Compute Node

```bash
# Command line
--gateway-addr http://127.0.0.1:50051
--model-path ./models

# Environment
COMPUTE_NODE_PRIVATE_KEY=0x...
SANDBOX_MODE=strict
EXECUTION_TIMEOUT_SECS=300
MAX_MEMORY_MB=4096
```

### P2P Registry

```bash
# Command line
--p2p-listen-addr /ip4/0.0.0.0/tcp/8828
--grpc-listen-addr 127.0.0.1:50050

# Environment
VALIDATOR_PRIVATE_KEY=0x...
VALIDATOR_SYNC_ENABLED=true
```

***

## Network Configurations

### Local Development

```bash
# Gateway
RPC_URL=http://127.0.0.1:8545
NETWORK=local
REGISTRY_GRPC_ADDR=http://127.0.0.1:50050

# Features disabled for development
REQUIRE_PAYMENT=false
SANDBOX_MODE=disabled
```

### Forknet Testnet

```bash
# Gateway
RPC_URL=https://forknet-rpc.neuralgpu.online
NETWORK=forknet
CONTRACT_ADDRESS=0x4361115359E5C0a25c9b2f8Bb71184F010b768ea

# Compute
SANDBOX_MODE=strict
REQUIRE_PAYMENT=true
```

### Production (Mainnet)

```bash
# Gateway
RPC_URL=https://mainnet.infura.io/v3/YOUR_KEY
NETWORK=mainnet
CONTRACT_ADDRESS=0x...

# Security
SANDBOX_MODE=strict
REQUIRE_PAYMENT=true
REQUIRED_CONFIRMATIONS=12
```

***

## Configuration Files

### Gateway `.env` File

Location: `gateway_node/.env`

```bash
# ============================================================================
# REQUIRED: Wallet Configuration
# ============================================================================
GATEWAY_WALLET_PRIVATE_KEY=0x...
GATEWAY_WALLET_ADDRESS=0x...

# ============================================================================
# Blockchain Configuration
# ============================================================================
CONTRACT_ADDRESS=0x4361115359E5C0a25c9b2f8Bb71184F010b768ea
RPC_URL=http://127.0.0.1:8545
NETWORK=forknet

# ============================================================================
# Network Configuration
# ============================================================================
SUBNET_ID=1
GRPC_ADDR=127.0.0.1:50051
HTTP_ADDR=127.0.0.1:8080
WS_ADDR=127.0.0.1:9000
REGISTRY_GRPC_ADDR=http://127.0.0.1:50050

# ============================================================================
# Transaction Configuration
# ============================================================================
GAS_LIMIT=500000
GAS_PRICE_MULTIPLIER=1.1
REQUIRED_CONFIRMATIONS=1
```

### Subnet Configuration

Location: Custom (used with `subnet-cli`)

```json
{
  "gateway_address": "0x...",
  "models": [
    {
      "name": "bark_semantic",
      "download_url": "https://huggingface.co/suno/bark/...",
      "executor_script": "...",
      "file_size_bytes": 2000000000
    }
  ]
}
```

***

## Security Recommendations

### Private Keys

```bash
# DON'T commit .env files with real keys
# .gitignore should include:
.env
*.env.local
*.env.production

# DO use environment variables or secrets management
export GATEWAY_WALLET_PRIVATE_KEY="$SECRET_FROM_VAULT"
```

### Network Exposure

```bash
# Development (bind to localhost)
GRPC_ADDR=127.0.0.1:50051
HTTP_ADDR=127.0.0.1:8080

# Production (bind to all interfaces behind firewall)
GRPC_ADDR=0.0.0.0:50051
HTTP_ADDR=0.0.0.0:8080
```

### Sandbox Mode

```bash
# Development only
SANDBOX_MODE=disabled

# Testing
SANDBOX_MODE=permissive

# Production (always)
SANDBOX_MODE=strict
```

***

## Validation

### Check Configuration

```bash
# Gateway: verify wallet loads
cargo run --bin gateway_node -- --dry-run

# Compute: verify sandbox
cargo run --bin compute_node -- --check-sandbox

# Subnet CLI: validate config
subnet-cli validate -c my_subnet.json
```

### Required vs Optional

| Component | Required                        | Recommended     | Optional       |
| --------- | ------------------------------- | --------------- | -------------- |
| Gateway   | Wallet, RPC, Contract, Registry | TLS, Metrics    | Debug settings |
| Compute   | Gateway addr                    | Wallet, Sandbox | Fallback       |
| Registry  | Listen addresses                | Validator key   | Sync settings  |

***

## Next Steps

* [Gateway Configuration](https://github.com/NeuroChainAi/docs-guides/blob/main/configuration/gateway-config.md) - Full gateway options
* [Compute Configuration](https://github.com/NeuroChainAi/docs-guides/blob/main/configuration/compute-config.md) - Compute node options
* [Environment Variables](https://docs.neurochain.ai/nc/neurochainai-guides/configuration/environment-vars) - Complete reference
