Repository navigation
Expand file tree
/
Copy pathstart-evm-node.ps1
More file actions
77 lines (69 loc) · 2.64 KB
/
Copy pathstart-evm-node.ps1
File metadata and controls
77 lines (69 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Start a Kanari EVM node (mirrors kanari-node/start-node.ps1)
param(
[ValidateSet("start", "local")]
[string]$Command = "start",
[ValidateSet("devnet", "testnet", "mainnet")]
[string]$Network = "devnet",
[string]$DataDir = "",
[string]$BaseDataDir = "$env:USERPROFILE\.kanari\evm-devnet",
[int]$RpcPort = 8545,
[string]$RpcHost = "127.0.0.1",
[string]$FaucetKey = "",
[string]$StateFile = ""
)
$exeCandidates = @(
(Join-Path $PSScriptRoot "target\debug\kanari-evm-node.exe"),
(Join-Path $PSScriptRoot "target\release\kanari-evm-node.exe")
)
$exePath = $exeCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $exePath) {
$onPath = Get-Command kanari-evm-node -ErrorAction SilentlyContinue
if ($onPath) { $exePath = $onPath.Source }
}
if (-not $exePath) {
Write-Host 'Error: kanari-evm-node executable not found! Run: cargo build -p kanari-evm-node' -ForegroundColor Red
exit 1
}
Write-Host "Using: $exePath" -ForegroundColor DarkGray
if ($Command -eq "local") {
Write-Host '========================================' -ForegroundColor Cyan
Write-Host 'Starting Kanari EVM Local Node' -ForegroundColor Green
Write-Host '========================================' -ForegroundColor Cyan
Write-Host 'RPC Port:' $RpcPort -ForegroundColor Yellow
Write-Host 'RPC URL: http://127.0.0.1:'$RpcPort -ForegroundColor Yellow
Write-Host '========================================' -ForegroundColor Cyan
Write-Host ''
& $exePath local --rpc-port $RpcPort
exit $LASTEXITCODE
}
if ([string]::IsNullOrWhiteSpace($DataDir)) {
$DataDir = $BaseDataDir
}
if (-not (Test-Path $DataDir)) {
New-Item -ItemType Directory -Path $DataDir -Force | Out-Null
}
$rpcUrl = "http://${RpcHost}:${RpcPort}"
Write-Host '========================================' -ForegroundColor Cyan
Write-Host 'Starting Kanari EVM Node' -ForegroundColor Green
Write-Host '========================================' -ForegroundColor Cyan
Write-Host 'Network:' $Network -ForegroundColor Yellow
Write-Host 'RPC Port:' $RpcPort -ForegroundColor Yellow
Write-Host 'RPC Bind Host:' $RpcHost -ForegroundColor Yellow
Write-Host 'Data Dir:' $DataDir -ForegroundColor Yellow
Write-Host "RPC URL: $rpcUrl" -ForegroundColor Yellow
Write-Host '========================================' -ForegroundColor Cyan
Write-Host ''
$nodeArgs = @(
"start",
"--network", $Network,
"--rpc-port", $RpcPort,
"--rpc-host", $RpcHost,
"--data-dir", $DataDir
)
if ($FaucetKey -ne "") {
$nodeArgs += @("--faucet-key", $FaucetKey)
}
if ($StateFile -ne "") {
$nodeArgs += @("--state-file", $StateFile)
}
& $exePath @nodeArgs