Instalación en Windows
Guía paso a paso para instalar KodeChain en Windows 10/11.
Requisitos Previos
- Windows 10 (versión 1909 o superior) o Windows 11
- Derechos de administrador
- Conexión a Internet
Método 1: Instalación Nativa
1. Instalar Go
Descarga e instala Go desde go.dev:
- Descarga
go1.24.0.windows-amd64.msi - Ejecuta el instalador
- Sigue el asistente de instalación
- Deja la ruta por defecto:
C:\Program Files\Go
Verificar instalación:
go version
2. Instalar Git
Descarga e instala Git desde git-scm.com:
- Descarga el instalador
- Ejecuta y sigue el asistente
- Usa opciones por defecto
Verificar:
git --version
3. Instalar Make (Opcional)
Opciones:
Opción A: Chocolatey
# Instalar Chocolatey (como administrador)
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Instalar Make
choco install make
Opción B: Usar comandos Go directamente (sin Make)
4. Clonar el Repositorio
Abrir PowerShell:
cd $HOME
git clone https://github.com/kodechain/kodechain-node-validator.git
cd kodechain-node-validator
5. Instalar Dependencias de Go
go mod download
go mod verify
6. Compilar KodeChain
go build -o kodechain.exe main.go
7. Crear Estructura de Directorios
New-Item -ItemType Directory -Force -Path "$HOME\.kodechain\data"
New-Item -ItemType Directory -Force -Path "$HOME\.kodechain\keystore"
New-Item -ItemType Directory -Force -Path "$HOME\.kodechain\logs"
8. Crear Archivo de Configuración
Crear %USERPROFILE%\.kodechain\config.json:
notepad "$HOME\.kodechain\config.json"
Contenido:
{
"node_id": "windows-node-1",
"consensus_type": "dpos",
"network": {
"p2p_port": 30303,
"http_port": 8545,
"discovery_port": 30301
},
"bootstrap_nodes": [
"enode://[id]@seed1.kodechain.io:30303",
"enode://[id]@seed2.kodechain.io:30303"
],
"data_dir": "C:\\Users\\YOUR_USERNAME\\.kodechain\\data",
"keystore_dir": "C:\\Users\\YOUR_USERNAME\\.kodechain\\keystore",
"log_level": "info"
}
Reemplaza YOUR_USERNAME con tu usuario de Windows.
9. Configurar Firewall de Windows
Abrir PowerShell como Administrador:
# KodeChain P2P TCP
New-NetFirewallRule -DisplayName "KodeChain P2P TCP" -Direction Inbound -LocalPort 30303 -Protocol TCP -Action Allow
# KodeChain P2P UDP
New-NetFirewallRule -DisplayName "KodeChain P2P UDP" -Direction Inbound -LocalPort 30303 -Protocol UDP -Action Allow
# KodeChain HTTP API
New-NetFirewallRule -DisplayName "KodeChain HTTP" -Direction Inbound -LocalPort 8545 -Protocol TCP -Action Allow
# KodeChain Discovery UDP
New-NetFirewallRule -DisplayName "KodeChain Discovery" -Direction Inbound -LocalPort 30301 -Protocol UDP -Action Allow
10. Crear Servicio de Windows (Opcional)
Para que el nodo se inicie automáticamente, usa NSSM (Non-Sucking Service Manager):
# Descargar NSSM
Invoke-WebRequest -Uri "https://nssm.cc/release/nssm-2.24.zip" -OutFile "nssm.zip"
# Extraer
Expand-Archive -Path "nssm.zip" -DestinationPath "."
# Mover a ubicación permanente
Move-Item -Path ".\nssm-2.24\win64\nssm.exe" -Destination "C:\Windows\System32\"
Crear servicio:
# Ejecutar como administrador
nssm install KodeChain "C:\Users\YOUR_USERNAME\kodechain-node-validator\kodechain.exe" "--config" "C:\Users\YOUR_USERNAME\.kodechain\config.json"
# Configurar directorio de trabajo
nssm set KodeChain AppDirectory "C:\Users\YOUR_USERNAME\kodechain-node-validator"
# Configurar stdout
nssm set KodeChain AppStdout "C:\Users\YOUR_USERNAME\.kodechain\logs\kodechain.log"
# Configurar stderr
nssm set KodeChain AppStderr "C:\Users\YOUR_USERNAME\.kodechain\logs\kodechain-error.log"
# Iniciar servicio
nssm start KodeChain
Comandos útiles:
# Ver estado
nssm status KodeChain
# Detener
nssm stop KodeChain
# Reiniciar
nssm restart KodeChain
# Remover servicio
nssm remove KodeChain confirm
11. Verificar Instalación
# Verificar que el nodo está corriendo
Invoke-WebRequest -Uri "http://localhost:8545/api/blockchain/status" | Select-Object -Expand Content
# Verificar peers
Invoke-WebRequest -Uri "http://localhost:8545/api/network/peers" | Select-Object -Expand Content
O con curl (si está instalado):
curl http://localhost:8545/api/blockchain/status
curl http://localhost:8545/api/network/peers
Método 2: WSL2 (Windows Subsystem for Linux)
1. Habilitar WSL2
Abrir PowerShell como Administrador:
wsl --install
Reiniciar el sistema.
2. Instalar Ubuntu desde Microsoft Store
- Abrir Microsoft Store
- Buscar "Ubuntu 22.04 LTS"
- Instalar
- Configurar usuario y contraseña
3. Seguir Guía de Ubuntu
Desde WSL2, sigue la guía de instalación de Ubuntu.
Método 3: Docker Desktop
Ver Docker Installation Guide.
Configuración Avanzada
Variables de Entorno
Configurar variables de entorno de Windows:
- Panel de Control > Sistema > Configuración avanzada del sistema
- Variables de entorno
- Crear nuevas variables de usuario:
KODECHAIN_HOME = C:\Users\YOUR_USERNAME\.kodechain
KODECHAIN_DATA_DIR = C:\Users\YOUR_USERNAME\.kodechain\data
KODECHAIN_KEYSTORE = C:\Users\YOUR_USERNAME\.kodechain\keystore
- Agregar a PATH:
C:\Users\YOUR_USERNAME\kodechain-node-validator
Optimización de Performance
Deshabilitar Windows Defender para carpeta de KodeChain:
- Windows Security > Virus & threat protection
- Manage settings > Exclusions
- Add or remove exclusions > Add an exclusion > Folder
- Seleccionar carpeta
kodechain-node-validator
Configurar Power Plan:
- Panel de Control > Hardware and Sound > Power Options
- Seleccionar High performance
Backup Automático
Crear script de PowerShell backup-kodechain.ps1:
$BackupDir = "$HOME\Backups\kodechain"
$Date = Get-Date -Format "yyyyMMdd_HHmmss"
New-Item -ItemType Directory -Force -Path $BackupDir
# Backup de keystore
Compress-Archive -Path "$HOME\.kodechain\keystore\*" -DestinationPath "$BackupDir\keystore_$Date.zip"
# Backup de configuración
Copy-Item -Path "$HOME\.kodechain\config.json" -Destination "$BackupDir\config_$Date.json"
# Limpiar backups antiguos (mantener últimos 7 días)
Get-ChildItem -Path $BackupDir | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-7)} | Remove-Item
Write-Host "Backup completado: $Date"
Programar con Task Scheduler:
- Abrir Task Scheduler
- Create Basic Task
- Nombre: "KodeChain Backup"
- Trigger: Daily a las 2:00 AM
- Action: Start a program
- Program:
powershell.exe - Arguments:
-ExecutionPolicy Bypass -File "C:\Users\YOUR_USERNAME\backup-kodechain.ps1"
- Program:
Solución de Problemas
Error: "go: command not found"
Reiniciar PowerShell o añadir Go manualmente al PATH:
$env:Path += ";C:\Program Files\Go\bin"
Error: "Access Denied"
Ejecutar PowerShell como Administrador.
Puerto ya en uso
# Encontrar proceso usando puerto 8545
Get-Process -Id (Get-NetTCPConnection -LocalPort 8545).OwningProcess
# Terminar proceso
Stop-Process -Id [PID] -Force
Error de compilación
go clean -cache
go mod tidy
go build -o kodechain.exe main.go
Problema con Windows Defender
Si Windows Defender bloquea la ejecución:
- Windows Security > Virus & threat protection
- Protection history
- Encontrar KodeChain y permitir
Herramientas de Monitoreo
Task Manager
Usa Task Manager (Ctrl+Shift+Esc) para monitorear:
- CPU usage
- Memory usage
- Network activity
- Disk activity
Resource Monitor
Task Manager > Performance > Open Resource Monitor
PowerShell Monitoring
# Ver logs en tiempo real
Get-Content "$HOME\.kodechain\logs\kodechain.log" -Wait
# Monitorear status cada 5 segundos
while ($true) {
Invoke-WebRequest -Uri "http://localhost:8545/api/blockchain/status" | Select-Object -Expand Content | ConvertFrom-Json
Start-Sleep -Seconds 5
}
Próximos Pasos
- 🔑 Genera tus claves de validador
- 💰 Haz stake de 10 KDC
- 🔐 Activa tu validador
- 📊 Configura monitoreo avanzado
Instalación en Windows completada ✅