apow-cli 0.11.4 → 0.11.5
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 +12 -26
- package/dist/config.js +1 -1
- package/dist/dashboard-html.js +2 -2
- package/dist/errors.js +11 -3
- package/dist/fund.js +2 -2
- package/dist/grinder-http.js +28 -4
- package/dist/index.js +15 -6
- package/dist/miner.js +7 -2
- package/dist/mint.js +8 -3
- package/dist/preflight.js +26 -2
- package/dist/ui.js +9 -2
- package/local/vast-setup.sh +170 -0
- package/package.json +3 -2
- package/skill.md +11 -23
package/.env.example
CHANGED
|
@@ -11,7 +11,7 @@ ALLOW_LOCAL_FALLBACK_WITH_X402=false
|
|
|
11
11
|
# RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY
|
|
12
12
|
# USE_X402=false
|
|
13
13
|
|
|
14
|
-
# LLM Provider (clawrouter / openai / anthropic / gemini / ollama / claude-code / codex)
|
|
14
|
+
# LLM Provider (clawrouter / openai / anthropic / gemini / deepseek / qwen / ollama / claude-code / codex)
|
|
15
15
|
# Default: clawrouter when USE_X402=true, openai otherwise
|
|
16
16
|
# LLM_PROVIDER=clawrouter
|
|
17
17
|
# LLM_MODEL=blockrun/eco
|
|
@@ -42,9 +42,9 @@ ALLOW_LOCAL_FALLBACK_WITH_X402=false
|
|
|
42
42
|
# GPU Mining (optional — auto-detected, massive speed boost)
|
|
43
43
|
# Run `apow build-grinders` to compile native binaries automatically.
|
|
44
44
|
# GRINDER_MODE=auto # auto (default) or js (force JS-only)
|
|
45
|
-
# GPU_GRINDER_PATH
|
|
46
|
-
# CUDA_GRINDER_PATH=~/.apow/grinder-cuda
|
|
47
|
-
# CPU_GRINDER_PATH
|
|
45
|
+
# GPU_GRINDER_PATH=local/gpu/grinder-gpu # Metal binary (macOS, source install)
|
|
46
|
+
# CUDA_GRINDER_PATH=~/.apow/grinder-cuda # CUDA binary (NVIDIA GPU, after build-grinders)
|
|
47
|
+
# CPU_GRINDER_PATH=local/gpu/grinder-cpu # C binary (any platform, source install)
|
|
48
48
|
# CPU_THREADS=16 # Threads for CPU-C grinder (default: all cores)
|
|
49
49
|
# Remote GPU via Vast.ai (see: local/vast-setup.sh)
|
|
50
50
|
# VAST_IP= # Remote GPU host IP
|
package/README.md
CHANGED
|
@@ -8,6 +8,9 @@ Mining client for the [APoW (Agentic Proof of Work)](https://github.com/Agentosh
|
|
|
8
8
|
- `Easy Mode`: no config, x402 for RPC + LLM + GPU grinding
|
|
9
9
|
- `Advanced Mode`: choose which credentials you supply and which services stay autonomous
|
|
10
10
|
|
|
11
|
+
`apow start` is the fastest path when you want the full flow in one command:
|
|
12
|
+
setup, funding checks, minting, and mining.
|
|
13
|
+
|
|
11
14
|
## Install
|
|
12
15
|
|
|
13
16
|
```bash
|
|
@@ -32,20 +35,10 @@ npx apow-cli
|
|
|
32
35
|
## For AI Agents
|
|
33
36
|
|
|
34
37
|
Any AI agent can go from zero to actively mining with no human interaction except funding the wallet.
|
|
38
|
+
If the wallet is already configured, `apow start` skips ahead automatically.
|
|
35
39
|
|
|
36
40
|
```bash
|
|
37
|
-
|
|
38
|
-
npx apow-cli setup
|
|
39
|
-
|
|
40
|
-
# 2. Fund the wallet (bridge from any chain, auto-splits into ETH + USDC)
|
|
41
|
-
npx apow-cli fund --chain solana --token sol # bridge SOL → ETH+USDC on Base
|
|
42
|
-
# Or send ETH/USDC on Base directly
|
|
43
|
-
|
|
44
|
-
# 3. Mint a mining rig NFT (proves AI via LLM, one-time)
|
|
45
|
-
npx apow-cli mint
|
|
46
|
-
|
|
47
|
-
# 4. Start mining (Easy Mode uses remote x402 GPU by default)
|
|
48
|
-
npx apow-cli mine
|
|
41
|
+
npx apow-cli start
|
|
49
42
|
```
|
|
50
43
|
|
|
51
44
|
Easy Mode writes an `.env` equivalent to:
|
|
@@ -78,23 +71,16 @@ Each wallet gets one rig, each rig mines independently. More wallets = more chan
|
|
|
78
71
|
If you prefer to do it yourself:
|
|
79
72
|
|
|
80
73
|
```bash
|
|
81
|
-
#
|
|
82
|
-
npx apow-cli setup
|
|
83
|
-
|
|
84
|
-
# 2. Fund your wallet (bridge from Solana/Ethereum or send ETH directly)
|
|
85
|
-
npx apow-cli fund
|
|
86
|
-
|
|
87
|
-
# 3. Mint a mining rig NFT
|
|
88
|
-
npx apow-cli mint
|
|
89
|
-
|
|
90
|
-
# 4. Start mining
|
|
91
|
-
npx apow-cli mine
|
|
74
|
+
npx apow-cli start # guided happy path: setup -> fund -> mint -> mine
|
|
92
75
|
```
|
|
93
76
|
|
|
77
|
+
If you want to control each step manually, the older `setup -> fund -> mint -> mine` flow is still supported below.
|
|
78
|
+
|
|
94
79
|
## Commands
|
|
95
80
|
|
|
96
81
|
| Command | Description |
|
|
97
82
|
|---------|-------------|
|
|
83
|
+
| `apow start` | Guided happy path: setup -> fund -> mint -> mine |
|
|
98
84
|
| `apow setup` | Agent-first setup wizard: Easy Mode (x402 everywhere) or Advanced Mode |
|
|
99
85
|
| `apow fund` | Fund your wallet: bridge from Solana/Ethereum or send on Base, auto-split ETH+USDC |
|
|
100
86
|
| `apow wallet new` | Generate a new mining wallet |
|
|
@@ -114,7 +100,7 @@ Create a `.env` file or use `apow setup`:
|
|
|
114
100
|
|
|
115
101
|
```bash
|
|
116
102
|
PRIVATE_KEY=0x... # Your wallet private key
|
|
117
|
-
USE_X402=true # Auto-pay RPC + LLM via x402 (
|
|
103
|
+
USE_X402=true # Auto-pay RPC + LLM via x402 (2.00 USDC minimum starting balance, zero API keys)
|
|
118
104
|
USE_X402_GRIND=true # Auto-pay remote GPU grinding via x402
|
|
119
105
|
ALLOW_LOCAL_FALLBACK_WITH_X402=false # Easy Mode default: do not burn local CPU while x402 GPU is active
|
|
120
106
|
# RPC_URL=https://... # Or: bring your own RPC (free from Alchemy, QuickNode, etc.)
|
|
@@ -148,7 +134,7 @@ An LLM is required to mint your Mining Rig NFT (one-time identity verification).
|
|
|
148
134
|
|
|
149
135
|
## Funding (v0.7.0+)
|
|
150
136
|
|
|
151
|
-
Mining requires two assets on Base: **ETH** (gas) and **USDC** (x402 RPC). The `fund` command bridges from Solana or Ethereum, or accepts deposits on Base, and auto-splits into both:
|
|
137
|
+
Mining requires two assets on Base: **ETH** (gas) and **USDC** (x402 RPC). `apow start` checks both and can auto-split the wallet into the right mix. The `fund` command also bridges from Solana or Ethereum, or accepts deposits on Base, and auto-splits into both:
|
|
152
138
|
|
|
153
139
|
```bash
|
|
154
140
|
# From Solana (deposit address — send from any wallet, QR code included)
|
|
@@ -168,7 +154,7 @@ apow fund --chain base --no-swap
|
|
|
168
154
|
|
|
169
155
|
**Solana/Ethereum bridging:** Uses [Squid Router](https://squidrouter.com/) (Chainflip). Generates a one-time deposit address with QR code — send from any wallet. Requires `SQUID_INTEGRATOR_ID` in `.env` (free at [squidrouter.com](https://app.squidrouter.com/)).
|
|
170
156
|
|
|
171
|
-
**Auto-split targets:** 0.003 ETH (gas for ~100 mine txns) + 2.00 USDC (
|
|
157
|
+
**Auto-split targets:** 0.003 ETH (gas for ~100 mine txns) + 2.00 USDC (minimum x402 starting balance). If both are already met, the CLI skips the swap.
|
|
172
158
|
|
|
173
159
|
## x402 GPU Grinding
|
|
174
160
|
|
package/dist/config.js
CHANGED
|
@@ -15,7 +15,7 @@ const promises_1 = require("node:fs/promises");
|
|
|
15
15
|
const node_os_1 = __importDefault(require("node:os"));
|
|
16
16
|
const node_path_1 = require("node:path");
|
|
17
17
|
const chains_1 = require("viem/chains");
|
|
18
|
-
(0, dotenv_1.config)();
|
|
18
|
+
(0, dotenv_1.config)({ quiet: true });
|
|
19
19
|
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
20
20
|
const DEFAULT_OLLAMA_URL = "http://127.0.0.1:11434";
|
|
21
21
|
const DEFAULT_CHAIN_NAME = "base";
|
package/dist/dashboard-html.js
CHANGED
|
@@ -84,8 +84,8 @@ a{color:inherit;text-decoration:none}
|
|
|
84
84
|
<div class="status"><span class="pulse" id="statusDot"></span><span id="statusText">Loading...</span></div>
|
|
85
85
|
</div>
|
|
86
86
|
<div id="rpcWarning" class="rpc-warning" style="display:none">
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
Set <code>RPC_URL</code> in your <code>.env</code> for reliable dashboard refreshes.
|
|
88
|
+
A dedicated Base RPC is recommended for fleets.
|
|
89
89
|
</div>
|
|
90
90
|
<div id="errorBanner" class="error-banner" style="display:none">Failed to fetch data. Check RPC connection.</div>
|
|
91
91
|
<div id="fleetTabs" class="fleet-tabs" style="display:none"></div>
|
package/dist/errors.js
CHANGED
|
@@ -106,7 +106,7 @@ const patterns = [
|
|
|
106
106
|
classify: () => ({
|
|
107
107
|
category: "transient",
|
|
108
108
|
userMessage: "QuickNode x402 credit purchase failed — check USDC balance on Base",
|
|
109
|
-
recovery: "Send USDC to your wallet on Base
|
|
109
|
+
recovery: "Send at least 2.00 USDC to your wallet on Base for x402 starting balance, or set RPC_URL in .env to use a custom RPC",
|
|
110
110
|
}),
|
|
111
111
|
},
|
|
112
112
|
{
|
|
@@ -153,8 +153,16 @@ const patterns = [
|
|
|
153
153
|
test: (m) => m.includes("Remote GPU grind timed out") || (m.includes("GrindProxy") && /\b504\b/.test(m)),
|
|
154
154
|
classify: () => ({
|
|
155
155
|
category: "transient",
|
|
156
|
-
userMessage: "Remote GPU grind timed out
|
|
157
|
-
recovery: "
|
|
156
|
+
userMessage: "Remote GPU grind timed out",
|
|
157
|
+
recovery: "Retrying with a fresh remote grind request...",
|
|
158
|
+
}),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
test: (m) => m.includes("Remote GPU grind request failed"),
|
|
162
|
+
classify: () => ({
|
|
163
|
+
category: "transient",
|
|
164
|
+
userMessage: "Remote GPU grind request failed",
|
|
165
|
+
recovery: "Retrying with a fresh remote grind request...",
|
|
158
166
|
}),
|
|
159
167
|
},
|
|
160
168
|
{
|
package/dist/fund.js
CHANGED
|
@@ -177,7 +177,7 @@ async function showFinalBalances() {
|
|
|
177
177
|
const ethBal = Number((0, viem_1.formatEther)(await (0, wallet_1.getEthBalance)()));
|
|
178
178
|
const usdcBal = Number((0, viem_1.formatUnits)(await (0, uniswap_1.getUsdcBalance)(wallet_1.account.address), 6));
|
|
179
179
|
console.log("");
|
|
180
|
-
console.log(` ${ui.green("Ready to
|
|
180
|
+
console.log(` ${ui.green("Ready to mint!")}`);
|
|
181
181
|
ui.table([
|
|
182
182
|
["ETH", `${ethBal.toFixed(6)} ETH (gas)`],
|
|
183
183
|
["USDC", `${usdcBal.toFixed(2)} USDC (x402 RPC)`],
|
|
@@ -506,7 +506,7 @@ async function runFundFlow(options) {
|
|
|
506
506
|
console.log("");
|
|
507
507
|
// Already funded?
|
|
508
508
|
if (ethBalance >= constants_1.MIN_ETH && usdcBalance >= constants_1.MIN_USDC) {
|
|
509
|
-
console.log(` ${ui.green("Already funded! Ready to
|
|
509
|
+
console.log(` ${ui.green("Already funded! Ready to mint.")}`);
|
|
510
510
|
console.log(` Next: ${ui.cyan("apow mint")}`);
|
|
511
511
|
console.log("");
|
|
512
512
|
// Allow explicit re-run if user wants to add more
|
package/dist/grinder-http.js
CHANGED
|
@@ -50,6 +50,7 @@ exports.getGrindUrl = getGrindUrl;
|
|
|
50
50
|
exports.grindNonceHttp = grindNonceHttp;
|
|
51
51
|
const config_1 = require("./config");
|
|
52
52
|
const DEFAULT_GRIND_URL = "https://grind.apow.io/grind";
|
|
53
|
+
const GRIND_HTTP_TIMEOUT_MS = 20_000;
|
|
53
54
|
// Lazy singleton — created on first grind, reused across calls
|
|
54
55
|
let _fetchWithPayment = null;
|
|
55
56
|
function resetPaymentFetch() {
|
|
@@ -92,6 +93,8 @@ function getGrindUrl() {
|
|
|
92
93
|
}
|
|
93
94
|
async function grindNonceHttp(challengeNumber, target, minerAddress, grindUrl, privateKey, signal) {
|
|
94
95
|
const start = process.hrtime();
|
|
96
|
+
const timeoutSignal = AbortSignal.timeout(GRIND_HTTP_TIMEOUT_MS);
|
|
97
|
+
const requestSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
|
|
95
98
|
const requestInit = {
|
|
96
99
|
method: "POST",
|
|
97
100
|
headers: { "Content-Type": "application/json" },
|
|
@@ -100,12 +103,28 @@ async function grindNonceHttp(challengeNumber, target, minerAddress, grindUrl, p
|
|
|
100
103
|
target: target.toString(),
|
|
101
104
|
address: minerAddress,
|
|
102
105
|
}),
|
|
103
|
-
signal,
|
|
106
|
+
signal: requestSignal,
|
|
104
107
|
};
|
|
105
108
|
let response = null;
|
|
106
109
|
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
107
110
|
const paidFetch = await getPaymentFetch(privateKey);
|
|
108
|
-
|
|
111
|
+
try {
|
|
112
|
+
response = await paidFetch(grindUrl, requestInit);
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
if (signal?.aborted) {
|
|
116
|
+
throw err;
|
|
117
|
+
}
|
|
118
|
+
if (timeoutSignal.aborted) {
|
|
119
|
+
resetPaymentFetch();
|
|
120
|
+
throw new Error(`Remote GPU grind timed out (${GRIND_HTTP_TIMEOUT_MS / 1000}s)`);
|
|
121
|
+
}
|
|
122
|
+
resetPaymentFetch();
|
|
123
|
+
if (attempt === 1) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`Remote GPU grind request failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
127
|
+
}
|
|
109
128
|
if (response.ok) {
|
|
110
129
|
break;
|
|
111
130
|
}
|
|
@@ -121,23 +140,28 @@ async function grindNonceHttp(challengeNumber, target, minerAddress, grindUrl, p
|
|
|
121
140
|
catch { /* ignore decode errors */ }
|
|
122
141
|
}
|
|
123
142
|
const combinedError = `${reason} ${bodyDetail}`.trim();
|
|
124
|
-
|
|
143
|
+
const stalePaymentSession = /No matching payment requirements|facilitator|payment session|authorization/i.test(combinedError);
|
|
144
|
+
if (attempt === 1 && (stalePaymentSession || response.status >= 500)) {
|
|
125
145
|
resetPaymentFetch();
|
|
126
146
|
continue;
|
|
127
147
|
}
|
|
128
148
|
if (response.status === 402) {
|
|
149
|
+
resetPaymentFetch();
|
|
129
150
|
if (reason.includes("insufficient_balance")) {
|
|
130
151
|
throw new Error("x402 GPU payment failed: insufficient USDC balance");
|
|
131
152
|
}
|
|
132
153
|
else if (reason.includes("simulation_failed")) {
|
|
133
154
|
throw new Error(`x402 GPU payment failed: EVM simulation failed (USDC approval issue?) [${reason}]`);
|
|
134
155
|
}
|
|
156
|
+
else if (attempt === 1) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
135
159
|
else {
|
|
136
160
|
throw new Error(`x402 GPU payment failed: ${reason || bodyDetail.slice(0, 200) || "unknown"}`);
|
|
137
161
|
}
|
|
138
162
|
}
|
|
139
163
|
if (response.status === 504) {
|
|
140
|
-
throw new Error(
|
|
164
|
+
throw new Error(`Remote GPU grind timed out (${GRIND_HTTP_TIMEOUT_MS / 1000}s)`);
|
|
141
165
|
}
|
|
142
166
|
throw new Error(`GrindProxy HTTP ${response.status}: ${(bodyDetail || body).slice(0, 200)}`);
|
|
143
167
|
}
|
package/dist/index.js
CHANGED
|
@@ -99,13 +99,20 @@ function readVersion() {
|
|
|
99
99
|
return "0.1.0";
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
+
function shouldSkipUpdateCheck(argv) {
|
|
103
|
+
return argv.includes("--help")
|
|
104
|
+
|| argv.includes("-h")
|
|
105
|
+
|| argv.includes("--version")
|
|
106
|
+
|| argv.includes("-V")
|
|
107
|
+
|| argv[0] === "help";
|
|
108
|
+
}
|
|
102
109
|
async function resolveTokenId(tokenIdArg) {
|
|
103
110
|
if (tokenIdArg) {
|
|
104
111
|
return parseTokenId(tokenIdArg);
|
|
105
112
|
}
|
|
106
113
|
if (!wallet_1.account) {
|
|
107
114
|
ui.error("No token ID provided and no wallet configured.");
|
|
108
|
-
ui.hint("Usage: apow mine <tokenId>, or run `apow
|
|
115
|
+
ui.hint("Usage: apow mine <tokenId>, or run `apow start` for the guided happy path");
|
|
109
116
|
process.exit(1);
|
|
110
117
|
}
|
|
111
118
|
const miners = await (0, detect_1.detectMiners)(wallet_1.account.address);
|
|
@@ -210,7 +217,7 @@ async function setupWizard() {
|
|
|
210
217
|
ui.ok("LLM: ClawRouter x402 (wallet-paid, no API key)");
|
|
211
218
|
ui.ok("Grinder: x402 GPU (remote, wallet-paid, no local CPU fallback)");
|
|
212
219
|
console.log(` ${ui.dim("Easy mode is agent-first: no RPC key, no LLM key, no GPU rental setup.")}`);
|
|
213
|
-
console.log(` ${ui.dim("Fund the wallet with ETH + USDC on Base, then run: apow
|
|
220
|
+
console.log(` ${ui.dim("Fund the wallet with ETH + USDC on Base, then run: apow start")}`);
|
|
214
221
|
}
|
|
215
222
|
else {
|
|
216
223
|
// Advanced: user picks which services remain autonomous
|
|
@@ -338,9 +345,8 @@ async function setupWizard() {
|
|
|
338
345
|
}
|
|
339
346
|
}
|
|
340
347
|
console.log("");
|
|
341
|
-
console.log(` Next: ${ui.cyan("apow
|
|
342
|
-
console.log(` ${ui.
|
|
343
|
-
console.log(` ${ui.cyan("apow mine")}`);
|
|
348
|
+
console.log(` Next: ${ui.cyan("apow start")}`);
|
|
349
|
+
console.log(` ${ui.dim("Guided happy path: setup -> fund -> mint -> mine")}`);
|
|
344
350
|
console.log("");
|
|
345
351
|
}
|
|
346
352
|
async function runStartFlow() {
|
|
@@ -432,7 +438,10 @@ async function runStartFlow() {
|
|
|
432
438
|
}
|
|
433
439
|
async function main() {
|
|
434
440
|
const version = readVersion();
|
|
435
|
-
|
|
441
|
+
const argv = process.argv.slice(2);
|
|
442
|
+
if (!shouldSkipUpdateCheck(argv)) {
|
|
443
|
+
void (0, update_1.warnIfUpdateAvailable)(version);
|
|
444
|
+
}
|
|
436
445
|
const program = new commander_1.Command();
|
|
437
446
|
// SIGINT handler
|
|
438
447
|
process.on("SIGINT", async () => {
|
package/dist/miner.js
CHANGED
|
@@ -650,8 +650,13 @@ async function startMining(tokenId) {
|
|
|
650
650
|
await new Promise((r) => setTimeout(r, 2000));
|
|
651
651
|
}
|
|
652
652
|
const delta = earnings - runningTotal;
|
|
653
|
-
|
|
654
|
-
|
|
653
|
+
if (delta > 0n) {
|
|
654
|
+
runningTotal = earnings;
|
|
655
|
+
console.log(` ${ui.green("+")} ${(0, viem_1.formatEther)(delta)} AGENT | Total: ${(0, viem_1.formatEther)(earnings)} AGENT | Tx: ${ui.dim((0, explorer_1.txUrl)(txHash))}`);
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
console.log(` ${ui.green("+")} ~${(0, viem_1.formatEther)(estimatedReward)} AGENT ${ui.dim("(earnings sync pending)")} | Total: ${(0, viem_1.formatEther)(runningTotal)} AGENT | Tx: ${ui.dim((0, explorer_1.txUrl)(txHash))}`);
|
|
659
|
+
}
|
|
655
660
|
console.log("");
|
|
656
661
|
// Wait for block advancement before next iteration
|
|
657
662
|
await waitForNextBlock(receipt.blockNumber);
|
package/dist/mint.js
CHANGED
|
@@ -48,6 +48,7 @@ const ui = __importStar(require("./ui"));
|
|
|
48
48
|
const wallet_1 = require("./wallet");
|
|
49
49
|
const miningAgentAbi = MiningAgent_json_1.default;
|
|
50
50
|
const ZERO_SEED = `0x${"0".repeat(64)}`;
|
|
51
|
+
const MINT_GAS_RESERVE_ETH = (0, viem_1.parseEther)("0.003");
|
|
51
52
|
function deriveChallengeFromSeed(seed) {
|
|
52
53
|
const bytes = (0, viem_1.hexToBytes)(seed);
|
|
53
54
|
const firstNChars = 5 + (bytes[0] % 6);
|
|
@@ -128,12 +129,16 @@ async function runMintFlow(options = {}) {
|
|
|
128
129
|
console.log("");
|
|
129
130
|
ui.table([
|
|
130
131
|
["Mint price", `${(0, viem_1.formatEther)(mintPrice)} ETH`],
|
|
132
|
+
["Gas reserve", `${(0, viem_1.formatEther)(MINT_GAS_RESERVE_ETH)} ETH (getChallenge + mint)`],
|
|
133
|
+
["Required", `${(0, viem_1.formatEther)(mintPrice + MINT_GAS_RESERVE_ETH)} ETH total`],
|
|
131
134
|
["Balance", `${Number((0, viem_1.formatEther)(ethBalance)).toFixed(6)} ETH`],
|
|
132
135
|
]);
|
|
133
136
|
console.log("");
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
ui.
|
|
137
|
+
const requiredBalance = mintPrice + MINT_GAS_RESERVE_ETH;
|
|
138
|
+
if (ethBalance < requiredBalance) {
|
|
139
|
+
ui.error("Insufficient ETH for mint and challenge gas.");
|
|
140
|
+
ui.hint(`Mint uses 2 transactions: getChallenge and mint.`);
|
|
141
|
+
ui.hint(`Send at least ${(0, viem_1.formatEther)(requiredBalance)} ETH to ${account.address} on Base.`);
|
|
137
142
|
return null;
|
|
138
143
|
}
|
|
139
144
|
// Confirm before spending ETH
|
package/dist/preflight.js
CHANGED
|
@@ -40,13 +40,16 @@ exports.runPreflight = runPreflight;
|
|
|
40
40
|
const viem_1 = require("viem");
|
|
41
41
|
const chains_1 = require("viem/chains");
|
|
42
42
|
const AgentCoin_json_1 = __importDefault(require("./abi/AgentCoin.json"));
|
|
43
|
+
const MiningAgent_json_1 = __importDefault(require("./abi/MiningAgent.json"));
|
|
43
44
|
const config_1 = require("./config");
|
|
44
45
|
const grinder_http_1 = require("./grinder-http");
|
|
45
46
|
const wallet_1 = require("./wallet");
|
|
46
47
|
const ui = __importStar(require("./ui"));
|
|
47
48
|
const agentCoinAbi = AgentCoin_json_1.default;
|
|
49
|
+
const miningAgentAbi = MiningAgent_json_1.default;
|
|
48
50
|
const USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
49
51
|
const USDC_DECIMALS = 6;
|
|
52
|
+
const MINT_GAS_RESERVE_ETH = (0, viem_1.parseEther)("0.003");
|
|
50
53
|
const erc20BalanceAbi = [
|
|
51
54
|
{
|
|
52
55
|
type: "function",
|
|
@@ -98,7 +101,7 @@ async function runPreflight(level) {
|
|
|
98
101
|
results.push({
|
|
99
102
|
label: "No USDC balance — QuickNode x402 requires USDC on Base",
|
|
100
103
|
passed: false,
|
|
101
|
-
fix: `Send USDC to ${wallet_1.account.address} on Base
|
|
104
|
+
fix: `Send at least 2.00 USDC to ${wallet_1.account.address} on Base for x402 starting balance; add more if you want extra headroom. Run \`apow fund\` to bridge from Solana or Ethereum.`,
|
|
102
105
|
});
|
|
103
106
|
}
|
|
104
107
|
else {
|
|
@@ -164,7 +167,28 @@ async function runPreflight(level) {
|
|
|
164
167
|
try {
|
|
165
168
|
const balance = await wallet_1.publicClient.getBalance({ address: wallet_1.account.address });
|
|
166
169
|
const ethBalance = Number((0, viem_1.formatEther)(balance));
|
|
167
|
-
if (
|
|
170
|
+
if (level === "wallet") {
|
|
171
|
+
const mintPrice = (await wallet_1.publicClient.readContract({
|
|
172
|
+
address: config_1.config.miningAgentAddress,
|
|
173
|
+
abi: miningAgentAbi,
|
|
174
|
+
functionName: "getMintPrice",
|
|
175
|
+
}));
|
|
176
|
+
const requiredBalance = mintPrice + MINT_GAS_RESERVE_ETH;
|
|
177
|
+
if (balance < requiredBalance) {
|
|
178
|
+
results.push({
|
|
179
|
+
label: `Mint-ready ETH balance (${ethBalance.toFixed(6)} ETH)`,
|
|
180
|
+
passed: false,
|
|
181
|
+
fix: `Mint needs ${(0, viem_1.formatEther)(mintPrice)} ETH for the rig plus ~${(0, viem_1.formatEther)(MINT_GAS_RESERVE_ETH)} ETH for the getChallenge and mint transactions. Send at least ${(0, viem_1.formatEther)(requiredBalance)} ETH to ${wallet_1.account.address} on Base.`,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
results.push({
|
|
186
|
+
label: `Mint-ready ETH balance (${ethBalance.toFixed(6)} ETH)`,
|
|
187
|
+
passed: true,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else if (ethBalance < 0.001) {
|
|
168
192
|
results.push({
|
|
169
193
|
label: `Low ETH balance (${ethBalance.toFixed(6)} ETH)`,
|
|
170
194
|
passed: false,
|
package/dist/ui.js
CHANGED
|
@@ -16,7 +16,8 @@ exports.warn = warn;
|
|
|
16
16
|
exports.info = info;
|
|
17
17
|
const promises_1 = require("node:readline/promises");
|
|
18
18
|
const node_process_1 = require("node:process");
|
|
19
|
-
const isTTY = node_process_1.stdout.isTTY && node_process_1.stderr.isTTY;
|
|
19
|
+
const isTTY = !!node_process_1.stdout.isTTY && !!node_process_1.stderr.isTTY;
|
|
20
|
+
const isInteractive = !!node_process_1.stdin.isTTY && isTTY;
|
|
20
21
|
const noColor = !!process.env.NO_COLOR || !isTTY;
|
|
21
22
|
function wrap(code, reset) {
|
|
22
23
|
if (noColor)
|
|
@@ -101,7 +102,7 @@ function stopAll() {
|
|
|
101
102
|
activeSpinners.clear();
|
|
102
103
|
}
|
|
103
104
|
async function confirm(question) {
|
|
104
|
-
if (!
|
|
105
|
+
if (!isInteractive)
|
|
105
106
|
return true;
|
|
106
107
|
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stderr });
|
|
107
108
|
const answer = await rl.question(` ${question} ${(0, exports.dim)("(Y/n)")} `);
|
|
@@ -110,6 +111,9 @@ async function confirm(question) {
|
|
|
110
111
|
return trimmed === "" || trimmed === "y" || trimmed === "yes";
|
|
111
112
|
}
|
|
112
113
|
async function prompt(question, defaultValue) {
|
|
114
|
+
if (!isInteractive) {
|
|
115
|
+
return defaultValue ?? "";
|
|
116
|
+
}
|
|
113
117
|
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stderr });
|
|
114
118
|
const hint = defaultValue ? ` ${(0, exports.dim)(`[${defaultValue}`)}${(0, exports.dim)("]")}` : "";
|
|
115
119
|
const answer = await rl.question(` ${question}${hint}: `);
|
|
@@ -117,6 +121,9 @@ async function prompt(question, defaultValue) {
|
|
|
117
121
|
return answer.trim() || defaultValue || "";
|
|
118
122
|
}
|
|
119
123
|
async function promptSecret(question) {
|
|
124
|
+
if (!isInteractive) {
|
|
125
|
+
return "";
|
|
126
|
+
}
|
|
120
127
|
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stderr });
|
|
121
128
|
const answer = await rl.question(` ${question}: `);
|
|
122
129
|
rl.close();
|
|
@@ -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.5",
|
|
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
|
|
|
@@ -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)
|
|
@@ -283,7 +271,7 @@ CHAIN=base
|
|
|
283
271
|
| `CLAWROUTER_PORT` | No | `8402` | Port for ClawRouter local proxy (only if default is in use) |
|
|
284
272
|
| `MINER_THREADS` | No | All CPU cores | Threads for JS nonce grinding (fallback if no native GPU/CPU grinder detected) |
|
|
285
273
|
| `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 (
|
|
274
|
+
| `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
275
|
| `CHAIN` | No | `base` | Network selector; auto-detects `baseSepolia` if RPC URL contains "sepolia" |
|
|
288
276
|
| `SOLANA_RPC_URL` | No | `https://api.mainnet-beta.solana.com` | Solana RPC endpoint (only for `apow fund --chain solana`) |
|
|
289
277
|
| `ETHEREUM_RPC_URL` | No | `https://cloudflare-eth.com` | Ethereum mainnet RPC (only for `apow fund --chain ethereum`) |
|
|
@@ -316,7 +304,7 @@ CHAIN=base
|
|
|
316
304
|
|
|
317
305
|
### RPC Recommendations
|
|
318
306
|
|
|
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 (
|
|
307
|
+
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
308
|
|
|
321
309
|
#### Option 1: Alchemy (Recommended)
|
|
322
310
|
|
|
@@ -460,7 +448,7 @@ A Mythic miner (5.00x) earns 15.00 AGENT per mine in Era 0.
|
|
|
460
448
|
### Error Handling
|
|
461
449
|
|
|
462
450
|
The miner has built-in resilience:
|
|
463
|
-
- **
|
|
451
|
+
- **Flat retry delay** on transient failures (about 2s with a small jitter)
|
|
464
452
|
- **Max 10 consecutive failures** before the miner exits
|
|
465
453
|
- **Fatal errors** cause immediate exit: `"Not your miner"`, `"Supply exhausted"`, `"No contracts"`
|
|
466
454
|
- **Block timing** is handled automatically: if the block hasn't advanced, the miner waits
|