apow-cli 0.4.0 → 0.6.0
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 +9 -4
- package/README.md +90 -27
- package/dist/bridge/constants.js +34 -0
- package/dist/bridge/debridge.js +151 -28
- package/dist/bridge/solana.js +13 -0
- package/dist/bridge/squid.js +54 -21
- package/dist/bridge/uniswap.js +184 -0
- package/dist/config.js +1 -0
- package/dist/dashboard.js +6 -2
- package/dist/errors.js +40 -0
- package/dist/fund.js +506 -133
- package/dist/index.js +10 -23
- package/dist/preflight.js +52 -0
- package/dist/wallet.js +24 -2
- package/dist/x402.js +45 -0
- package/package.json +3 -1
- package/skill.md +150 -101
package/skill.md
CHANGED
|
@@ -21,11 +21,11 @@ metadata:
|
|
|
21
21
|
|
|
22
22
|
> A self-contained guide for any AI agent to go from zero knowledge to actively mining AGENT tokens on Base.
|
|
23
23
|
|
|
24
|
-
**For AI agents:** You are the operator. You can do everything autonomously
|
|
24
|
+
**For AI agents:** You are the operator. You can do everything autonomously: generate wallets,
|
|
25
25
|
configure the miner, mint, and mine. The only step that requires your user is funding the wallet
|
|
26
26
|
with ETH on Base. Everything else you handle yourself.
|
|
27
27
|
|
|
28
|
-
> **IMPORTANT
|
|
28
|
+
> **IMPORTANT: You need a dedicated RPC endpoint.** The default public RPC (`https://mainnet.base.org`) has aggressive rate limits and **will cause minting and mining to fail**. Before starting, get a free Alchemy endpoint:
|
|
29
29
|
>
|
|
30
30
|
> 1. Go to [alchemy.com](https://www.alchemy.com/) and sign up (free, no credit card)
|
|
31
31
|
> 2. Click **Create new app** → Name: `apow-miner` → Chain: **Base** → Network: **Base Mainnet**
|
|
@@ -40,8 +40,8 @@ with ETH on Base. Everything else you handle yourself.
|
|
|
40
40
|
|
|
41
41
|
**Via npm (recommended):**
|
|
42
42
|
```bash
|
|
43
|
-
npx apow-cli setup # interactive wizard
|
|
44
|
-
npx apow-cli fund # fund wallet
|
|
43
|
+
npx apow-cli setup # interactive wizard: wallet, RPC, LLM config
|
|
44
|
+
npx apow-cli fund # fund wallet: bridge from Solana or show deposit address
|
|
45
45
|
npx apow-cli mint # mint a mining rig NFT
|
|
46
46
|
npx apow-cli mine # start mining (auto-detects your best rig)
|
|
47
47
|
```
|
|
@@ -65,9 +65,9 @@ npx apow-cli wallet new
|
|
|
65
65
|
# Captures address + private key from output (also saved to wallet-<address>.txt)
|
|
66
66
|
|
|
67
67
|
# 2. Write .env directly (no interactive prompts needed)
|
|
68
|
-
# LLM config is only needed for minting (one-time)
|
|
68
|
+
# LLM config is only needed for minting (one-time); mining uses algorithmic SMHL.
|
|
69
69
|
# IMPORTANT: Use an API-based provider for minting (openai/anthropic/gemini/deepseek/qwen).
|
|
70
|
-
# IMPORTANT: The public Base RPC is unreliable
|
|
70
|
+
# IMPORTANT: The public Base RPC is unreliable. Get a free Alchemy URL (see RPC Recommendations).
|
|
71
71
|
cat > .env << 'EOF'
|
|
72
72
|
PRIVATE_KEY=0x<from step 1>
|
|
73
73
|
RPC_URL=https://mainnet.base.org
|
|
@@ -92,15 +92,15 @@ npx apow-cli mine
|
|
|
92
92
|
|
|
93
93
|
## 1. What is APoW?
|
|
94
94
|
|
|
95
|
-
Agent Proof-of-Work (APoW) is a mining protocol on Base L2 where AI agents prove their identity once by minting an ERC-8004 Mining Rig NFT (requires LLM to solve an SMHL challenge), then compete on hash power to mine AGENT tokens. Mining requires owning a Miner NFT (ERC-721 with rarity-based hashpower)
|
|
95
|
+
Agent Proof-of-Work (APoW) is a mining protocol on Base L2 where AI agents prove their identity once by minting an ERC-8004 Mining Rig NFT (requires LLM to solve an SMHL challenge), then compete on hash power to mine AGENT tokens. Mining requires owning a Miner NFT (ERC-721 with rarity-based hashpower) and no LLM is needed after minting. Rewards start at 3 AGENT per mine (scaled by hashpower) and decay by 10% every 500,000 total network mines, with a hard cap of 21,000,000 AGENT.
|
|
96
96
|
|
|
97
97
|
### SMHL Challenge Format
|
|
98
98
|
|
|
99
99
|
SMHL ("Show Me Human Language") serves two different roles in APoW:
|
|
100
100
|
|
|
101
|
-
**SMHL for Minting (identity verification):** When minting a Mining Rig, your LLM solves an SMHL challenge to prove agent capability. This is the "prove yourself" gate
|
|
101
|
+
**SMHL for Minting (identity verification):** When minting a Mining Rig, your LLM solves an SMHL challenge to prove agent capability. This is the "prove yourself" gate: your agent demonstrates it can solve constrained text generation. The LLM receives a prompt like: "Generate a sentence that is approximately N characters long, contains approximately W words, and includes the letter 'X'."
|
|
102
102
|
|
|
103
|
-
**SMHL for Mining (algorithmic):** During mining, SMHL solutions are generated algorithmically in microseconds
|
|
103
|
+
**SMHL for Mining (algorithmic):** During mining, SMHL solutions are generated algorithmically in microseconds, with no LLM needed. Your agent identity was already established when you minted your ERC-8004 Mining Rig. Mining is a hash power competition, not a language puzzle.
|
|
104
104
|
|
|
105
105
|
On-chain verification checks (both minting and mining):
|
|
106
106
|
1. **Length** (in bytes): within ±5 of the target
|
|
@@ -117,7 +117,7 @@ The miner client validates locally before submitting.
|
|
|
117
117
|
|---|---|
|
|
118
118
|
| **Node.js** | v18 or higher |
|
|
119
119
|
| **Base wallet** | A private key with ETH on Base (for gas + mint fee) |
|
|
120
|
-
| **LLM access** | API key (OpenAI,
|
|
120
|
+
| **LLM access** | API key (OpenAI, Gemini, DeepSeek, Qwen, or Anthropic) or local Ollama (**required for minting only**) |
|
|
121
121
|
| **git** | Only if installing from source (not needed for npm) |
|
|
122
122
|
|
|
123
123
|
---
|
|
@@ -131,7 +131,7 @@ npx apow-cli setup
|
|
|
131
131
|
# Select "No" when asked if you have a wallet → generates one automatically
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
Or generate one directly (useful for agents
|
|
134
|
+
Or generate one directly (useful for agents, no prompts):
|
|
135
135
|
|
|
136
136
|
```bash
|
|
137
137
|
npx apow-cli wallet new
|
|
@@ -195,7 +195,7 @@ Phantom natively supports Base. Tell your user:
|
|
|
195
195
|
#### From an Exchange (Coinbase, Binance, etc.)
|
|
196
196
|
1. Buy ETH on Base (Coinbase supports Base withdrawals natively)
|
|
197
197
|
2. Withdraw to the mining wallet address
|
|
198
|
-
3. Select **Base** as the network
|
|
198
|
+
3. Select **Base** as the network. Do NOT send on Ethereum mainnet
|
|
199
199
|
|
|
200
200
|
#### From Ethereum Mainnet
|
|
201
201
|
Bridge ETH to Base via [bridge.base.org](https://bridge.base.org):
|
|
@@ -209,7 +209,7 @@ Send ETH directly to the mining wallet address on Base.
|
|
|
209
209
|
After funding, verify the balance:
|
|
210
210
|
```bash
|
|
211
211
|
npx apow-cli stats
|
|
212
|
-
# Shows wallet balance
|
|
212
|
+
# Shows wallet balance; must be ≥0.005 ETH to proceed
|
|
213
213
|
```
|
|
214
214
|
|
|
215
215
|
---
|
|
@@ -220,7 +220,7 @@ npx apow-cli stats
|
|
|
220
220
|
```bash
|
|
221
221
|
npx apow-cli setup
|
|
222
222
|
```
|
|
223
|
-
All `apow` commands work via `npx`
|
|
223
|
+
All `apow` commands work via `npx` with no global install required.
|
|
224
224
|
|
|
225
225
|
**Via source (for developers):**
|
|
226
226
|
```bash
|
|
@@ -245,9 +245,9 @@ PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE
|
|
|
245
245
|
MINING_AGENT_ADDRESS=0xB7caD3ca5F2BD8aEC2Eb67d6E8D448099B3bC03D
|
|
246
246
|
AGENT_COIN_ADDRESS=0x12577CF0D8a07363224D6909c54C056A183e13b3
|
|
247
247
|
|
|
248
|
-
# === LLM Configuration (required for minting only
|
|
248
|
+
# === LLM Configuration (required for minting only; mining uses optimized solving) ===
|
|
249
249
|
|
|
250
|
-
# Provider: "openai" | "
|
|
250
|
+
# Provider: "openai" | "gemini" | "deepseek" | "qwen" | "anthropic" | "ollama"
|
|
251
251
|
LLM_PROVIDER=openai
|
|
252
252
|
|
|
253
253
|
# API key (not required if LLM_PROVIDER=ollama)
|
|
@@ -258,7 +258,7 @@ LLM_MODEL=gpt-4o-mini
|
|
|
258
258
|
|
|
259
259
|
# === Network ===
|
|
260
260
|
|
|
261
|
-
# Base RPC endpoint
|
|
261
|
+
# Base RPC endpoint. The public default is unreliable for sustained mining.
|
|
262
262
|
# Strongly recommend a free Alchemy key: https://www.alchemy.com/ (no credit card)
|
|
263
263
|
RPC_URL=https://mainnet.base.org
|
|
264
264
|
|
|
@@ -270,35 +270,32 @@ CHAIN=base
|
|
|
270
270
|
|
|
271
271
|
| Variable | Required | Default | Description |
|
|
272
272
|
|---|---|---|---|
|
|
273
|
-
| `PRIVATE_KEY` | Yes |
|
|
274
|
-
| `MINING_AGENT_ADDRESS` | Yes |
|
|
275
|
-
| `AGENT_COIN_ADDRESS` | Yes |
|
|
276
|
-
| `LLM_PROVIDER` | For minting | `openai` | LLM provider for minting: `openai`, `
|
|
277
|
-
| `LLM_API_KEY` | For minting |
|
|
273
|
+
| `PRIVATE_KEY` | Yes | - | Wallet private key (0x + 64 hex chars) |
|
|
274
|
+
| `MINING_AGENT_ADDRESS` | Yes | - | Deployed MiningAgent contract address |
|
|
275
|
+
| `AGENT_COIN_ADDRESS` | Yes | - | Deployed AgentCoin contract address |
|
|
276
|
+
| `LLM_PROVIDER` | For minting | `openai` | LLM provider for minting: `openai`, `gemini`, `deepseek`, `qwen`, `anthropic`, or `ollama`. Not needed for mining. |
|
|
277
|
+
| `LLM_API_KEY` | For minting | - | API key for minting. Falls back to `OPENAI_API_KEY` / `GEMINI_API_KEY` / `DEEPSEEK_API_KEY` / `DASHSCOPE_API_KEY` / `ANTHROPIC_API_KEY` per provider. Not needed for `ollama` or mining. |
|
|
278
278
|
| `LLM_MODEL` | For minting | `gpt-4o-mini` | Model identifier passed to the provider (minting only) |
|
|
279
279
|
| `MINER_THREADS` | No | All CPU cores | Number of threads for parallel nonce grinding |
|
|
280
|
-
| `RPC_URL` | **Strongly recommended** | `https://mainnet.base.org` | Base JSON-RPC endpoint. **The default public RPC is unreliable
|
|
280
|
+
| `RPC_URL` | **Strongly recommended** | `https://mainnet.base.org` | Base JSON-RPC endpoint. **The default public RPC is unreliable. Use Alchemy (free) or another dedicated provider.** |
|
|
281
281
|
| `CHAIN` | No | `base` | Network selector; auto-detects `baseSepolia` if RPC URL contains "sepolia" |
|
|
282
282
|
| `SOLANA_RPC_URL` | No | `https://api.mainnet-beta.solana.com` | Solana RPC endpoint (only for `apow fund --solana`) |
|
|
283
|
-
| `SQUID_INTEGRATOR_ID` | No |
|
|
283
|
+
| `SQUID_INTEGRATOR_ID` | No | - | Squid Router integrator ID for deposit address flow (free at [squidrouter.com](https://app.squidrouter.com/)) |
|
|
284
284
|
|
|
285
285
|
### LLM Provider Recommendations (for Minting)
|
|
286
286
|
|
|
287
|
-
> An LLM is only needed for **minting** your Mining Rig NFT (one-time identity verification). Mining uses optimized algorithmic SMHL solving
|
|
287
|
+
> An LLM is only needed for **minting** your Mining Rig NFT (one-time identity verification). Mining uses optimized algorithmic SMHL solving, with no LLM needed.
|
|
288
288
|
>
|
|
289
|
-
>
|
|
289
|
+
> An LLM is only needed for **minting** your Mining Rig NFT (one-time identity verification). Use a fast, non-thinking model to stay within the 20-second challenge window.
|
|
290
290
|
|
|
291
291
|
| Provider | Model | Cost per call | Notes |
|
|
292
292
|
|---|---|---|---|
|
|
293
|
-
| OpenAI | `gpt-4o-mini` | ~$0.001 | **Recommended
|
|
293
|
+
| OpenAI | `gpt-4o-mini` | ~$0.001 | **Recommended.** Cheapest, fastest, reliable |
|
|
294
294
|
| Gemini | `gemini-2.5-flash` | ~$0.001 | Fast, good accuracy |
|
|
295
|
-
| Anthropic | `claude-sonnet-4-5-20250929` | ~$0.005 | High accuracy on constrained generation |
|
|
296
|
-
| OpenAI | `gpt-4o` | ~$0.005 | Higher quality, slightly slower |
|
|
297
295
|
| DeepSeek | `deepseek-chat` | ~$0.001 | Fast, accessible in China |
|
|
298
296
|
| Qwen | `qwen-plus` | ~$0.002 | Alibaba Cloud, accessible in China |
|
|
297
|
+
| Anthropic | `claude-sonnet-4-5-20250929` | ~$0.005 | Works but slower and more expensive |
|
|
299
298
|
| Ollama | `llama3.1` | Free (local) | Requires local GPU; variable accuracy |
|
|
300
|
-
| Claude Code | `default` | Subscription | **Not recommended for minting** — CLI startup too slow for 20s window |
|
|
301
|
-
| Codex | `default` | Subscription | **Not recommended for minting** — CLI startup too slow for 20s window |
|
|
302
299
|
|
|
303
300
|
### RPC Recommendations
|
|
304
301
|
|
|
@@ -355,7 +352,7 @@ The default `https://mainnet.base.org` is a public RPC with aggressive rate limi
|
|
|
355
352
|
|
|
356
353
|
## 7. Step 4: Mint a Mining Rig
|
|
357
354
|
|
|
358
|
-
**One rig per wallet.** The CLI enforces a one-rig-per-wallet rule. Only one rig can mine competitively per wallet (one mine per block globally), so extra rigs in the same wallet waste ETH. To scale, create additional wallets
|
|
355
|
+
**One rig per wallet.** The CLI enforces a one-rig-per-wallet rule. Only one rig can mine competitively per wallet (one mine per block globally), so extra rigs in the same wallet waste ETH. To scale, create additional wallets (see [Scaling with Multiple Wallets](#scaling-with-multiple-wallets) below).
|
|
359
356
|
|
|
360
357
|
```bash
|
|
361
358
|
npx apow-cli mint
|
|
@@ -367,9 +364,9 @@ npx apow-cli mint
|
|
|
367
364
|
3. The LLM generates a sentence matching the constraints (approximate length, approximate word count, must contain a specific letter).
|
|
368
365
|
4. The client calls `mint(solution)` with the mint fee attached. The contract verifies the SMHL solution on-chain.
|
|
369
366
|
5. On success, an ERC-721 Miner NFT is minted to your wallet with a randomly determined rarity and hashpower.
|
|
370
|
-
6. The mint fee is forwarded to the LPVault (used for AGENT/USDC liquidity
|
|
367
|
+
6. The mint fee is forwarded to the LPVault (used for AGENT/USDC liquidity: initial LP deployment at threshold, then ongoing `addLiquidity()` to deepen the position).
|
|
371
368
|
|
|
372
|
-
**Challenge expiry:** 20 seconds from `getChallenge` to `mint`. The LLM must solve quickly. Use
|
|
369
|
+
**Challenge expiry:** 20 seconds from `getChallenge` to `mint`. The LLM must solve quickly. Use a fast, non-thinking model (gpt-4o-mini, gemini-2.5-flash, deepseek-chat).
|
|
373
370
|
|
|
374
371
|
### Mint Price
|
|
375
372
|
|
|
@@ -401,21 +398,21 @@ npx apow-cli mine <tokenId> # or specify a rig by token ID
|
|
|
401
398
|
|
|
402
399
|
### What Each Mining Cycle Does
|
|
403
400
|
|
|
404
|
-
1. **Ownership check
|
|
405
|
-
2. **Supply check
|
|
406
|
-
3. **Fetch challenge
|
|
407
|
-
- `challengeNumber` (bytes32)
|
|
408
|
-
- `miningTarget` (uint256)
|
|
409
|
-
- `smhl
|
|
410
|
-
4. **Solve SMHL
|
|
411
|
-
5. **Grind nonce
|
|
412
|
-
6. **Submit proof
|
|
413
|
-
7. **Collect reward
|
|
414
|
-
8. **Wait for next block
|
|
401
|
+
1. **Ownership check:** verifies your wallet owns the specified token.
|
|
402
|
+
2. **Supply check:** confirms mineable supply is not exhausted.
|
|
403
|
+
3. **Fetch challenge:** reads `getMiningChallenge()` from the AgentCoin contract, which returns:
|
|
404
|
+
- `challengeNumber` (bytes32): the current PoW challenge hash
|
|
405
|
+
- `miningTarget` (uint256): the difficulty target
|
|
406
|
+
- `smhl`: the SMHL format challenge
|
|
407
|
+
4. **Solve SMHL:** generates a valid SMHL solution algorithmically (sub-millisecond, no LLM needed).
|
|
408
|
+
5. **Grind nonce:** multi-threaded brute-force search for a `nonce` where `keccak256(challengeNumber, minerAddress, nonce) < miningTarget`. Uses all CPU cores by default.
|
|
409
|
+
6. **Submit proof:** calls `mine(nonce, smhlSolution, tokenId)` on AgentCoin. The contract verifies both the hash and SMHL solution on-chain.
|
|
410
|
+
7. **Collect reward:** AGENT tokens are minted directly to your wallet.
|
|
411
|
+
8. **Wait for next block:** the protocol enforces one mine per block network-wide. The client waits for block advancement before the next cycle.
|
|
415
412
|
|
|
416
413
|
### Reward Economics
|
|
417
414
|
|
|
418
|
-
**One mine per block, network-wide.** The protocol allows exactly one successful `mine()` per Base block across the entire network
|
|
415
|
+
**One mine per block, network-wide.** The protocol allows exactly one successful `mine()` per Base block across the entire network, not per wallet. All miners compete for each block's reward. If two miners submit in the same block, only the first transaction to be included succeeds; the other reverts (and still costs gas).
|
|
419
416
|
|
|
420
417
|
| Parameter | Value |
|
|
421
418
|
|---|---|
|
|
@@ -430,18 +427,18 @@ npx apow-cli mine <tokenId> # or specify a rig by token ID
|
|
|
430
427
|
|
|
431
428
|
| Era | Total Network Mines | Reward per Mine |
|
|
432
429
|
|---|---|---|
|
|
433
|
-
| 0 | 0
|
|
434
|
-
| 1 | 500,000
|
|
435
|
-
| 2 | 1,000,000
|
|
436
|
-
| 3 | 1,500,000
|
|
430
|
+
| 0 | 0 to 499,999 | 3.00 AGENT |
|
|
431
|
+
| 1 | 500,000 to 999,999 | 2.70 AGENT |
|
|
432
|
+
| 2 | 1,000,000 to 1,499,999 | 2.43 AGENT |
|
|
433
|
+
| 3 | 1,500,000 to 1,999,999 | 2.187 AGENT |
|
|
437
434
|
|
|
438
435
|
A Mythic miner (5.00x) earns 15.00 AGENT per mine in Era 0.
|
|
439
436
|
|
|
440
437
|
### Cost Per Mine
|
|
441
438
|
|
|
442
439
|
- **Gas:** ~0.001 ETH per `mine()` transaction on Base
|
|
443
|
-
- **LLM:** $0 (mining uses algorithmic SMHL
|
|
444
|
-
- **Total:** ~$0.003
|
|
440
|
+
- **LLM:** $0 (mining uses algorithmic SMHL, no LLM calls)
|
|
441
|
+
- **Total:** ~$0.003 to $0.005 per mining cycle (gas only)
|
|
445
442
|
|
|
446
443
|
### Error Handling
|
|
447
444
|
|
|
@@ -479,15 +476,15 @@ npx apow-cli stats <tokenId> # stats for a specific rig
|
|
|
479
476
|
|
|
480
477
|
### Competitive Mining & Scaling
|
|
481
478
|
|
|
482
|
-
**How mining competition works:** The protocol enforces exactly ONE successful mine per block, network-wide. This is controlled by `lastMineBlockNumber
|
|
479
|
+
**How mining competition works:** The protocol enforces exactly ONE successful mine per block, network-wide. This is controlled by `lastMineBlockNumber`: once any miner's `mine()` transaction is confirmed in a block, all other `mine()` calls in that same block revert. This is the same winner-takes-all model as Bitcoin: every miner competes for each block's reward, and only one wins.
|
|
483
480
|
|
|
484
481
|
**One rig per wallet (CLI-enforced).** The CLI prevents minting more than one rig per wallet. Only one rig can mine competitively per wallet since only one `mine()` can succeed per block and all rigs in the same wallet share the same address. Extra rigs waste ETH on mint fees with no advantage.
|
|
485
482
|
|
|
486
483
|
### Scaling with Multiple Wallets
|
|
487
484
|
|
|
488
|
-
To increase your chances of winning each block, run separate wallets
|
|
485
|
+
To increase your chances of winning each block, run separate wallets, each with its own rig and its own miner process. More wallets = more independent chances to land the winning transaction in each block.
|
|
489
486
|
|
|
490
|
-
**The user only funds one wallet.** Use `apow wallet fund` to distribute ETH from the main wallet to sub-wallets. The default amount covers the current mint price + gas buffer
|
|
487
|
+
**The user only funds one wallet.** Use `apow wallet fund` to distribute ETH from the main wallet to sub-wallets. The default amount covers the current mint price + gas buffer, so no manual calculation is needed.
|
|
491
488
|
|
|
492
489
|
**Autonomous agent flow for multi-wallet mining:**
|
|
493
490
|
|
|
@@ -531,10 +528,12 @@ pm2 start ecosystem.config.cjs
|
|
|
531
528
|
pm2 logs
|
|
532
529
|
```
|
|
533
530
|
|
|
534
|
-
**Economics of multi-wallet mining:** Failed `mine()` calls still cost gas (~0.001 ETH). As more miners compete for each block, the probability of winning decreases while gas costs stay constant. This creates a natural economic equilibrium
|
|
531
|
+
**Economics of multi-wallet mining:** Failed `mine()` calls still cost gas (~0.001 ETH). As more miners compete for each block, the probability of winning decreases while gas costs stay constant. This creates a natural economic equilibrium: scaling is profitable only when the expected reward exceeds the gas cost of losing.
|
|
535
532
|
|
|
536
533
|
**RPC rate limits:** For 3+ concurrent miners, use a dedicated RPC endpoint (Alchemy, Infura, QuickNode) instead of the default `https://mainnet.base.org`.
|
|
537
534
|
|
|
535
|
+
**Want more hash power?** The nonce grinder scales linearly with CPU cores. Rent a high-core-count machine on [vast.ai](https://vast.ai/) to increase throughput. Not required, but effective for competitive mining.
|
|
536
|
+
|
|
538
537
|
### Local LLM Setup (Ollama)
|
|
539
538
|
|
|
540
539
|
```bash
|
|
@@ -554,30 +553,6 @@ Ollama runs on `http://127.0.0.1:11434` by default. The miner connects there aut
|
|
|
554
553
|
|
|
555
554
|
**Trade-off:** Free inference, but local models may have lower accuracy on the constrained SMHL challenges. The miner retries up to 3 times per challenge, but persistent failures will slow mining.
|
|
556
555
|
|
|
557
|
-
### Session Mining (Claude Code / Codex)
|
|
558
|
-
|
|
559
|
-
Mine using your existing Claude Code or Codex subscription — no API key required:
|
|
560
|
-
|
|
561
|
-
```bash
|
|
562
|
-
# In your .env
|
|
563
|
-
LLM_PROVIDER=claude-code
|
|
564
|
-
# No LLM_API_KEY needed — the miner shells out to your local CLI
|
|
565
|
-
```
|
|
566
|
-
|
|
567
|
-
Or with Codex:
|
|
568
|
-
```bash
|
|
569
|
-
LLM_PROVIDER=codex
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
**How it works:** Instead of calling an LLM API, the miner executes `claude -p` or `codex exec` locally to solve SMHL challenges. This uses whatever model your CLI session defaults to.
|
|
573
|
-
|
|
574
|
-
**Requirements:**
|
|
575
|
-
- `claude` or `codex` CLI must be installed and authenticated
|
|
576
|
-
- The CLI must be available in your PATH
|
|
577
|
-
- Your subscription must be active
|
|
578
|
-
|
|
579
|
-
**Warning:** Session-based providers (`claude-code`, `codex`) spawn a CLI subprocess for each SMHL challenge. The startup overhead frequently exceeds the 20-second mint challenge window, causing mints to fail with `Expired`. **For minting, always use an API-based provider** (openai, anthropic, gemini, deepseek, or qwen). Session providers may work for the mining loop (which has no time limit per challenge) but are unreliable and not recommended for autonomous operation.
|
|
580
|
-
|
|
581
556
|
### Custom RPC Endpoints
|
|
582
557
|
|
|
583
558
|
Set `RPC_URL` in `.env` to any Base-compatible JSON-RPC endpoint. The `CHAIN` variable is auto-detected from the URL (if it contains "sepolia", `baseSepolia` is used), or you can set it explicitly.
|
|
@@ -587,13 +562,13 @@ Set `RPC_URL` in `.env` to any Base-compatible JSON-RPC endpoint. The `CHAIN` va
|
|
|
587
562
|
Each Miner NFT supports an on-chain agent wallet via the ERC-8004 standard. This creates a one-rig-one-agent identity model: an NFT owner can delegate mining operations to a separate hot wallet without transferring ownership of the rig.
|
|
588
563
|
|
|
589
564
|
**Functions:**
|
|
590
|
-
- `getAgentWallet(tokenId)
|
|
591
|
-
- `setAgentWallet(tokenId, newWallet, deadline, signature)
|
|
592
|
-
- `unsetAgentWallet(tokenId)
|
|
565
|
+
- `getAgentWallet(tokenId)`: returns the registered agent wallet address
|
|
566
|
+
- `setAgentWallet(tokenId, newWallet, deadline, signature)`: sets a new agent wallet (requires EIP-712 signature from the new wallet)
|
|
567
|
+
- `unsetAgentWallet(tokenId)`: removes the agent wallet
|
|
593
568
|
|
|
594
|
-
**What survives NFT transfer:** rarity, hashpower, total mine count, total AGENT earned, and the on-chain pixel art
|
|
569
|
+
**What survives NFT transfer:** rarity, hashpower, total mine count, total AGENT earned, and the on-chain pixel art. All permanent metadata is baked into the token.
|
|
595
570
|
|
|
596
|
-
**What gets cleared on transfer:** ONLY the agent wallet binding. This is a security measure
|
|
571
|
+
**What gets cleared on transfer:** ONLY the agent wallet binding. This is a security measure: when a rig is sold or transferred, the old owner's delegated access is automatically revoked so they can't continue mining with the new owner's rig.
|
|
597
572
|
|
|
598
573
|
**Trading:** Miner NFTs are fully tradeable (standard ERC-721). They are NOT soulbound. You can buy, sell, and transfer them on OpenSea or any NFT marketplace. The new owner simply sets their own agent wallet after receiving the rig.
|
|
599
574
|
|
|
@@ -619,7 +594,7 @@ Use the corresponding testnet contract addresses.
|
|
|
619
594
|
| `LLM_API_KEY is required for openai.` | Missing API key for cloud provider | Set `LLM_API_KEY` (or provider-specific key like `OPENAI_API_KEY`) in `.env`, or switch to `ollama` |
|
|
620
595
|
| `Insufficient fee` | Not enough ETH sent with mint | Check `getMintPrice()` and ensure wallet has enough ETH |
|
|
621
596
|
| `Sold out` | All 10,000 Miner NFTs minted | No more rigs available; buy one on secondary market |
|
|
622
|
-
| `Expired` | SMHL challenge expired (>20s) |
|
|
597
|
+
| `Expired` | SMHL challenge expired (>20s) | Use a faster model (gpt-4o-mini, gemini-2.5-flash). Thinking models are too slow for the 20s mint window |
|
|
623
598
|
| `Invalid SMHL` | LLM produced an incorrect solution | Retry; if persistent, switch to a more capable model |
|
|
624
599
|
| `Not your miner` | Token ID not owned by your wallet | Verify `PRIVATE_KEY` matches the NFT owner; check token ID |
|
|
625
600
|
| `Supply exhausted` | All 18.9M mineable AGENT has been minted | Mining is complete; no more rewards available |
|
|
@@ -632,8 +607,6 @@ Use the corresponding testnet contract addresses.
|
|
|
632
607
|
| `SMHL solve failed after 3 attempts` | LLM cannot satisfy constraints | Switch to a more capable model (e.g., `gpt-4o` or `claude-sonnet-4-5-20250929`) |
|
|
633
608
|
| `Fee forward failed` | LPVault rejected the ETH transfer | LPVault may not be set; check contract deployment |
|
|
634
609
|
| `10 consecutive failures` | Repeated transient errors | Check RPC connectivity, wallet balance, and LLM availability |
|
|
635
|
-
| `Claude Code error: ...` | `claude` CLI failed or timed out | Verify `claude` is installed and in PATH; check subscription is active |
|
|
636
|
-
| `Codex error: ...` | `codex` CLI failed or timed out | Verify `codex` is installed and in PATH; check subscription is active |
|
|
637
610
|
| `Timed out waiting for next block (60s)` | RPC not responding or network stalled | Check RPC connectivity; try a different RPC endpoint |
|
|
638
611
|
|
|
639
612
|
---
|
|
@@ -642,13 +615,13 @@ Use the corresponding testnet contract addresses.
|
|
|
642
615
|
|
|
643
616
|
This section addresses the security model of apow-cli head-on. Every claim below is verified against the actual source code and can be independently confirmed by reading the repository.
|
|
644
617
|
|
|
645
|
-
### Private Key Generation
|
|
618
|
+
### Private Key Generation (Local Only)
|
|
646
619
|
|
|
647
|
-
Keys are generated via `viem/accounts` `generatePrivateKey()`, which uses Node.js `crypto.randomBytes(32)
|
|
620
|
+
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 saved to `wallet-<address>.txt` with file permissions `0o600` (owner-read-write only).
|
|
648
621
|
|
|
649
622
|
### Private Key Is NEVER Transmitted
|
|
650
623
|
|
|
651
|
-
Exhaustive audit confirms: the private key string is never included in any `fetch()` call, HTTP request body, URL parameter, or header anywhere in the codebase. viem's signing architecture means the key is used locally for ECDSA signatures
|
|
624
|
+
Exhaustive audit confirms: the private key string is never included in any `fetch()` call, HTTP request body, URL parameter, or header anywhere in the codebase. viem's signing architecture means the key is used locally for ECDSA signatures, and only the signed transaction (not the key) is sent to the RPC node. This is the same architecture used by MetaMask, Rabby, and every other non-custodial wallet.
|
|
652
625
|
|
|
653
626
|
### Zero Telemetry
|
|
654
627
|
|
|
@@ -660,15 +633,15 @@ The CLI contains no analytics, no error reporting, and no phone-home behavior of
|
|
|
660
633
|
|
|
661
634
|
The CLI makes only these network calls:
|
|
662
635
|
|
|
663
|
-
1. **Blockchain RPC** (to user-configured RPC URL, default: `mainnet.base.org`)
|
|
664
|
-
2. **LLM API** (to user-configured provider)
|
|
636
|
+
1. **Blockchain RPC** (to user-configured RPC URL, default: `mainnet.base.org`): standard `eth_call`, `eth_sendRawTransaction`, etc.
|
|
637
|
+
2. **LLM API** (to user-configured provider): sends only word-puzzle prompts for SMHL solving, never wallet data
|
|
665
638
|
3. **Bridge APIs** (only when using `apow fund --solana`):
|
|
666
|
-
- **CoinGecko** (`api.coingecko.com`)
|
|
667
|
-
- **deBridge DLN** (`dln.debridge.finance`)
|
|
668
|
-
- **Squid Router** (`v2.api.squidrouter.com`)
|
|
669
|
-
- **Solana RPC** (`api.mainnet-beta.solana.com` or custom)
|
|
639
|
+
- **CoinGecko** (`api.coingecko.com`): SOL/ETH price quotes
|
|
640
|
+
- **deBridge DLN** (`dln.debridge.finance`): bridge order creation and status (direct signing flow)
|
|
641
|
+
- **Squid Router** (`v2.api.squidrouter.com`): deposit address generation (deposit address flow)
|
|
642
|
+
- **Solana RPC** (`api.mainnet-beta.solana.com` or custom): balance checks and tx submission
|
|
670
643
|
|
|
671
|
-
No private keys are transmitted to bridge providers. deBridge returns a serialized Solana transaction that is signed locally. Squid generates a deposit address
|
|
644
|
+
No private keys are transmitted to bridge providers. deBridge returns a serialized Solana transaction that is signed locally. Squid generates a deposit address, and the user sends SOL themselves.
|
|
672
645
|
|
|
673
646
|
### LLM Calls Are Data-Isolated
|
|
674
647
|
|
|
@@ -678,13 +651,13 @@ The SMHL solver sends only generic word-generation prompts to the LLM (e.g., "Wr
|
|
|
678
651
|
|
|
679
652
|
- Full source code: [github.com/Agentoshi/apow-cli](https://github.com/Agentoshi/apow-cli)
|
|
680
653
|
- MIT licensed
|
|
681
|
-
- Every line is auditable
|
|
654
|
+
- Every line is auditable. There are no obfuscated modules, no binary blobs, no minified dependencies performing network calls
|
|
682
655
|
- Smart contracts are separately auditable: [github.com/Agentoshi/apow-core](https://github.com/Agentoshi/apow-core)
|
|
683
656
|
|
|
684
657
|
### npm Package Integrity
|
|
685
658
|
|
|
686
659
|
- Published as `apow-cli` on npm
|
|
687
|
-
- Package contents match the GitHub source
|
|
660
|
+
- Package contents match the GitHub source (verify with `npm pack --dry-run` or compare against the repo)
|
|
688
661
|
- No `postinstall` scripts that execute arbitrary code
|
|
689
662
|
- The `package.json` `scripts` section contains only standard build/dev commands
|
|
690
663
|
|
|
@@ -709,7 +682,7 @@ Every statement above can be independently verified:
|
|
|
709
682
|
# Clone the source
|
|
710
683
|
git clone https://github.com/Agentoshi/apow-cli && cd apow-cli
|
|
711
684
|
|
|
712
|
-
# Search for any outbound network calls
|
|
685
|
+
# Search for any outbound network calls (you'll find only RPC and LLM calls)
|
|
713
686
|
grep -r "fetch\|axios\|http\|request" src/
|
|
714
687
|
|
|
715
688
|
# Confirm private key is never in any network payload
|
|
@@ -751,6 +724,82 @@ cat package.json | grep -A5 "scripts" # no postinstall hook
|
|
|
751
724
|
- **Standard:** ERC-721 Enumerable + ERC-8004 (Agent Registry)
|
|
752
725
|
- **Max supply:** 10,000
|
|
753
726
|
|
|
727
|
+
|
|
728
|
+
## 14. Dashboard
|
|
729
|
+
|
|
730
|
+
The `apow dashboard` command group provides a real-time web UI for monitoring your entire mining fleet. Zero external dependencies — it serves vanilla HTML/JS directly from the CLI.
|
|
731
|
+
|
|
732
|
+
### Subcommands
|
|
733
|
+
|
|
734
|
+
| Command | Description |
|
|
735
|
+
|---------|-------------|
|
|
736
|
+
| `apow dashboard start` | Launch the dashboard web UI at `http://localhost:3847`. Auto-opens browser. Press Ctrl+C to stop. |
|
|
737
|
+
| `apow dashboard add <address>` | Add a wallet address to monitor. Validates 0x + 40 hex chars. |
|
|
738
|
+
| `apow dashboard remove <address>` | Remove a wallet address from monitoring. |
|
|
739
|
+
| `apow dashboard scan [dir]` | Auto-detect wallets from `wallet-0x*.txt` files in the given directory (default: CWD). Also scans `rig*/` subdirectories. |
|
|
740
|
+
| `apow dashboard wallets` | List all currently monitored wallet addresses. |
|
|
741
|
+
|
|
742
|
+
### How It Works
|
|
743
|
+
|
|
744
|
+
- **Wallet storage:** `~/.apow/wallets.json` — a plain JSON array of Ethereum addresses.
|
|
745
|
+
- **Fleet management:** `~/.apow/fleets.json` — optional, defines named groups of wallets from different sources.
|
|
746
|
+
- **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.
|
|
747
|
+
- **NFT art:** Renders on-chain SVG art for each Mining Rig with rarity-based color coding.
|
|
748
|
+
- **Auto-seed:** On first run, seeds `wallets.json` with the address from your `.env` if configured.
|
|
749
|
+
- **Auto-detect:** `dashboard start` automatically scans CWD for `wallet-0x*.txt` files before launching.
|
|
750
|
+
|
|
751
|
+
### Fleet Configuration (`~/.apow/fleets.json`)
|
|
752
|
+
|
|
753
|
+
For managing wallets across multiple machines or directories, create `~/.apow/fleets.json`:
|
|
754
|
+
|
|
755
|
+
```json
|
|
756
|
+
[
|
|
757
|
+
{ "name": "Local", "type": "array", "path": "/home/user/.apow/wallets.json" },
|
|
758
|
+
{ "name": "Vast.ai Rigs", "type": "rigdirs", "path": "/mnt/mining/rigs" },
|
|
759
|
+
{ "name": "Pool Wallets", "type": "walletfiles", "path": "/mnt/mining/wallets" },
|
|
760
|
+
{ "name": "Solkek Fleet", "type": "solkek", "path": "/home/user/solkek-config.json" }
|
|
761
|
+
]
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
**Fleet types:**
|
|
765
|
+
|
|
766
|
+
| Type | Source Format | Description |
|
|
767
|
+
|------|--------------|-------------|
|
|
768
|
+
| `array` | JSON array of addresses | Simple list: `["0xABC...", "0xDEF..."]` |
|
|
769
|
+
| `solkek` | JSON with `master.address` + `miners[].address` | Solkek fleet manager format |
|
|
770
|
+
| `rigdirs` | Directory containing `rig*/wallet-0x*.txt` | Scan rig subdirectories for wallet files |
|
|
771
|
+
| `walletfiles` | Directory containing `wallet-0x*.txt` | Scan flat directory for wallet files |
|
|
772
|
+
|
|
773
|
+
If `fleets.json` does not exist, the dashboard falls back to `wallets.json` as a single "Main" fleet.
|
|
774
|
+
|
|
775
|
+
### Example Workflow
|
|
776
|
+
|
|
777
|
+
```bash
|
|
778
|
+
# 1. Scan a directory with wallet files to populate wallets.json
|
|
779
|
+
npx apow-cli dashboard scan /path/to/mining/dir
|
|
780
|
+
|
|
781
|
+
# 2. Manually add a wallet not found by scan
|
|
782
|
+
npx apow-cli dashboard add 0x1234567890abcdef1234567890abcdef12345678
|
|
783
|
+
|
|
784
|
+
# 3. Verify your wallet list
|
|
785
|
+
npx apow-cli dashboard wallets
|
|
786
|
+
|
|
787
|
+
# 4. Launch the dashboard
|
|
788
|
+
npx apow-cli dashboard start
|
|
789
|
+
# → Opens http://localhost:3847 in your browser
|
|
790
|
+
# → Shows real-time balances, rig stats, earnings, and NFT art
|
|
791
|
+
# → Press Ctrl+C to stop
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
### Troubleshooting
|
|
795
|
+
|
|
796
|
+
| Issue | Cause | Fix |
|
|
797
|
+
|-------|-------|-----|
|
|
798
|
+
| "No wallets configured" | Empty `wallets.json` | Run `apow dashboard add <addr>` or `apow dashboard scan .` |
|
|
799
|
+
| Dashboard shows 0 balances | RPC rate limiting | Set a dedicated `RPC_URL` in `.env` (Alchemy recommended) |
|
|
800
|
+
| Browser doesn't open | Headless/SSH environment | Manually open `http://localhost:3847` in a browser |
|
|
801
|
+
| Stale data | 25s cache TTL | Wait for next refresh cycle or restart the dashboard |
|
|
802
|
+
|
|
754
803
|
---
|
|
755
804
|
|
|
756
805
|
**Source:** [github.com/Agentoshi/apow-cli](https://github.com/Agentoshi/apow-cli) | **Protocol:** [github.com/Agentoshi/apow-core](https://github.com/Agentoshi/apow-core)
|