apow-cli 0.11.4 → 0.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +4 -4
- package/README.md +19 -32
- package/dist/config.js +28 -5
- package/dist/dashboard-html.js +2 -2
- package/dist/dashboard.js +7 -6
- package/dist/detect.js +11 -11
- package/dist/errors.js +13 -5
- package/dist/fund.js +5 -2
- package/dist/grinder-http.js +28 -4
- package/dist/index.js +164 -102
- package/dist/miner.js +58 -39
- package/dist/mint.js +8 -3
- package/dist/preflight.js +26 -2
- package/dist/ui.js +27 -5
- package/dist/wallet-store.js +58 -0
- package/local/vast-setup.sh +170 -0
- package/package.json +3 -2
- package/skill.md +20 -31
package/dist/ui.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cyan = exports.yellow = exports.green = exports.red = exports.bold = exports.dim = void 0;
|
|
4
|
+
exports.isInteractiveSession = isInteractiveSession;
|
|
4
5
|
exports.banner = banner;
|
|
5
6
|
exports.table = table;
|
|
6
7
|
exports.spinner = spinner;
|
|
@@ -16,8 +17,12 @@ exports.warn = warn;
|
|
|
16
17
|
exports.info = info;
|
|
17
18
|
const promises_1 = require("node:readline/promises");
|
|
18
19
|
const node_process_1 = require("node:process");
|
|
19
|
-
const isTTY = node_process_1.stdout.isTTY && node_process_1.stderr.isTTY;
|
|
20
|
+
const isTTY = !!node_process_1.stdout.isTTY && !!node_process_1.stderr.isTTY;
|
|
21
|
+
const isInteractive = !!node_process_1.stdin.isTTY && isTTY;
|
|
20
22
|
const noColor = !!process.env.NO_COLOR || !isTTY;
|
|
23
|
+
function isInteractiveSession() {
|
|
24
|
+
return isInteractive;
|
|
25
|
+
}
|
|
21
26
|
function wrap(code, reset) {
|
|
22
27
|
if (noColor)
|
|
23
28
|
return (s) => s;
|
|
@@ -51,10 +56,21 @@ const activeSpinners = new Set();
|
|
|
51
56
|
function spinner(label) {
|
|
52
57
|
if (!isTTY) {
|
|
53
58
|
console.error(` ${label}`);
|
|
59
|
+
let finished = false;
|
|
54
60
|
const noop = {
|
|
55
|
-
update(
|
|
56
|
-
stop(l) {
|
|
57
|
-
|
|
61
|
+
update() { },
|
|
62
|
+
stop(l) {
|
|
63
|
+
if (finished)
|
|
64
|
+
return;
|
|
65
|
+
finished = true;
|
|
66
|
+
console.error(` ${l}`);
|
|
67
|
+
},
|
|
68
|
+
fail(l) {
|
|
69
|
+
if (finished)
|
|
70
|
+
return;
|
|
71
|
+
finished = true;
|
|
72
|
+
console.error(` ${l}`);
|
|
73
|
+
},
|
|
58
74
|
};
|
|
59
75
|
return noop;
|
|
60
76
|
}
|
|
@@ -101,7 +117,7 @@ function stopAll() {
|
|
|
101
117
|
activeSpinners.clear();
|
|
102
118
|
}
|
|
103
119
|
async function confirm(question) {
|
|
104
|
-
if (!
|
|
120
|
+
if (!isInteractive)
|
|
105
121
|
return true;
|
|
106
122
|
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stderr });
|
|
107
123
|
const answer = await rl.question(` ${question} ${(0, exports.dim)("(Y/n)")} `);
|
|
@@ -110,6 +126,9 @@ async function confirm(question) {
|
|
|
110
126
|
return trimmed === "" || trimmed === "y" || trimmed === "yes";
|
|
111
127
|
}
|
|
112
128
|
async function prompt(question, defaultValue) {
|
|
129
|
+
if (!isInteractive) {
|
|
130
|
+
return defaultValue ?? "";
|
|
131
|
+
}
|
|
113
132
|
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stderr });
|
|
114
133
|
const hint = defaultValue ? ` ${(0, exports.dim)(`[${defaultValue}`)}${(0, exports.dim)("]")}` : "";
|
|
115
134
|
const answer = await rl.question(` ${question}${hint}: `);
|
|
@@ -117,6 +136,9 @@ async function prompt(question, defaultValue) {
|
|
|
117
136
|
return answer.trim() || defaultValue || "";
|
|
118
137
|
}
|
|
119
138
|
async function promptSecret(question) {
|
|
139
|
+
if (!isInteractive) {
|
|
140
|
+
return "";
|
|
141
|
+
}
|
|
120
142
|
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stderr });
|
|
121
143
|
const answer = await rl.question(` ${question}: `);
|
|
122
144
|
rl.close();
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getKeystoreDir = getKeystoreDir;
|
|
4
|
+
exports.getPlaintextWalletPath = getPlaintextWalletPath;
|
|
5
|
+
exports.getKeystoreWalletPath = getKeystoreWalletPath;
|
|
6
|
+
exports.savePlaintextImportFile = savePlaintextImportFile;
|
|
7
|
+
exports.saveEncryptedKeystoreFile = saveEncryptedKeystoreFile;
|
|
8
|
+
exports.detectWalletAddressFromFilename = detectWalletAddressFromFilename;
|
|
9
|
+
const node_fs_1 = require("node:fs");
|
|
10
|
+
const node_os_1 = require("node:os");
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
const ox_1 = require("ox");
|
|
13
|
+
function ensureDir(path) {
|
|
14
|
+
if (!(0, node_fs_1.existsSync)(path)) {
|
|
15
|
+
(0, node_fs_1.mkdirSync)(path, { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function getKeystoreDir() {
|
|
19
|
+
const dir = (0, node_path_1.join)((0, node_os_1.homedir)(), ".apow", "keystores");
|
|
20
|
+
ensureDir(dir);
|
|
21
|
+
return dir;
|
|
22
|
+
}
|
|
23
|
+
function getPlaintextWalletPath(address, cwd = process.cwd()) {
|
|
24
|
+
return (0, node_path_1.join)(cwd, `wallet-${address}.txt`);
|
|
25
|
+
}
|
|
26
|
+
function getKeystoreWalletPath(address) {
|
|
27
|
+
return (0, node_path_1.join)(getKeystoreDir(), `wallet-${address}.json`);
|
|
28
|
+
}
|
|
29
|
+
function savePlaintextImportFile(address, privateKey, cwd = process.cwd()) {
|
|
30
|
+
const filepath = getPlaintextWalletPath(address, cwd);
|
|
31
|
+
const content = [
|
|
32
|
+
`Address: ${address}`,
|
|
33
|
+
`Private Key: ${privateKey}`,
|
|
34
|
+
"",
|
|
35
|
+
`Generated: ${new Date().toISOString()}`,
|
|
36
|
+
"",
|
|
37
|
+
"Import this key into MetaMask, Rabby, Phantom, or any EVM wallet.",
|
|
38
|
+
"Keep this file safe — anyone with the private key controls your funds.",
|
|
39
|
+
"",
|
|
40
|
+
].join("\n");
|
|
41
|
+
(0, node_fs_1.writeFileSync)(filepath, content, { encoding: "utf8", mode: 0o600 });
|
|
42
|
+
return filepath;
|
|
43
|
+
}
|
|
44
|
+
async function saveEncryptedKeystoreFile(address, privateKey, password) {
|
|
45
|
+
const filepath = getKeystoreWalletPath(address);
|
|
46
|
+
const [key, opts] = await ox_1.Keystore.scryptAsync({ password });
|
|
47
|
+
const keystore = ox_1.Keystore.encrypt(privateKey, key, opts);
|
|
48
|
+
const payload = {
|
|
49
|
+
...keystore,
|
|
50
|
+
address: address.slice(2).toLowerCase(),
|
|
51
|
+
};
|
|
52
|
+
(0, node_fs_1.writeFileSync)(filepath, JSON.stringify(payload, null, 2) + "\n", { encoding: "utf8", mode: 0o600 });
|
|
53
|
+
return filepath;
|
|
54
|
+
}
|
|
55
|
+
function detectWalletAddressFromFilename(filename) {
|
|
56
|
+
const match = filename.match(/^wallet-(0x[0-9a-fA-F]{40})(?:\.keystore)?\.(txt|json)$/);
|
|
57
|
+
return match?.[1] ?? null;
|
|
58
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# APoW Cloud GPU Mining — Vast.ai RTX 4090 Setup
|
|
3
|
+
#
|
|
4
|
+
# Prerequisites:
|
|
5
|
+
# pip install vastai
|
|
6
|
+
# vastai set api-key <YOUR_API_KEY>
|
|
7
|
+
# Upload SSH key at https://cloud.vast.ai/manage-keys/
|
|
8
|
+
#
|
|
9
|
+
# Usage:
|
|
10
|
+
# ./vast-setup.sh # Find offers, rent, deploy grinder
|
|
11
|
+
# ./vast-setup.sh status # Check running instance
|
|
12
|
+
# ./vast-setup.sh destroy # Tear down instance
|
|
13
|
+
|
|
14
|
+
set -euo pipefail
|
|
15
|
+
|
|
16
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
17
|
+
GPU_DIR="$SCRIPT_DIR/gpu"
|
|
18
|
+
CUDA_SRC="$GPU_DIR/grinder-cuda.cu"
|
|
19
|
+
STATE_FILE="$SCRIPT_DIR/.vast-instance"
|
|
20
|
+
|
|
21
|
+
# ── Helpers ──
|
|
22
|
+
|
|
23
|
+
log() { echo "[$(date '+%H:%M:%S')] $*"; }
|
|
24
|
+
die() { log "ERROR: $*"; exit 1; }
|
|
25
|
+
|
|
26
|
+
get_instance_id() {
|
|
27
|
+
[[ -f "$STATE_FILE" ]] && cat "$STATE_FILE" || echo ""
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get_ssh_cmd() {
|
|
31
|
+
local id="$1"
|
|
32
|
+
local info
|
|
33
|
+
info=$(vastai show instance "$id" --raw 2>/dev/null)
|
|
34
|
+
local ip port
|
|
35
|
+
ip=$(echo "$info" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('ssh_host',''))" 2>/dev/null)
|
|
36
|
+
port=$(echo "$info" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('ssh_port',''))" 2>/dev/null)
|
|
37
|
+
if [[ -z "$ip" || -z "$port" ]]; then
|
|
38
|
+
die "Cannot get SSH details for instance $id"
|
|
39
|
+
fi
|
|
40
|
+
echo "$ip $port"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# ── Commands ──
|
|
44
|
+
|
|
45
|
+
cmd_status() {
|
|
46
|
+
local id
|
|
47
|
+
id=$(get_instance_id)
|
|
48
|
+
if [[ -z "$id" ]]; then
|
|
49
|
+
log "No active instance. Run './vast-setup.sh' to create one."
|
|
50
|
+
return
|
|
51
|
+
fi
|
|
52
|
+
log "Instance ID: $id"
|
|
53
|
+
vastai show instance "$id"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
cmd_destroy() {
|
|
57
|
+
local id
|
|
58
|
+
id=$(get_instance_id)
|
|
59
|
+
if [[ -z "$id" ]]; then
|
|
60
|
+
log "No active instance."
|
|
61
|
+
return
|
|
62
|
+
fi
|
|
63
|
+
log "Destroying instance $id..."
|
|
64
|
+
vastai destroy instance "$id"
|
|
65
|
+
rm -f "$STATE_FILE"
|
|
66
|
+
log "Done. Instance destroyed."
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
cmd_setup() {
|
|
70
|
+
[[ -f "$CUDA_SRC" ]] || die "CUDA source not found: $CUDA_SRC"
|
|
71
|
+
|
|
72
|
+
# Check for existing instance
|
|
73
|
+
local existing_id
|
|
74
|
+
existing_id=$(get_instance_id)
|
|
75
|
+
if [[ -n "$existing_id" ]]; then
|
|
76
|
+
log "Existing instance found: $existing_id"
|
|
77
|
+
log "Run './vast-setup.sh destroy' first, or './vast-setup.sh status' to check it."
|
|
78
|
+
return
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
# 1. Search for RTX 4090 offers
|
|
82
|
+
log "Searching for RTX 4090 offers..."
|
|
83
|
+
vastai search offers \
|
|
84
|
+
'gpu_name=RTX_4090 num_gpus=1 reliability>0.98 direct_port_count>0 disk_space>=20' \
|
|
85
|
+
-o 'dph+' \
|
|
86
|
+
--limit 5
|
|
87
|
+
|
|
88
|
+
echo ""
|
|
89
|
+
read -rp "Enter offer ID to rent (or 'q' to quit): " OFFER_ID
|
|
90
|
+
[[ "$OFFER_ID" == "q" ]] && exit 0
|
|
91
|
+
|
|
92
|
+
# 2. Create instance
|
|
93
|
+
log "Creating instance from offer $OFFER_ID..."
|
|
94
|
+
local create_output
|
|
95
|
+
create_output=$(vastai create instance "$OFFER_ID" \
|
|
96
|
+
--image nvidia/cuda:12.4.1-devel-ubuntu22.04 \
|
|
97
|
+
--disk 20 \
|
|
98
|
+
--ssh \
|
|
99
|
+
--direct 2>&1)
|
|
100
|
+
|
|
101
|
+
local instance_id
|
|
102
|
+
instance_id=$(echo "$create_output" | grep -oP 'new contract is \K\d+' || echo "")
|
|
103
|
+
if [[ -z "$instance_id" ]]; then
|
|
104
|
+
instance_id=$(echo "$create_output" | grep -oP '\d+' | tail -1)
|
|
105
|
+
fi
|
|
106
|
+
if [[ -z "$instance_id" ]]; then
|
|
107
|
+
die "Failed to extract instance ID from: $create_output"
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
echo "$instance_id" > "$STATE_FILE"
|
|
111
|
+
log "Instance created: $instance_id"
|
|
112
|
+
|
|
113
|
+
# 3. Wait for instance to be ready
|
|
114
|
+
log "Waiting for instance to start (this can take 1-3 minutes)..."
|
|
115
|
+
for i in $(seq 1 60); do
|
|
116
|
+
local status
|
|
117
|
+
status=$(vastai show instance "$instance_id" --raw 2>/dev/null | \
|
|
118
|
+
python3 -c "import sys,json; print(json.load(sys.stdin).get('actual_status',''))" 2>/dev/null || echo "")
|
|
119
|
+
if [[ "$status" == "running" ]]; then
|
|
120
|
+
log "Instance is running!"
|
|
121
|
+
break
|
|
122
|
+
fi
|
|
123
|
+
printf "."
|
|
124
|
+
sleep 5
|
|
125
|
+
done
|
|
126
|
+
echo ""
|
|
127
|
+
|
|
128
|
+
# 4. Get SSH details
|
|
129
|
+
local ssh_info ip port
|
|
130
|
+
ssh_info=$(get_ssh_cmd "$instance_id")
|
|
131
|
+
ip=$(echo "$ssh_info" | cut -d' ' -f1)
|
|
132
|
+
port=$(echo "$ssh_info" | cut -d' ' -f2)
|
|
133
|
+
log "SSH: ssh -p $port root@$ip"
|
|
134
|
+
|
|
135
|
+
# 5. Upload and compile CUDA grinder
|
|
136
|
+
log "Uploading CUDA grinder source..."
|
|
137
|
+
scp -o StrictHostKeyChecking=no -P "$port" "$CUDA_SRC" "root@$ip:/workspace/grinder-cuda.cu"
|
|
138
|
+
|
|
139
|
+
log "Compiling on GPU instance (nvcc -O3 -arch=sm_89)..."
|
|
140
|
+
ssh -o StrictHostKeyChecking=no -p "$port" "root@$ip" \
|
|
141
|
+
"cd /workspace && nvcc grinder-cuda.cu -o grinder-cuda -std=c++17 -O3 -arch=sm_89"
|
|
142
|
+
|
|
143
|
+
log "Verifying binary..."
|
|
144
|
+
ssh -o StrictHostKeyChecking=no -p "$port" "root@$ip" \
|
|
145
|
+
"ls -la /workspace/grinder-cuda && nvidia-smi --query-gpu=name,memory.total --format=csv,noheader"
|
|
146
|
+
|
|
147
|
+
# 6. Output env vars for speed-miner.js
|
|
148
|
+
echo ""
|
|
149
|
+
log "=== Setup complete! ==="
|
|
150
|
+
echo ""
|
|
151
|
+
echo "Add to your .env or export:"
|
|
152
|
+
echo " export GRINDER_MODE=remote"
|
|
153
|
+
echo " export VAST_IP=$ip"
|
|
154
|
+
echo " export VAST_PORT=$port"
|
|
155
|
+
echo ""
|
|
156
|
+
echo "Test manually:"
|
|
157
|
+
echo " ssh -p $port root@$ip '/workspace/grinder-cuda <challenge> <address> <target>'"
|
|
158
|
+
echo ""
|
|
159
|
+
echo "Start mining:"
|
|
160
|
+
echo " GRINDER_MODE=remote VAST_IP=$ip VAST_PORT=$port node local/speed-miner.js"
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
# ── Main ──
|
|
164
|
+
|
|
165
|
+
case "${1:-setup}" in
|
|
166
|
+
status) cmd_status ;;
|
|
167
|
+
destroy) cmd_destroy ;;
|
|
168
|
+
setup|"") cmd_setup ;;
|
|
169
|
+
*) echo "Usage: $0 [setup|status|destroy]"; exit 1 ;;
|
|
170
|
+
esac
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apow-cli",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.6",
|
|
4
4
|
"description": "Mine AGENT tokens on Base L2 with Agentic Proof of Work",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apow",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"local/gpu/grinder-cuda.cu",
|
|
37
37
|
"local/gpu/grinder.m",
|
|
38
38
|
"local/gpu/keccak.metal",
|
|
39
|
-
"local/gpu/Makefile"
|
|
39
|
+
"local/gpu/Makefile",
|
|
40
|
+
"local/vast-setup.sh"
|
|
40
41
|
],
|
|
41
42
|
"scripts": {
|
|
42
43
|
"build": "tsc",
|
package/skill.md
CHANGED
|
@@ -30,19 +30,14 @@ on Base. Everything else you handle yourself.
|
|
|
30
30
|
|
|
31
31
|
**Via npm (recommended):**
|
|
32
32
|
```bash
|
|
33
|
-
npx apow-cli
|
|
34
|
-
npx apow-cli fund # fund wallet: bridge from Solana or show deposit address
|
|
35
|
-
npx apow-cli mint # mint a mining rig NFT
|
|
36
|
-
npx apow-cli mine # start mining (auto-detects your best rig)
|
|
33
|
+
npx apow-cli start # zero-config happy path: setup -> fund -> mint -> mine
|
|
37
34
|
```
|
|
38
35
|
|
|
39
36
|
**Via source:**
|
|
40
37
|
```bash
|
|
41
38
|
git clone https://github.com/Agentoshi/apow-cli.git
|
|
42
39
|
cd apow-cli && npm install
|
|
43
|
-
npx tsx src/index.ts
|
|
44
|
-
npx tsx src/index.ts mint
|
|
45
|
-
npx tsx src/index.ts mine
|
|
40
|
+
npx tsx src/index.ts start
|
|
46
41
|
```
|
|
47
42
|
|
|
48
43
|
### Autonomous Agent Flow — Zero Credentials (non-interactive)
|
|
@@ -66,15 +61,8 @@ LLM_MODEL=blockrun/eco
|
|
|
66
61
|
ALLOW_LOCAL_FALLBACK_WITH_X402=false
|
|
67
62
|
EOF
|
|
68
63
|
|
|
69
|
-
# 3.
|
|
70
|
-
npx apow-cli
|
|
71
|
-
# Or: npx apow-cli fund --chain ethereum # bridge ETH from Ethereum mainnet
|
|
72
|
-
# Or: npx apow-cli fund --chain base # send ETH or USDC on Base directly
|
|
73
|
-
# Or: ask your user to send ETH + USDC on Base directly
|
|
74
|
-
|
|
75
|
-
# 4. Mint + mine (fully autonomous from here — zero human intervention)
|
|
76
|
-
npx apow-cli mint
|
|
77
|
-
npx apow-cli mine
|
|
64
|
+
# 3. Start mining — the CLI handles funding checks, minting, and mining
|
|
65
|
+
npx apow-cli start
|
|
78
66
|
```
|
|
79
67
|
|
|
80
68
|
### Legacy Flow (with API keys)
|
|
@@ -125,7 +113,7 @@ The miner client validates locally before submitting.
|
|
|
125
113
|
|---|---|
|
|
126
114
|
| **Node.js** | v20 or higher |
|
|
127
115
|
| **Base wallet** | A private key with ETH on Base (for gas + mint fee) |
|
|
128
|
-
| **USDC on Base** |
|
|
116
|
+
| **USDC on Base** | 2.00 USDC minimum starting balance for x402 RPC/ClawRouter; more gives headroom |
|
|
129
117
|
| **LLM access** | ClawRouter (zero credentials, recommended) OR API key (OpenAI, Gemini, etc.) OR local Ollama (**required for minting only**) |
|
|
130
118
|
| **git** | Only if installing from source (not needed for npm) |
|
|
131
119
|
|
|
@@ -146,7 +134,7 @@ Or generate one directly (useful for agents, no prompts):
|
|
|
146
134
|
npx apow-cli wallet new
|
|
147
135
|
```
|
|
148
136
|
|
|
149
|
-
This outputs a private key (0x + 64 hex chars) and Base address,
|
|
137
|
+
This outputs a private key (0x + 64 hex chars) and Base address, saves a plaintext `wallet-<address>.txt` import helper to the current directory, and can also create an encrypted `wallet-<address>.json` keystore under `~/.apow/keystores/` when a password is available. The private key goes in your `.env` as `PRIVATE_KEY`.
|
|
150
138
|
|
|
151
139
|
**Exporting an existing wallet:** If you've already set up a wallet and need to retrieve the key:
|
|
152
140
|
|
|
@@ -154,7 +142,7 @@ This outputs a private key (0x + 64 hex chars) and Base address, and saves a `wa
|
|
|
154
142
|
npx apow-cli wallet export
|
|
155
143
|
```
|
|
156
144
|
|
|
157
|
-
This prompts for confirmation, then displays your address and private key. It
|
|
145
|
+
This prompts for confirmation, then displays your address and private key. It can save a plaintext `wallet-<address>.txt` import helper and/or an encrypted JSON keystore backup.
|
|
158
146
|
|
|
159
147
|
**Exporting to a wallet app:** The user can import this private key into Phantom, MetaMask, Rainbow, or any EVM-compatible wallet to view their AGENT tokens and Mining Rig NFT alongside their other assets.
|
|
160
148
|
|
|
@@ -167,7 +155,7 @@ Your mining wallet needs ETH on Base for gas and the mint fee.
|
|
|
167
155
|
|
|
168
156
|
### Built-in Bridge: `apow fund` (Recommended)
|
|
169
157
|
|
|
170
|
-
The CLI bridges from Solana or Ethereum via [Squid Router](https://squidrouter.com/) (Chainflip), or accepts deposits directly on Base. Auto-splits into ETH (gas) + USDC (x402 RPC):
|
|
158
|
+
The CLI bridges from Solana or Ethereum via [Squid Router](https://squidrouter.com/) (Chainflip), or accepts deposits directly on Base. `apow start` can use this flow automatically. Auto-splits into ETH (gas) + USDC (x402 RPC):
|
|
171
159
|
|
|
172
160
|
```bash
|
|
173
161
|
npx apow-cli fund # Interactive: choose chain + token
|
|
@@ -180,7 +168,7 @@ npx apow-cli fund --chain base --no-swap # Skip auto-split
|
|
|
180
168
|
|
|
181
169
|
**Solana/Ethereum bridging:** Generates a one-time deposit address with QR code. Send tokens from any wallet (Phantom, MetaMask, etc.). Requires `SQUID_INTEGRATOR_ID` in `.env` (free at [squidrouter.com](https://app.squidrouter.com/)). Bridge time: ~1-3 minutes via Chainflip.
|
|
182
170
|
|
|
183
|
-
**Auto-split:** After bridging, the CLI checks ETH and USDC balances. If either is below the minimum (0.003 ETH for gas, 2.00 USDC for x402
|
|
171
|
+
**Auto-split:** After bridging, the CLI checks ETH and USDC balances. If either is below the minimum (0.003 ETH for gas, 2.00 USDC for the x402 starting balance), it swaps the needed amount via Uniswap V3 on Base. Use `--no-swap` to skip.
|
|
184
172
|
|
|
185
173
|
### Manual Funding Options
|
|
186
174
|
|
|
@@ -263,7 +251,7 @@ LLM_MODEL=blockrun/eco
|
|
|
263
251
|
# === Network ===
|
|
264
252
|
|
|
265
253
|
# Base RPC endpoint (required). Get a free URL from alchemy.com (no credit card).
|
|
266
|
-
# Or set USE_X402=true instead for auto-pay via QuickNode (
|
|
254
|
+
# Or set USE_X402=true instead for auto-pay via QuickNode (2.00 USDC minimum starting balance; add more for headroom).
|
|
267
255
|
RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY
|
|
268
256
|
|
|
269
257
|
# Chain: "base" | "baseSepolia" (auto-detected from RPC_URL if omitted)
|
|
@@ -275,6 +263,7 @@ CHAIN=base
|
|
|
275
263
|
| Variable | Required | Default | Description |
|
|
276
264
|
|---|---|---|---|
|
|
277
265
|
| `PRIVATE_KEY` | Yes | - | Wallet private key (0x + 64 hex chars) |
|
|
266
|
+
| `KEYSTORE_PASSWORD` | No | unset | If set, `wallet new`/`wallet export` also create an encrypted JSON keystore backup under `~/.apow/keystores/` |
|
|
278
267
|
| `MINING_AGENT_ADDRESS` | Yes | - | Deployed MiningAgent contract address |
|
|
279
268
|
| `AGENT_COIN_ADDRESS` | Yes | - | Deployed AgentCoin contract address |
|
|
280
269
|
| `LLM_PROVIDER` | For minting | `clawrouter` if `USE_X402=true`, else `openai` | LLM provider for minting: `clawrouter` (recommended, zero credentials), `openai`, `gemini`, `deepseek`, `qwen`, `anthropic`, `ollama`, `claude-code`, `codex`. Not needed for mining. |
|
|
@@ -283,7 +272,7 @@ CHAIN=base
|
|
|
283
272
|
| `CLAWROUTER_PORT` | No | `8402` | Port for ClawRouter local proxy (only if default is in use) |
|
|
284
273
|
| `MINER_THREADS` | No | All CPU cores | Threads for JS nonce grinding (fallback if no native GPU/CPU grinder detected) |
|
|
285
274
|
| `RPC_URL` | Yes* | — | Base JSON-RPC endpoint. Get a free URL from Alchemy or QuickNode. *Not needed if `USE_X402=true`. |
|
|
286
|
-
| `USE_X402` | No | `false` | Set to `true` to auto-pay via QuickNode x402 (
|
|
275
|
+
| `USE_X402` | No | `false` | Set to `true` to auto-pay via QuickNode x402 (2.00 USDC minimum starting balance; add more for headroom). Replaces `RPC_URL`. |
|
|
287
276
|
| `CHAIN` | No | `base` | Network selector; auto-detects `baseSepolia` if RPC URL contains "sepolia" |
|
|
288
277
|
| `SOLANA_RPC_URL` | No | `https://api.mainnet-beta.solana.com` | Solana RPC endpoint (only for `apow fund --chain solana`) |
|
|
289
278
|
| `ETHEREUM_RPC_URL` | No | `https://cloudflare-eth.com` | Ethereum mainnet RPC (only for `apow fund --chain ethereum`) |
|
|
@@ -316,7 +305,7 @@ CHAIN=base
|
|
|
316
305
|
|
|
317
306
|
### RPC Recommendations
|
|
318
307
|
|
|
319
|
-
You need a dedicated RPC endpoint. The public `https://mainnet.base.org` has aggressive rate limits and **will** fail during sustained mining. All providers below offer a **free tier** that is more than sufficient for mining. Alternatively, set `USE_X402=true` for zero-setup auto-pay via QuickNode (
|
|
308
|
+
You need a dedicated RPC endpoint. The public `https://mainnet.base.org` has aggressive rate limits and **will** fail during sustained mining. All providers below offer a **free tier** that is more than sufficient for mining. Alternatively, set `USE_X402=true` for zero-setup auto-pay via QuickNode (2.00 USDC minimum starting balance; add more for headroom).
|
|
320
309
|
|
|
321
310
|
#### Option 1: Alchemy (Recommended)
|
|
322
311
|
|
|
@@ -460,7 +449,7 @@ A Mythic miner (5.00x) earns 15.00 AGENT per mine in Era 0.
|
|
|
460
449
|
### Error Handling
|
|
461
450
|
|
|
462
451
|
The miner has built-in resilience:
|
|
463
|
-
- **
|
|
452
|
+
- **Flat retry delay** on transient failures (about 2s with a small jitter)
|
|
464
453
|
- **Max 10 consecutive failures** before the miner exits
|
|
465
454
|
- **Fatal errors** cause immediate exit: `"Not your miner"`, `"Supply exhausted"`, `"No contracts"`
|
|
466
455
|
- **Block timing** is handled automatically: if the block hasn't advanced, the miner waits
|
|
@@ -662,7 +651,7 @@ This section addresses the security model of apow-cli head-on. Every claim below
|
|
|
662
651
|
|
|
663
652
|
### Private Key Generation (Local Only)
|
|
664
653
|
|
|
665
|
-
Keys are generated via `viem/accounts` `generatePrivateKey()`, which uses Node.js `crypto.randomBytes(32)`, a cryptographically secure random number generator. Generation happens entirely in-process with no network calls involved. The private key is displayed once to the terminal and
|
|
654
|
+
Keys are generated via `viem/accounts` `generatePrivateKey()`, which uses Node.js `crypto.randomBytes(32)`, a cryptographically secure random number generator. Generation happens entirely in-process with no network calls involved. The private key is displayed once to the terminal, and the CLI can create both a plaintext `wallet-<address>.txt` import helper and a password-protected JSON keystore (`Web3 Secret Storage v3`) with file permissions `0o600`.
|
|
666
655
|
|
|
667
656
|
### Private Key Is NEVER Transmitted
|
|
668
657
|
|
|
@@ -710,7 +699,7 @@ The SMHL solver sends only generic word-generation prompts to the LLM (e.g., "Wr
|
|
|
710
699
|
|
|
711
700
|
1. **Use a fresh wallet.** Generate one with `npx apow-cli wallet new`. Do not import your main wallet or any wallet holding significant funds.
|
|
712
701
|
2. **Fund with only what you need.** ~0.005 ETH covers minting + several mining cycles.
|
|
713
|
-
3. **
|
|
702
|
+
3. **Prefer encrypted keystore backups** in `~/.apow/keystores/wallet-<address>.json`. The plaintext `wallet-<address>.txt` helper is convenient for importing into wallet UIs, but it is less secure.
|
|
714
703
|
4. **Verify the source before running** if you prefer:
|
|
715
704
|
```bash
|
|
716
705
|
git clone https://github.com/Agentoshi/apow-cli
|
|
@@ -781,7 +770,7 @@ The `apow dashboard` command group provides a real-time web UI for monitoring yo
|
|
|
781
770
|
| `apow dashboard start` | Launch the dashboard web UI at `http://localhost:3847`. Auto-opens browser. Press Ctrl+C to stop. |
|
|
782
771
|
| `apow dashboard add <address>` | Add a wallet address to monitor. Validates 0x + 40 hex chars. |
|
|
783
772
|
| `apow dashboard remove <address>` | Remove a wallet address from monitoring. |
|
|
784
|
-
| `apow dashboard scan [dir]` | Auto-detect wallets from `wallet-0x*.txt` files in the given directory (default: CWD). Also scans `rig*/` subdirectories. |
|
|
773
|
+
| `apow dashboard scan [dir]` | Auto-detect wallets from `wallet-0x*.txt` and `wallet-0x*.json` files in the given directory (default: CWD). Also scans `rig*/` subdirectories. |
|
|
785
774
|
| `apow dashboard wallets` | List all currently monitored wallet addresses. |
|
|
786
775
|
|
|
787
776
|
### How It Works
|
|
@@ -791,7 +780,7 @@ The `apow dashboard` command group provides a real-time web UI for monitoring yo
|
|
|
791
780
|
- **Data fetching:** Chunked RPC multicalls (max 30 per batch) with a 25-second TTL cache. Queries ETH balance, AGENT balance, rig ownership, rarity, hashpower, mine count, and earnings for every wallet.
|
|
792
781
|
- **NFT art:** Renders on-chain SVG art for each Mining Rig with rarity-based color coding.
|
|
793
782
|
- **Auto-seed:** On first run, seeds `wallets.json` with the address from your `.env` if configured.
|
|
794
|
-
- **Auto-detect:** `dashboard start` automatically scans CWD for `wallet-0x*.txt` files before launching.
|
|
783
|
+
- **Auto-detect:** `dashboard start` automatically scans CWD for `wallet-0x*.txt` and `wallet-0x*.json` files before launching.
|
|
795
784
|
|
|
796
785
|
### Fleet Configuration (`~/.apow/fleets.json`)
|
|
797
786
|
|
|
@@ -812,8 +801,8 @@ For managing wallets across multiple machines or directories, create `~/.apow/fl
|
|
|
812
801
|
|------|--------------|-------------|
|
|
813
802
|
| `array` | JSON array of addresses | Simple list: `["0xABC...", "0xDEF..."]` |
|
|
814
803
|
| `solkek` | JSON with `master.address` + `miners[].address` | Solkek fleet manager format |
|
|
815
|
-
| `rigdirs` | Directory containing `rig*/wallet-0x*.txt` | Scan rig subdirectories for wallet files |
|
|
816
|
-
| `walletfiles` | Directory containing `wallet-0x*.txt` | Scan flat directory for wallet files |
|
|
804
|
+
| `rigdirs` | Directory containing `rig*/wallet-0x*.txt` or `.json` | Scan rig subdirectories for wallet files |
|
|
805
|
+
| `walletfiles` | Directory containing `wallet-0x*.txt` or `.json` | Scan flat directory for wallet files |
|
|
817
806
|
|
|
818
807
|
If `fleets.json` does not exist, the dashboard falls back to `wallets.json` as a single "Main" fleet.
|
|
819
808
|
|