apow-cli 0.11.19 → 0.12.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 +23 -5
- package/README.md +115 -67
- package/dist/brand-intro.js +160 -0
- package/dist/bridge/solana.js +27 -45
- package/dist/config.js +90 -5
- package/dist/dashboard-html.js +36 -43
- package/dist/dashboard.js +22 -151
- package/dist/errors.js +22 -3
- package/dist/grinder-http.js +3 -5
- package/dist/grinder-native.js +6 -5
- package/dist/index.js +540 -343
- package/dist/llm-setup.js +42 -0
- package/dist/lp-gate.js +28 -0
- package/dist/miner.js +24 -10
- package/dist/mint.js +6 -7
- package/dist/policy/audit-log.js +57 -0
- package/dist/policy/context.js +11 -0
- package/dist/policy/decode.js +84 -0
- package/dist/policy/paths.js +41 -0
- package/dist/policy/policy.js +224 -0
- package/dist/policy/spend-ledger.js +43 -0
- package/dist/preflight.js +138 -50
- package/dist/secure-env.js +65 -0
- package/dist/signer/guarded-account.js +78 -0
- package/dist/signer/local-keystore.js +40 -0
- package/dist/signer/session.js +11 -0
- package/dist/signer/types.js +2 -0
- package/dist/smhl.js +83 -10
- package/dist/stats.js +13 -1
- package/dist/sweep.js +181 -0
- package/dist/ui.js +140 -16
- package/dist/wallet-store.js +127 -31
- package/dist/wallet.js +18 -22
- package/dist/x402.js +4 -4
- package/package.json +8 -5
- package/skill.md +57 -837
package/skill.md
CHANGED
|
@@ -1,872 +1,92 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: apow-
|
|
3
|
-
description:
|
|
4
|
-
allowed-tools: Bash(npx
|
|
5
|
-
argument-hint: [setup|mint|mine|stats]
|
|
2
|
+
name: apow-mining
|
|
3
|
+
description: This skill teaches your agent how to mine $AGENT coin via the apow-cli.
|
|
4
|
+
allowed-tools: Bash(npx --yes apow-cli@0.12.0 start --easy)
|
|
6
5
|
metadata:
|
|
7
6
|
openclaw:
|
|
8
7
|
requires:
|
|
9
8
|
anyBins:
|
|
10
9
|
- npx
|
|
11
|
-
- node
|
|
12
10
|
---
|
|
13
11
|
|
|
14
|
-
# APoW Mining
|
|
12
|
+
# APoW Mining
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
Use this skill only to set up a fresh APoW mining wallet and run the official APoW miner. It is deliberately limited to that workflow.
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
and mine autonomously. The only step that requires your user is funding the wallet with ETH + USDC
|
|
20
|
-
on Base. Everything else you handle yourself.
|
|
16
|
+
APoW mining uses real assets on Base. Use a fresh, low-balance hot wallet dedicated to APoW. The CLI stores generated wallets as password-protected JSON keystores and applies a local signing policy with spend caps.
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
> - **Easy Mode** (recommended / beginner path): run `npx apow-cli start` or `npx apow-cli setup`, choose `Easy Mode`, let the CLI generate a wallet and private key if needed, then hand the user the funding address. No API keys or pre-existing `PRIVATE_KEY` are required up front.
|
|
24
|
-
> - **Advanced Mode:** bring your own wallet, RPC, LLM, and grinder settings via `.env` or the interactive setup flow.
|
|
18
|
+
## Required approval
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## Quick Start (TL;DR)
|
|
29
|
-
|
|
30
|
-
**Via npm (recommended):**
|
|
31
|
-
```bash
|
|
32
|
-
npx apow-cli start # zero-config happy path: setup -> funding checks -> mint -> mine
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
**Via source:**
|
|
36
|
-
```bash
|
|
37
|
-
git clone https://github.com/Agentoshi/apow-cli.git
|
|
38
|
-
cd apow-cli && npm install
|
|
39
|
-
npx tsx src/index.ts start
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Recommended Agent Flow — Easy Mode
|
|
43
|
-
|
|
44
|
-
For OpenClaw and other interactive agents, start here. Do not ask the user for a `PRIVATE_KEY`
|
|
45
|
-
before running Easy Mode.
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npx apow-cli start
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
1. Choose `Easy Mode`
|
|
52
|
-
2. If no wallet exists yet, let the CLI generate it and show the new Base address
|
|
53
|
-
3. Hand the funding address to the user and explain they need ETH for gas + minting and USDC for the x402 stack
|
|
54
|
-
4. If they want the built-in bridge, use `npx apow-cli fund`; otherwise let them fund the wallet manually
|
|
55
|
-
5. After funding arrives, rerun `npx apow-cli start` to continue through minting and mining
|
|
56
|
-
|
|
57
|
-
Easy Mode writes the x402-backed config for the user. The manual requirement is funding the newly
|
|
58
|
-
generated wallet, not bringing a private key or API keys ahead of time.
|
|
59
|
-
|
|
60
|
-
### Headless Fallback — Reproduce Easy Mode Defaults Manually
|
|
61
|
-
|
|
62
|
-
Only use this if the environment cannot drive the interactive CLI prompts. This reproduces the
|
|
63
|
-
same zero-credential x402 stack that Easy Mode would write for you.
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
# 1. Generate a wallet
|
|
67
|
-
npx apow-cli wallet new
|
|
68
|
-
# Captures address + private key from output (and can save a plaintext import helper plus encrypted keystore)
|
|
69
|
-
|
|
70
|
-
# 2. Write .env directly — headless fallback for Easy Mode
|
|
71
|
-
# Contract addresses are built-in defaults — no need to specify them
|
|
72
|
-
cat > .env << 'EOF'
|
|
73
|
-
PRIVATE_KEY=0x<from step 1>
|
|
74
|
-
USE_X402=true
|
|
75
|
-
USE_X402_GRIND=true
|
|
76
|
-
LLM_PROVIDER=clawrouter
|
|
77
|
-
LLM_MODEL=blockrun/eco
|
|
78
|
-
ALLOW_LOCAL_FALLBACK_WITH_X402=false
|
|
79
|
-
EOF
|
|
80
|
-
|
|
81
|
-
# 3. Start mining — the CLI handles funding checks, minting, and mining
|
|
82
|
-
npx apow-cli start
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
In headless shells like OpenClaw, treat funding as a user handoff. Do not run `apow fund`
|
|
86
|
-
without explicit `--chain` and `--token` flags. If `npx apow-cli start` reports that funding
|
|
87
|
-
is needed, show the wallet address, explain the funding options, wait for the user to fund the
|
|
88
|
-
wallet or pick a route, then rerun `npx apow-cli start`.
|
|
89
|
-
|
|
90
|
-
### Advanced Mode / Manual Flow
|
|
91
|
-
|
|
92
|
-
If you prefer to use your own LLM API key instead of ClawRouter:
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
cat > .env << 'EOF'
|
|
96
|
-
PRIVATE_KEY=0x<your key>
|
|
97
|
-
RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY # Free from alchemy.com
|
|
98
|
-
LLM_PROVIDER=openai
|
|
99
|
-
LLM_MODEL=gpt-4o-mini
|
|
100
|
-
LLM_API_KEY=<your key>
|
|
101
|
-
MINING_AGENT_ADDRESS=0xB7caD3ca5F2BD8aEC2Eb67d6E8D448099B3bC03D
|
|
102
|
-
AGENT_COIN_ADDRESS=0x12577CF0D8a07363224D6909c54C056A183e13b3
|
|
103
|
-
EOF
|
|
104
|
-
|
|
105
|
-
npx apow-cli mint
|
|
106
|
-
npx apow-cli mine
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## 1. What is APoW?
|
|
112
|
-
|
|
113
|
-
Agent Proof-of-Work (APoW) is a mining protocol on Base L2 where AI agents prove their identity once by minting an ERC-721 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.
|
|
114
|
-
|
|
115
|
-
### SMHL Challenge Format
|
|
116
|
-
|
|
117
|
-
SMHL ("Show Me Human Language") serves two different roles in APoW:
|
|
118
|
-
|
|
119
|
-
**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'."
|
|
120
|
-
|
|
121
|
-
**SMHL for Mining (algorithmic):** During mining, SMHL solutions are generated algorithmically in microseconds, with no LLM needed. Your AI was already proven when you minted your Mining Rig. Mining is a hash power competition, not a language puzzle.
|
|
122
|
-
|
|
123
|
-
On-chain verification checks (both minting and mining):
|
|
124
|
-
1. **Length** (in bytes): within ±5 of the target
|
|
125
|
-
2. **Word count**: within ±2 of the target
|
|
126
|
-
3. **Character presence**: the specified letter appears at least once
|
|
127
|
-
|
|
128
|
-
The miner client validates locally before submitting.
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## 2. Prerequisites
|
|
133
|
-
|
|
134
|
-
| Requirement | Details |
|
|
135
|
-
|---|---|
|
|
136
|
-
| **Node.js** | v20 or higher |
|
|
137
|
-
| **Base wallet** | Easy Mode: none up front, the CLI can create one for you. Advanced Mode: existing private key with ETH on Base for gas + mint fee. |
|
|
138
|
-
| **USDC on Base** | 2.00 USDC minimum starting balance in the mining wallet for x402 RPC / ClawRouter / remote grind; more gives headroom |
|
|
139
|
-
| **LLM access** | Easy Mode: none up front, uses ClawRouter via x402. Advanced Mode: API key (OpenAI, Gemini, etc.) or local Ollama for minting. |
|
|
140
|
-
| **git** | Only if installing from source (not needed for npm) |
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## 3. Step 1: Create a Mining Wallet
|
|
145
|
-
|
|
146
|
-
In Easy Mode, the normal path is to let `apow start` or `apow setup` create the mining wallet for
|
|
147
|
-
you. You do not need to arrive with a `PRIVATE_KEY`.
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
|
-
npx apow-cli start
|
|
151
|
-
# Choose "Easy Mode"
|
|
152
|
-
# Select "No" when asked if you have a wallet → generates one automatically
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
You can also generate one directly (useful for agents, headless shells, or Advanced Mode):
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
npx apow-cli wallet new
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
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. If you are using a manual or headless flow, put that key in your `.env` as `PRIVATE_KEY`.
|
|
162
|
-
|
|
163
|
-
**Exporting an existing wallet:** If you've already set up a wallet and need to retrieve the key:
|
|
164
|
-
|
|
165
|
-
```bash
|
|
166
|
-
npx apow-cli wallet export
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
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.
|
|
170
|
-
|
|
171
|
-
**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.
|
|
172
|
-
|
|
173
|
-
---
|
|
174
|
-
|
|
175
|
-
## 4. Funding Your Wallet
|
|
176
|
-
|
|
177
|
-
Your mining wallet needs ETH on Base for gas and the mint fee.
|
|
178
|
-
**Minimum:** 0.005 ETH (~$15) covers minting + several mining cycles.
|
|
179
|
-
|
|
180
|
-
### Built-in Bridge: `apow fund` (Recommended)
|
|
181
|
-
|
|
182
|
-
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):
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
npx apow-cli fund # Interactive: choose chain + token
|
|
186
|
-
npx apow-cli fund --chain solana --token sol # Bridge SOL → ETH+USDC on Base
|
|
187
|
-
npx apow-cli fund --chain solana --token usdc # Bridge Solana USDC → Base
|
|
188
|
-
npx apow-cli fund --chain ethereum # Bridge ETH from Ethereum mainnet → Base
|
|
189
|
-
npx apow-cli fund --chain base # Show address, wait for deposit
|
|
190
|
-
npx apow-cli fund --chain base --no-swap # Skip auto-split
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
**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.
|
|
194
|
-
|
|
195
|
-
**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.
|
|
196
|
-
|
|
197
|
-
### Manual Funding Options
|
|
198
|
-
|
|
199
|
-
If you prefer not to use the built-in bridge:
|
|
200
|
-
|
|
201
|
-
#### From Solana (Phantom Wallet)
|
|
202
|
-
Phantom natively supports Base. Tell your user:
|
|
203
|
-
1. Open Phantom → tap the **Swap** icon
|
|
204
|
-
2. Set **From:** SOL (Solana) → **To:** ETH (Base)
|
|
205
|
-
3. Enter amount (≥0.005 ETH worth of SOL)
|
|
206
|
-
4. Tap **Review** → **Swap**
|
|
207
|
-
5. Once ETH arrives on Base, tap **Send** → paste the mining wallet address
|
|
208
|
-
6. Confirm the transfer
|
|
209
|
-
|
|
210
|
-
#### From an Exchange (Coinbase, Binance, etc.)
|
|
211
|
-
1. Buy ETH on Base (Coinbase supports Base withdrawals natively)
|
|
212
|
-
2. Withdraw to the mining wallet address
|
|
213
|
-
3. Select **Base** as the network. Do NOT send on Ethereum mainnet
|
|
214
|
-
|
|
215
|
-
#### From Ethereum Mainnet
|
|
216
|
-
Bridge ETH to Base via [bridge.base.org](https://bridge.base.org):
|
|
217
|
-
1. Connect source wallet → enter mining wallet address as recipient
|
|
218
|
-
2. Bridge ≥0.005 ETH → arrives on Base in ~10 minutes
|
|
219
|
-
|
|
220
|
-
#### From Another Base Wallet
|
|
221
|
-
Send ETH directly to the mining wallet address on Base.
|
|
222
|
-
|
|
223
|
-
### Verifying Funds
|
|
224
|
-
After funding, verify the balance:
|
|
225
|
-
```bash
|
|
226
|
-
npx apow-cli stats
|
|
227
|
-
# Shows wallet balance; must be ≥0.005 ETH to proceed
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
---
|
|
231
|
-
|
|
232
|
-
## 5. Step 2: Install Miner Client
|
|
233
|
-
|
|
234
|
-
**Via npm (no install needed):**
|
|
235
|
-
```bash
|
|
236
|
-
npx apow-cli start
|
|
237
|
-
# or: npx apow-cli setup
|
|
238
|
-
```
|
|
239
|
-
All `apow` commands work via `npx` with no global install required.
|
|
240
|
-
|
|
241
|
-
**Via source (for developers):**
|
|
242
|
-
```bash
|
|
243
|
-
git clone https://github.com/Agentoshi/apow-cli.git
|
|
244
|
-
cd apow-cli && npm install
|
|
245
|
-
# Use `npx tsx src/index.ts` instead of `npx apow-cli` for all commands
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
## 6. Step 3: Configure Environment (Advanced Mode / Manual Setup)
|
|
251
|
-
|
|
252
|
-
Skip this section for Easy Mode. The CLI writes the equivalent config for you during `apow start`
|
|
253
|
-
or `apow setup`. Use a manual `.env` only when you want full control or need a headless fallback.
|
|
254
|
-
|
|
255
|
-
Run `npx apow-cli setup` for interactive configuration, or create a `.env` file manually in your working directory:
|
|
256
|
-
|
|
257
|
-
```bash
|
|
258
|
-
# === Required ===
|
|
259
|
-
|
|
260
|
-
# Your wallet private key (0x-prefixed, 64 hex chars)
|
|
261
|
-
# Required for manual / headless minting and mining commands
|
|
262
|
-
PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE
|
|
263
|
-
|
|
264
|
-
# Built-in Base mainnet defaults. Only override if you want a different deployment.
|
|
265
|
-
MINING_AGENT_ADDRESS=0xB7caD3ca5F2BD8aEC2Eb67d6E8D448099B3bC03D
|
|
266
|
-
AGENT_COIN_ADDRESS=0x12577CF0D8a07363224D6909c54C056A183e13b3
|
|
267
|
-
|
|
268
|
-
# === LLM Configuration (required for minting only; mining uses optimized solving) ===
|
|
269
|
-
|
|
270
|
-
# Provider: "clawrouter" (recommended) | "openai" | "gemini" | "deepseek" | "qwen" | "anthropic" | "ollama" | "claude-code" | "codex"
|
|
271
|
-
# clawrouter: zero credentials, pays with USDC from your wallet via x402
|
|
272
|
-
LLM_PROVIDER=clawrouter
|
|
273
|
-
|
|
274
|
-
# API key (not required if LLM_PROVIDER=clawrouter, ollama, claude-code, or codex)
|
|
275
|
-
# LLM_API_KEY=sk-your-api-key
|
|
276
|
-
|
|
277
|
-
# Model name (provider-specific)
|
|
278
|
-
LLM_MODEL=blockrun/eco
|
|
279
|
-
|
|
280
|
-
# === Network ===
|
|
281
|
-
|
|
282
|
-
# Base RPC endpoint (optional if USE_X402=true). Get a free URL from alchemy.com (no credit card).
|
|
283
|
-
# Or set USE_X402=true instead for auto-pay via QuickNode (2.00 USDC minimum starting balance; add more for headroom).
|
|
284
|
-
RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY
|
|
285
|
-
|
|
286
|
-
# Chain: "base" | "baseSepolia" (auto-detected from RPC_URL if omitted)
|
|
287
|
-
CHAIN=base
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
### Environment Variable Reference
|
|
291
|
-
|
|
292
|
-
| Variable | Required | Default | Description |
|
|
293
|
-
|---|---|---|---|
|
|
294
|
-
| `PRIVATE_KEY` | Manual / headless only | - | Wallet private key (0x + 64 hex chars). Easy Mode generates this for you if no wallet exists yet. |
|
|
295
|
-
| `KEYSTORE_PASSWORD` | No | unset | If set, `wallet new`/`wallet export` also create an encrypted JSON keystore backup under `~/.apow/keystores/` |
|
|
296
|
-
| `MINING_AGENT_ADDRESS` | No | built-in Base mainnet address | MiningAgent contract address. Override only for another deployment or network. |
|
|
297
|
-
| `AGENT_COIN_ADDRESS` | No | built-in Base mainnet address | AgentCoin contract address. Override only for another deployment or network. |
|
|
298
|
-
| `LLM_PROVIDER` | No | `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. |
|
|
299
|
-
| `LLM_API_KEY` | Only for cloud providers that require one | - | API key for minting. Not needed for `clawrouter`, `ollama`, `claude-code`, `codex`, or mining. Falls back to `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GEMINI_API_KEY`, `DEEPSEEK_API_KEY`, `DASHSCOPE_API_KEY`. |
|
|
300
|
-
| `LLM_MODEL` | No | per-provider default (e.g. `blockrun/eco`, `gpt-4o-mini`) | Model identifier passed to the provider (minting only). Auto-detected from provider if omitted. |
|
|
301
|
-
| `CLAWROUTER_PORT` | No | `8402` | Port for ClawRouter local proxy (only if default is in use) |
|
|
302
|
-
| `MINER_THREADS` | No | All CPU cores | Threads for JS nonce grinding (fallback if no native GPU/CPU grinder detected) |
|
|
303
|
-
| `STALE_CHECK_INTERVAL` | No | `5` | Seconds between stale-challenge checks while grinding. Applies across local/native and x402 grinders; lower values restart dead work faster but add more RPC reads. |
|
|
304
|
-
| `RPC_URL` | No* | — | Base JSON-RPC endpoint. Get a free URL from Alchemy or QuickNode. *Not needed if `USE_X402=true`. |
|
|
305
|
-
| `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`. |
|
|
306
|
-
| `CHAIN` | No | `base` | Network selector; auto-detects `baseSepolia` if RPC URL contains "sepolia" |
|
|
307
|
-
| `SOLANA_RPC_URL` | No | `https://api.mainnet-beta.solana.com` | Solana RPC endpoint (only for `apow fund --chain solana`) |
|
|
308
|
-
| `ETHEREUM_RPC_URL` | No | `https://cloudflare-eth.com` | Ethereum mainnet RPC (only for `apow fund --chain ethereum`) |
|
|
309
|
-
| `OLLAMA_URL` | No | `http://127.0.0.1:11434` | Ollama server URL (only if `LLM_PROVIDER=ollama`) |
|
|
310
|
-
| `GRINDER_MODE` | No | `auto` | Grinder mode: `auto` (detect native binaries) or `js` (force JS worker_threads) |
|
|
311
|
-
| `GPU_GRINDER_PATH` | No | auto-detected | Explicit path to Metal GPU grinder binary |
|
|
312
|
-
| `CUDA_GRINDER_PATH` | No | auto-detected | Explicit path to local CUDA grinder binary |
|
|
313
|
-
| `CPU_GRINDER_PATH` | No | auto-detected | Explicit path to CPU-C grinder binary |
|
|
314
|
-
| `CPU_THREADS` | No | All CPU cores | Thread count for CPU-C grinder |
|
|
315
|
-
| `USE_X402_GRIND` | No | same as `USE_X402` | Enable remote GPU grinding via x402 (dynamic pricing, ~$0.006/grind). Set `false` to disable even when `USE_X402=true`. |
|
|
316
|
-
| `GRIND_URL` | No | `https://grind.apow.io/grind` | Custom GrindProxy endpoint URL (for self-hosted grinding) |
|
|
317
|
-
| `VAST_IP` | No | - | Remote VAST.ai GPU host IP (for remote CUDA mining) |
|
|
318
|
-
| `VAST_PORT` | No | - | Remote VAST.ai GPU SSH port |
|
|
319
|
-
| `REMOTE_GRINDER` | No | `/root/grinder-cuda` | Path to CUDA binary on remote host |
|
|
320
|
-
| `SQUID_INTEGRATOR_ID` | No | - | Squid Router integrator ID for deposit address flow (free at [squidrouter.com](https://app.squidrouter.com/)) |
|
|
321
|
-
|
|
322
|
-
### LLM Provider Recommendations (for Minting)
|
|
323
|
-
|
|
324
|
-
> 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. Use a fast, non-thinking model to stay within the 20-second challenge window.
|
|
325
|
-
|
|
326
|
-
| Provider | Model | Cost per call | Notes |
|
|
327
|
-
|---|---|---|---|
|
|
328
|
-
| ClawRouter | `blockrun/eco` | ~$0.006 | **Recommended.** Zero credentials, pays with USDC via x402 |
|
|
329
|
-
| OpenAI | `gpt-4o-mini` | ~$0.001 | Cheapest API key option, fast, reliable |
|
|
330
|
-
| Gemini | `gemini-2.5-flash` | ~$0.001 | Fast, good accuracy |
|
|
331
|
-
| DeepSeek | `deepseek-chat` | ~$0.001 | Fast, accessible in China |
|
|
332
|
-
| Qwen | `qwen-plus` | ~$0.002 | Alibaba Cloud, accessible in China |
|
|
333
|
-
| Anthropic | `claude-sonnet-4-5-20250929` | ~$0.005 | Works but slower and more expensive |
|
|
334
|
-
| Ollama | `llama3.1` | Free (local) | Requires local GPU; variable accuracy |
|
|
335
|
-
|
|
336
|
-
### RPC Recommendations
|
|
337
|
-
|
|
338
|
-
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).
|
|
339
|
-
|
|
340
|
-
#### Option 1: Alchemy (Recommended)
|
|
341
|
-
|
|
342
|
-
1. Go to [alchemy.com](https://www.alchemy.com/) and sign up (free, no credit card)
|
|
343
|
-
2. Click **Create new app** → Name: `apow-miner` → Chain: **Base** → Network: **Base Mainnet**
|
|
344
|
-
3. On the app dashboard, copy the **HTTPS** URL. It looks like:
|
|
345
|
-
```
|
|
346
|
-
https://base-mainnet.g.alchemy.com/v2/YOUR_API_KEY
|
|
347
|
-
```
|
|
348
|
-
4. Set in your `.env`:
|
|
349
|
-
```
|
|
350
|
-
RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_API_KEY
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
**Free tier:** 300M compute units/month (~millions of RPC calls). More than enough for mining.
|
|
354
|
-
|
|
355
|
-
#### Option 2: QuickNode
|
|
356
|
-
|
|
357
|
-
1. Go to [quicknode.com](https://www.quicknode.com/) and sign up (free, no credit card)
|
|
358
|
-
2. Click **Create Endpoint** → Chain: **Base** → Network: **Mainnet**
|
|
359
|
-
3. Copy the **HTTP Provider** URL. It looks like:
|
|
360
|
-
```
|
|
361
|
-
https://something-something.base-mainnet.quiknode.pro/YOUR_TOKEN/
|
|
362
|
-
```
|
|
363
|
-
4. Set in your `.env`:
|
|
364
|
-
```
|
|
365
|
-
RPC_URL=https://something-something.base-mainnet.quiknode.pro/YOUR_TOKEN/
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
**Free tier:** 10M API credits/month. Sufficient for a few miners.
|
|
369
|
-
|
|
370
|
-
#### Option 3: Other Free RPCs
|
|
371
|
-
|
|
372
|
-
| Provider | Free Tier | URL Pattern |
|
|
373
|
-
|---|---|---|
|
|
374
|
-
| [Infura](https://infura.io/) | 100K req/day | `https://base-mainnet.infura.io/v3/KEY` |
|
|
375
|
-
| [Ankr](https://www.ankr.com/) | 30 req/s | `https://rpc.ankr.com/base` (no key needed) |
|
|
376
|
-
| [Blast](https://blastapi.io/) | 40 req/s | `https://base-mainnet.blastapi.io/KEY` |
|
|
377
|
-
|
|
378
|
-
#### Troubleshooting RPC Issues
|
|
379
|
-
|
|
380
|
-
| Symptom | Cause | Fix |
|
|
381
|
-
|---|---|---|
|
|
382
|
-
| `429 Too Many Requests` | Public RPC rate limit | Switch to a dedicated RPC (Alchemy/QuickNode) |
|
|
383
|
-
| `Timed out waiting for next block (60s)` | RPC not responding | Check endpoint URL; try a different provider |
|
|
384
|
-
| `fetch failed` / `ECONNREFUSED` | RPC URL is wrong or down | Verify URL; test with `curl YOUR_RPC_URL -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'` |
|
|
385
|
-
| Stale data / missed mines | RPC caching or slow sync | Alchemy and QuickNode are fastest; avoid free community RPCs |
|
|
386
|
-
|
|
387
|
-
---
|
|
388
|
-
|
|
389
|
-
## 7. Step 4: Mint a Mining Rig
|
|
390
|
-
|
|
391
|
-
**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).
|
|
392
|
-
|
|
393
|
-
```bash
|
|
394
|
-
npx apow-cli mint
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
**What happens:**
|
|
398
|
-
1. The client calls `getChallenge(yourAddress)` on the MiningAgent contract, which generates a random SMHL challenge and stores the seed on-chain. This is a write transaction (costs gas).
|
|
399
|
-
2. The client derives the challenge parameters from the stored seed and sends them to your LLM.
|
|
400
|
-
3. The LLM generates a sentence matching the constraints (approximate length, approximate word count, must contain a specific letter).
|
|
401
|
-
4. The client calls `mint(solution)` with the mint fee attached. The contract verifies the SMHL solution on-chain.
|
|
402
|
-
5. On success, an ERC-721 Miner NFT is minted to your wallet with a randomly determined rarity and hashpower.
|
|
403
|
-
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).
|
|
404
|
-
|
|
405
|
-
**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).
|
|
20
|
+
Before running the miner, show the user this scope and wait for an explicit approval:
|
|
406
21
|
|
|
407
|
-
|
|
22
|
+
> Approve APoW to create or use one fresh encrypted low-balance wallet; spend up to the local policy caps for one rig mint and x402 RPC, SMHL, and grinding services; submit Base mining transactions continuously until stopped; and sweep mined AGENT only if a payout address and automatic sweep were already configured?
|
|
408
23
|
|
|
409
|
-
|
|
410
|
-
- Decreases by 5% every 100 mints
|
|
411
|
-
- Floors at 0.0002 ETH
|
|
412
|
-
- Formula: `price = max(0.002 * 0.95^(totalMinted / 100), 0.0002)` ETH
|
|
24
|
+
Do not infer approval from funding, installation, prior mining, or a general request to inspect the project. Run the command only after the user approves the scope above.
|
|
413
25
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
| Tier | Name | Hashpower | Reward Multiplier | Probability |
|
|
417
|
-
|---|---|---|---|---|
|
|
418
|
-
| 0 | Common | 100 | 1.00x | 60% |
|
|
419
|
-
| 1 | Uncommon | 150 | 1.50x | 25% |
|
|
420
|
-
| 2 | Rare | 200 | 2.00x | 10% |
|
|
421
|
-
| 3 | Epic | 300 | 3.00x | 4% |
|
|
422
|
-
| 4 | Mythic | 500 | 5.00x | 1% |
|
|
423
|
-
|
|
424
|
-
**Max supply:** 10,000 Miner NFTs.
|
|
425
|
-
|
|
426
|
-
---
|
|
427
|
-
|
|
428
|
-
## 8. Step 5: Start Mining
|
|
429
|
-
|
|
430
|
-
```bash
|
|
431
|
-
npx apow-cli mine # auto-detects your best rig
|
|
432
|
-
npx apow-cli mine <tokenId> # or specify a rig by token ID
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
### What Each Mining Cycle Does
|
|
436
|
-
|
|
437
|
-
1. **Ownership check:** verifies your wallet owns the specified token.
|
|
438
|
-
2. **Supply check:** confirms mineable supply is not exhausted.
|
|
439
|
-
3. **Fetch challenge:** reads `getMiningChallenge()` from the AgentCoin contract, which returns:
|
|
440
|
-
- `challengeNumber` (bytes32): the current PoW challenge hash
|
|
441
|
-
- `miningTarget` (uint256): the difficulty target
|
|
442
|
-
- `smhl`: the SMHL format challenge
|
|
443
|
-
4. **Solve SMHL:** generates a valid SMHL solution algorithmically (sub-millisecond, no LLM needed).
|
|
444
|
-
5. **Grind nonce:** brute-force search for a `nonce` where `keccak256(challengeNumber, minerAddress, nonce) < miningTarget`. Works on any CPU out of the box. Add a GPU for 100x+ faster grinding.
|
|
445
|
-
The CLI re-checks the challenge every 5 seconds by default while grinding and aborts stale work across local/native and x402 nonce sources.
|
|
446
|
-
6. **Submit proof:** calls `mine(nonce, smhlSolution, tokenId)` on AgentCoin. The contract verifies both the hash and SMHL solution on-chain.
|
|
447
|
-
7. **Collect reward:** AGENT tokens are minted directly to your wallet.
|
|
448
|
-
8. **Wait for next block:** the protocol enforces one mine per block network-wide. The client waits for block advancement before the next cycle.
|
|
449
|
-
|
|
450
|
-
### Reward Economics
|
|
451
|
-
|
|
452
|
-
**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).
|
|
453
|
-
|
|
454
|
-
| Parameter | Value |
|
|
455
|
-
|---|---|
|
|
456
|
-
| Base reward | 3 AGENT |
|
|
457
|
-
| Hashpower scaling | `reward = baseReward * hashpower / 100` |
|
|
458
|
-
| Era interval | Every 500,000 total mines |
|
|
459
|
-
| Era decay | 10% reduction per era (`reward * 90 / 100`) |
|
|
460
|
-
| Max mineable supply | 18,900,000 AGENT (21M total - 2.1M LP reserve) |
|
|
461
|
-
| Difficulty adjustment | Every 64 mines, targeting 5 blocks between mines |
|
|
462
|
-
|
|
463
|
-
**Example rewards (Common miner, 100 hashpower = 1.00x):**
|
|
464
|
-
|
|
465
|
-
| Era | Total Network Mines | Reward per Mine |
|
|
466
|
-
|---|---|---|
|
|
467
|
-
| 0 | 0 to 499,999 | 3.00 AGENT |
|
|
468
|
-
| 1 | 500,000 to 999,999 | 2.70 AGENT |
|
|
469
|
-
| 2 | 1,000,000 to 1,499,999 | 2.43 AGENT |
|
|
470
|
-
| 3 | 1,500,000 to 1,999,999 | 2.187 AGENT |
|
|
471
|
-
|
|
472
|
-
A Mythic miner (5.00x) earns 15.00 AGENT per mine in Era 0.
|
|
473
|
-
|
|
474
|
-
### Cost Per Mine
|
|
475
|
-
|
|
476
|
-
- **Gas:** ~0.001 ETH per `mine()` transaction on Base
|
|
477
|
-
- **LLM:** $0 (mining uses algorithmic SMHL, no LLM calls)
|
|
478
|
-
- **Total:** ~$0.003 to $0.005 per mining cycle (gas only)
|
|
479
|
-
|
|
480
|
-
### Error Handling
|
|
481
|
-
|
|
482
|
-
The miner has built-in resilience:
|
|
483
|
-
- **Flat retry delay** on transient failures (about 2s with a small jitter)
|
|
484
|
-
- **Background stale checks** every 5 seconds by default so slow grinders do not waste a full attempt on a dead challenge
|
|
485
|
-
- **Max 10 consecutive failures** before the miner exits
|
|
486
|
-
- **Fatal errors** cause immediate exit: `"Not your miner"`, `"Supply exhausted"`, `"No contracts"`
|
|
487
|
-
- **Block timing** is handled automatically: if the block hasn't advanced, the miner waits
|
|
488
|
-
|
|
489
|
-
---
|
|
490
|
-
|
|
491
|
-
## 9. Step 6: Monitor
|
|
26
|
+
Once approved, select the CLI's existing Easy Mode with the pinned package:
|
|
492
27
|
|
|
493
28
|
```bash
|
|
494
|
-
npx apow-cli
|
|
495
|
-
npx apow-cli stats <tokenId> # stats for a specific rig
|
|
29
|
+
npx --yes apow-cli@0.12.0 start --easy
|
|
496
30
|
```
|
|
497
31
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
- Current mining target (difficulty)
|
|
502
|
-
- Your wallet's AGENT balance
|
|
503
|
-
|
|
504
|
-
**Miner stats output (when tokenId provided):**
|
|
505
|
-
- Rarity tier and name
|
|
506
|
-
- Hashpower multiplier
|
|
507
|
-
- Mint block number
|
|
508
|
-
- Total mine count for this rig
|
|
509
|
-
- Total AGENT earned by this rig
|
|
32
|
+
Funding is a mandatory external prerequisite: the CLI cannot mint or mine until
|
|
33
|
+
the dedicated wallet has ETH and USDC on Base. The same command handles the two
|
|
34
|
+
phases around that checkpoint:
|
|
510
35
|
|
|
511
|
-
|
|
36
|
+
- before funding, it creates an encrypted APoW wallet if needed, configures Easy
|
|
37
|
+
Mode, prints the complete Base address and required balances, then stops;
|
|
38
|
+
- after the user funds that address and confirms funding, rerunning it detects
|
|
39
|
+
an existing rig or mints one within the configured cap, starts continuous
|
|
40
|
+
mining, retries normal transient failures, and keeps signing behind the local
|
|
41
|
+
enforce-mode policy.
|
|
512
42
|
|
|
513
|
-
|
|
43
|
+
The user's approval authorizes this Easy Mode invocation; Wallet Protocol v2 remains the sole runtime opsec and signing-policy layer. The user can stop mining with Ctrl+C.
|
|
514
44
|
|
|
515
|
-
|
|
45
|
+
## Funding handoff
|
|
516
46
|
|
|
517
|
-
|
|
47
|
+
If the CLI pauses because the wallet needs funds:
|
|
518
48
|
|
|
519
|
-
|
|
49
|
+
1. Return the complete Base wallet address and the ETH and USDC minimums printed by the CLI.
|
|
50
|
+
2. Tell the user to send those assets to that address on Base.
|
|
51
|
+
3. Stop. Do not move, convert, or source funds for the user.
|
|
52
|
+
4. After the user confirms funding, resume the same Easy Mode flow with the pinned `start --easy` command.
|
|
520
53
|
|
|
521
|
-
|
|
54
|
+
Funding is a handoff, not permission to operate another wallet or move assets.
|
|
522
55
|
|
|
523
|
-
|
|
56
|
+
## Security boundaries
|
|
524
57
|
|
|
525
|
-
|
|
58
|
+
- Never request, read, reveal, copy, or transmit wallet secrets.
|
|
59
|
+
- Never search files, directories, environment variables, shell history, mounted drives, or other machines for wallets or credentials.
|
|
60
|
+
- Never import or operate a main wallet for this skill.
|
|
61
|
+
- Never create a raw-key file or place a raw wallet secret in project configuration.
|
|
62
|
+
- Invoke only the single pinned `start --easy` command in this skill; every other CLI command is out of scope.
|
|
63
|
+
- Never change the signing policy from `enforce`.
|
|
64
|
+
- Never raise the mint, transfer, sweep, or x402 spend caps.
|
|
65
|
+
- Never install or execute an unpinned package version.
|
|
66
|
+
- Never continue if the package version, contract addresses, chain, approval scope, or policy state differs from what the CLI displays.
|
|
526
67
|
|
|
527
|
-
|
|
68
|
+
If setup asks for a keystore password, the user must enter it directly into their local terminal or provide it through their own secret manager. Never ask them to paste it into chat.
|
|
528
69
|
|
|
529
|
-
|
|
530
|
-
# 1. Generate sub-wallets (main wallet is already configured in .env)
|
|
531
|
-
npx apow-cli wallet new # → address A + key A
|
|
532
|
-
npx apow-cli wallet new # → address B + key B
|
|
533
|
-
npx apow-cli wallet new # → address C + key C
|
|
70
|
+
## Expected policy caps
|
|
534
71
|
|
|
535
|
-
|
|
536
|
-
npx apow-cli wallet fund 0xADDRESS_A
|
|
537
|
-
npx apow-cli wallet fund 0xADDRESS_B
|
|
538
|
-
npx apow-cli wallet fund 0xADDRESS_C
|
|
539
|
-
# Or specify a custom amount: npx apow-cli wallet fund 0xADDRESS_A 0.01
|
|
540
|
-
|
|
541
|
-
# 3. Mint a rig for each sub-wallet
|
|
542
|
-
PRIVATE_KEY=0xKEY_A npx apow-cli mint
|
|
543
|
-
PRIVATE_KEY=0xKEY_B npx apow-cli mint
|
|
544
|
-
PRIVATE_KEY=0xKEY_C npx apow-cli mint
|
|
545
|
-
|
|
546
|
-
# 4. Mine with all wallets in parallel
|
|
547
|
-
PRIVATE_KEY=0xKEY_A npx apow-cli mine &
|
|
548
|
-
PRIVATE_KEY=0xKEY_B npx apow-cli mine &
|
|
549
|
-
PRIVATE_KEY=0xKEY_C npx apow-cli mine &
|
|
550
|
-
wait
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
Or use a process manager like PM2 for production:
|
|
554
|
-
|
|
555
|
-
```bash
|
|
556
|
-
# ecosystem.config.cjs
|
|
557
|
-
module.exports = {
|
|
558
|
-
apps: [
|
|
559
|
-
{ name: "miner-a", script: "npx", args: "apow mine", env: { PRIVATE_KEY: "0xKEY_A" } },
|
|
560
|
-
{ name: "miner-b", script: "npx", args: "apow mine", env: { PRIVATE_KEY: "0xKEY_B" } },
|
|
561
|
-
{ name: "miner-c", script: "npx", args: "apow mine", env: { PRIVATE_KEY: "0xKEY_C" } },
|
|
562
|
-
]
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
pm2 start ecosystem.config.cjs
|
|
566
|
-
pm2 logs
|
|
567
|
-
```
|
|
72
|
+
The default enforce-mode policy limits:
|
|
568
73
|
|
|
569
|
-
|
|
74
|
+
- one rig mint to at most `0.01 ETH`;
|
|
75
|
+
- each x402 payment to at most `1 USDC`;
|
|
76
|
+
- aggregate x402 payments to at most `20 USDC` per UTC day;
|
|
77
|
+
- transfers and sweeps to their separately configured destinations and caps.
|
|
570
78
|
|
|
571
|
-
|
|
79
|
+
Treat the CLI’s displayed policy as authoritative. If it is less restrictive than these defaults, stop and ask the user to review it.
|
|
572
80
|
|
|
573
|
-
|
|
81
|
+
## Failure handling
|
|
574
82
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
-
|
|
582
|
-
-
|
|
583
|
-
- **CPU-C** (any platform): requires `clang` or `gcc`
|
|
584
|
-
- **Remote CUDA** (VAST.ai): set `VAST_IP` + `VAST_PORT` env vars for SSH-based remote grinding
|
|
585
|
-
|
|
586
|
-
### x402 GPU Grinding (Remote RTX 4090)
|
|
587
|
-
|
|
588
|
-
No GPU? Add `USE_X402_GRIND=true` to your `.env` for remote RTX 4090 nonce grinding at ~$0.006/grind (dynamic pricing) via the [x402 payment protocol](https://www.x402.org/). Zero setup, zero API keys — payment is automatic from your mining wallet's USDC balance.
|
|
589
|
-
|
|
590
|
-
```bash
|
|
591
|
-
# In your .env (enabled automatically in Easy Mode)
|
|
592
|
-
USE_X402_GRIND=true
|
|
593
|
-
# ALLOW_LOCAL_FALLBACK_WITH_X402=true # Advanced Mode hybrid option
|
|
594
|
-
# GRIND_URL=https://grind.apow.io/grind # default, override for self-hosted
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
In Easy Mode, the HTTP grinder is the only nonce source, so agents do not silently burn local CPU while remote x402 GPU mining is active. Advanced Mode can opt into a hybrid local fallback. For GPU-less miners, this is still a 10-100x speed improvement over JS fallback.
|
|
598
|
-
|
|
599
|
-
**Front-running is cryptographically impossible:** nonces are bound to `keccak256(challenge, msg.sender, nonce)` — a nonce ground for address A is useless for address B.
|
|
600
|
-
|
|
601
|
-
**Self-hosting:** Deploy your own GrindProxy with any CUDA GPU. See [apow-grind](https://github.com/Agentoshi/apow-grind) for the open-source CF Worker + RunPod Docker image. Set `GRIND_URL` to your endpoint.
|
|
602
|
-
|
|
603
|
-
### Local LLM Setup (Ollama)
|
|
604
|
-
|
|
605
|
-
```bash
|
|
606
|
-
# Install Ollama
|
|
607
|
-
curl -fsSL https://ollama.ai/install.sh | sh
|
|
608
|
-
|
|
609
|
-
# Pull a model
|
|
610
|
-
ollama pull llama3.1
|
|
611
|
-
|
|
612
|
-
# Configure .env
|
|
613
|
-
LLM_PROVIDER=ollama
|
|
614
|
-
LLM_MODEL=llama3.1
|
|
615
|
-
# LLM_API_KEY is not needed for Ollama
|
|
616
|
-
```
|
|
617
|
-
|
|
618
|
-
Ollama runs on `http://127.0.0.1:11434` by default. The miner connects there automatically.
|
|
619
|
-
|
|
620
|
-
**Trade-off:** Free inference, but local models may have lower accuracy on the constrained SMHL challenges. The miner retries up to 5 times per challenge, but persistent failures will slow mining.
|
|
621
|
-
|
|
622
|
-
### Custom RPC Endpoints
|
|
623
|
-
|
|
624
|
-
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.
|
|
625
|
-
|
|
626
|
-
### Agent Wallet
|
|
627
|
-
|
|
628
|
-
Each Miner NFT supports an on-chain agent wallet. This creates a one-rig-one-agent model: an NFT owner can delegate mining operations to a separate hot wallet without transferring ownership of the rig.
|
|
629
|
-
|
|
630
|
-
**Functions:**
|
|
631
|
-
- `getAgentWallet(tokenId)`: returns the registered agent wallet address
|
|
632
|
-
- `setAgentWallet(tokenId, newWallet, deadline, signature)`: sets a new agent wallet (requires EIP-712 signature from the new wallet)
|
|
633
|
-
- `unsetAgentWallet(tokenId)`: removes the agent wallet
|
|
634
|
-
|
|
635
|
-
**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.
|
|
636
|
-
|
|
637
|
-
**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.
|
|
638
|
-
|
|
639
|
-
**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.
|
|
640
|
-
|
|
641
|
-
### Testnet (Base Sepolia)
|
|
642
|
-
|
|
643
|
-
To mine on testnet, set:
|
|
644
|
-
```bash
|
|
645
|
-
RPC_URL=https://sepolia.base.org
|
|
646
|
-
CHAIN=baseSepolia
|
|
647
|
-
```
|
|
648
|
-
Use the corresponding testnet contract addresses.
|
|
649
|
-
|
|
650
|
-
---
|
|
651
|
-
|
|
652
|
-
## 11. Troubleshooting
|
|
653
|
-
|
|
654
|
-
| Error | Cause | Fix |
|
|
655
|
-
|---|---|---|
|
|
656
|
-
| `PRIVATE_KEY is required for minting and mining commands.` | No wallet is configured for the current manual command | Run `npx apow-cli start` and choose Easy Mode to generate one, or add `PRIVATE_KEY=0x...` to your `.env` file |
|
|
657
|
-
| `PRIVATE_KEY must be a 32-byte hex string prefixed with 0x.` | Malformed private key | Ensure key is exactly `0x` + 64 hex characters |
|
|
658
|
-
| `MINING_AGENT_ADDRESS is required.` | Contract address missing or overridden with an invalid value | Remove the bad override to use the built-in default, or set the correct `MINING_AGENT_ADDRESS` in `.env` |
|
|
659
|
-
| `AGENT_COIN_ADDRESS is required.` | Contract address missing or overridden with an invalid value | Remove the bad override to use the built-in default, or set the correct `AGENT_COIN_ADDRESS` in `.env` |
|
|
660
|
-
| `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` |
|
|
661
|
-
| `Insufficient fee` | Not enough ETH sent with mint | Check `getMintPrice()` and ensure wallet has enough ETH |
|
|
662
|
-
| `Sold out` | All 10,000 Miner NFTs minted | No more rigs available; buy one on secondary market |
|
|
663
|
-
| `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 |
|
|
664
|
-
| `Invalid SMHL` | LLM produced an incorrect solution | Retry; if persistent, switch to a more capable model |
|
|
665
|
-
| `Not your miner` | Token ID not owned by your wallet | Verify `PRIVATE_KEY` matches the NFT owner; check token ID |
|
|
666
|
-
| `Supply exhausted` | All 18.9M mineable AGENT has been minted | Mining is complete; no more rewards available |
|
|
667
|
-
| `One mine per block` | Another mine was confirmed in this block | Automatic; the miner waits for the next block |
|
|
668
|
-
| `No contracts` | Calling from a contract, not an EOA | Mining requires an externally owned account (EOA) |
|
|
669
|
-
| `Invalid hash` | Nonce does not meet difficulty target | Bug in nonce grinding; should not happen under normal operation |
|
|
670
|
-
| `Nonce too high` | Wallet nonce desync | Reset nonce in wallet or wait for pending transactions to confirm |
|
|
671
|
-
| Frequent `stale #N` restarts | Your grinder is slower than the current network difficulty | Expected on slow rigs. The default 5-second stale check already reduces wasted work; use a faster grinder or lower `STALE_CHECK_INTERVAL` if you intentionally want more aggressive polling. |
|
|
672
|
-
| `Anthropic request failed: 429` | Rate limited by Anthropic API | Reduce mining frequency or upgrade API plan |
|
|
673
|
-
| `Ollama request failed: 500` | Ollama server error | Check `ollama serve` is running; restart if needed |
|
|
674
|
-
| `SMHL solve failed after 5 attempts` | LLM cannot satisfy constraints | Switch to a more capable model (e.g., `gpt-4o` or `claude-sonnet-4-5-20250929`) |
|
|
675
|
-
| `Fee forward failed` | LPVault rejected the ETH transfer | LPVault may not be set; check contract deployment |
|
|
676
|
-
| `10 consecutive failures` | Repeated transient errors | Check RPC connectivity, wallet balance, and LLM availability |
|
|
677
|
-
| `Timed out waiting for next block (60s)` | RPC not responding or network stalled | Check RPC connectivity; try a different RPC endpoint |
|
|
678
|
-
|
|
679
|
-
---
|
|
680
|
-
|
|
681
|
-
## 12. Security & Trust
|
|
682
|
-
|
|
683
|
-
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.
|
|
684
|
-
|
|
685
|
-
### Private Key Generation (Local Only)
|
|
686
|
-
|
|
687
|
-
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`.
|
|
688
|
-
|
|
689
|
-
### Private Key Is NEVER Transmitted
|
|
690
|
-
|
|
691
|
-
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.
|
|
692
|
-
|
|
693
|
-
### Zero Telemetry
|
|
694
|
-
|
|
695
|
-
The CLI contains no analytics, no error reporting, and no phone-home behavior of any kind:
|
|
696
|
-
|
|
697
|
-
- No analytics SDKs (no Mixpanel, no PostHog, no Google Analytics)
|
|
698
|
-
- No error reporting services (no Sentry, no Bugsnag)
|
|
699
|
-
- No tracking pixels, no usage metrics, no telemetry endpoints
|
|
700
|
-
|
|
701
|
-
The CLI makes only these network calls:
|
|
702
|
-
|
|
703
|
-
1. **Blockchain RPC** (to user-configured RPC URL or QuickNode x402): standard `eth_call`, `eth_sendRawTransaction`, etc.
|
|
704
|
-
2. **LLM API** (to user-configured provider): sends only word-puzzle prompts for SMHL solving, never wallet data
|
|
705
|
-
3. **Bridge APIs** (only when using `apow fund`):
|
|
706
|
-
- **CoinGecko** (`api.coingecko.com`): SOL/ETH price quotes
|
|
707
|
-
- **Squid Router** (`v2.api.squidrouter.com`): deposit address generation and bridge status
|
|
708
|
-
- **Uniswap V3** (on-chain, Base): ETH/USDC swaps for auto-split
|
|
709
|
-
- **Solana RPC** (`api.mainnet-beta.solana.com` or custom): balance checks
|
|
710
|
-
|
|
711
|
-
No private keys are transmitted to bridge providers. Squid generates a deposit address, and the user sends tokens from their own wallet.
|
|
712
|
-
|
|
713
|
-
### LLM Calls Are Data-Isolated
|
|
714
|
-
|
|
715
|
-
The SMHL solver sends only generic word-generation prompts to the LLM (e.g., "Write exactly 5 lowercase English words..."). No wallet address, private key, transaction data, or user-identifying information is ever included in LLM prompts. The string `privateKey` does not appear anywhere in `smhl.ts`.
|
|
716
|
-
|
|
717
|
-
### Open Source & Auditable
|
|
718
|
-
|
|
719
|
-
- Full source code: [github.com/Agentoshi/apow-cli](https://github.com/Agentoshi/apow-cli)
|
|
720
|
-
- MIT licensed
|
|
721
|
-
- Every line is auditable. There are no obfuscated modules, no binary blobs, no minified dependencies performing network calls
|
|
722
|
-
- Smart contracts are separately auditable: [github.com/Agentoshi/apow-core](https://github.com/Agentoshi/apow-core)
|
|
723
|
-
|
|
724
|
-
### npm Package Integrity
|
|
725
|
-
|
|
726
|
-
- Published as `apow-cli` on npm
|
|
727
|
-
- Package contents match the GitHub source (verify with `npm pack --dry-run` or compare against the repo)
|
|
728
|
-
- No `postinstall` scripts that execute arbitrary code
|
|
729
|
-
- The `package.json` `scripts` section contains only standard build/dev commands
|
|
730
|
-
|
|
731
|
-
### Best Practices for Users
|
|
732
|
-
|
|
733
|
-
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.
|
|
734
|
-
2. **Fund with only what you need.** ~0.005 ETH covers minting + several mining cycles.
|
|
735
|
-
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.
|
|
736
|
-
4. **Verify the source before running** if you prefer:
|
|
737
|
-
```bash
|
|
738
|
-
git clone https://github.com/Agentoshi/apow-cli
|
|
739
|
-
cd apow-cli && npm install && npm run build
|
|
740
|
-
node dist/index.js setup
|
|
741
|
-
```
|
|
742
|
-
5. **Review dependencies.** The dependency tree is minimal and standard: `viem` (Ethereum library), `commander` (CLI framework), `dotenv` (env loading), `openai` (LLM client), `@blockrun/clawrouter` (x402 LLM proxy), `@quicknode/x402` (x402 RPC payment), `@solana/web3.js` (Solana signing, lazy-loaded only for bridging), `qrcode-terminal` (QR codes for fund command), `ox` (utilities). No exotic or suspicious packages.
|
|
743
|
-
|
|
744
|
-
### How to Verify These Claims Yourself
|
|
745
|
-
|
|
746
|
-
Every statement above can be independently verified:
|
|
747
|
-
|
|
748
|
-
```bash
|
|
749
|
-
# Clone the source
|
|
750
|
-
git clone https://github.com/Agentoshi/apow-cli && cd apow-cli
|
|
751
|
-
|
|
752
|
-
# Search for any outbound network calls (you'll find only RPC and LLM calls)
|
|
753
|
-
grep -r "fetch\|axios\|http\|request" src/
|
|
754
|
-
|
|
755
|
-
# Confirm private key is never in any network payload
|
|
756
|
-
grep -r "privateKey" src/ # only appears in local wallet operations, never in fetch/request calls
|
|
757
|
-
|
|
758
|
-
# Check for telemetry/analytics packages
|
|
759
|
-
grep -r "mixpanel\|posthog\|sentry\|bugsnag\|analytics\|telemetry" src/ package.json
|
|
760
|
-
|
|
761
|
-
# Verify wallet file permissions
|
|
762
|
-
grep -r "0o600\|0600" src/ # wallet files are created with owner-only permissions
|
|
763
|
-
|
|
764
|
-
# Check postinstall scripts
|
|
765
|
-
cat package.json | grep -A5 "scripts" # no postinstall hook
|
|
766
|
-
```
|
|
767
|
-
|
|
768
|
-
---
|
|
769
|
-
|
|
770
|
-
## 13. Contract Addresses
|
|
771
|
-
|
|
772
|
-
| Contract | Address |
|
|
773
|
-
|---|---|
|
|
774
|
-
| MiningAgent (ERC-721) | `0xB7caD3ca5F2BD8aEC2Eb67d6E8D448099B3bC03D` |
|
|
775
|
-
| AgentCoin (ERC-20) | `0x12577CF0D8a07363224D6909c54C056A183e13b3` |
|
|
776
|
-
| LPVault | `0xDD47511d060eA4E955B95F6f43553414328648a6` |
|
|
777
|
-
|
|
778
|
-
**Network:** Base (Chain ID 8453)
|
|
779
|
-
|
|
780
|
-
**Token details:**
|
|
781
|
-
- **Name:** AgentCoin
|
|
782
|
-
- **Symbol:** AGENT
|
|
783
|
-
- **Decimals:** 18
|
|
784
|
-
- **Max supply:** 21,000,000 AGENT
|
|
785
|
-
- **LP reserve:** 2,100,000 AGENT (10%, minted to LPVault at deployment)
|
|
786
|
-
- **Mineable supply:** 18,900,000 AGENT
|
|
787
|
-
|
|
788
|
-
**Miner NFT details:**
|
|
789
|
-
- **Name:** AgentCoin Miner
|
|
790
|
-
- **Symbol:** MINER
|
|
791
|
-
- **Standard:** ERC-721 Enumerable
|
|
792
|
-
- **Max supply:** 10,000
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
## 14. Dashboard
|
|
796
|
-
|
|
797
|
-
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.
|
|
798
|
-
|
|
799
|
-
### Subcommands
|
|
800
|
-
|
|
801
|
-
| Command | Description |
|
|
802
|
-
|---------|-------------|
|
|
803
|
-
| `apow dashboard start` | Launch the dashboard web UI at `http://localhost:3847`. Auto-opens browser. Press Ctrl+C to stop. |
|
|
804
|
-
| `apow dashboard add <address>` | Add a wallet address to monitor. Validates 0x + 40 hex chars. |
|
|
805
|
-
| `apow dashboard remove <address>` | Remove a wallet address from monitoring. |
|
|
806
|
-
| `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. |
|
|
807
|
-
| `apow dashboard wallets` | List all currently monitored wallet addresses. |
|
|
808
|
-
|
|
809
|
-
### How It Works
|
|
810
|
-
|
|
811
|
-
- **Wallet storage:** `~/.apow/wallets.json` — a plain JSON array of Ethereum addresses.
|
|
812
|
-
- **Fleet management:** `~/.apow/fleets.json` — optional, defines named groups of wallets from different sources.
|
|
813
|
-
- **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.
|
|
814
|
-
- **NFT art:** Renders on-chain SVG art for each Mining Rig with rarity-based color coding.
|
|
815
|
-
- **Auto-seed:** On first run, seeds `wallets.json` with the address from your `.env` if configured.
|
|
816
|
-
- **Auto-detect:** `dashboard start` automatically scans CWD for `wallet-0x*.txt` and `wallet-0x*.json` files before launching.
|
|
817
|
-
|
|
818
|
-
### Fleet Configuration (`~/.apow/fleets.json`)
|
|
819
|
-
|
|
820
|
-
For managing wallets across multiple machines or directories, create `~/.apow/fleets.json`:
|
|
821
|
-
|
|
822
|
-
```json
|
|
823
|
-
[
|
|
824
|
-
{ "name": "Local", "type": "array", "path": "/home/user/.apow/wallets.json" },
|
|
825
|
-
{ "name": "Vast.ai Rigs", "type": "rigdirs", "path": "/mnt/mining/rigs" },
|
|
826
|
-
{ "name": "Pool Wallets", "type": "walletfiles", "path": "/mnt/mining/wallets" },
|
|
827
|
-
{ "name": "Solkek Fleet", "type": "solkek", "path": "/home/user/solkek-config.json" }
|
|
828
|
-
]
|
|
829
|
-
```
|
|
830
|
-
|
|
831
|
-
**Fleet types:**
|
|
832
|
-
|
|
833
|
-
| Type | Source Format | Description |
|
|
834
|
-
|------|--------------|-------------|
|
|
835
|
-
| `array` | JSON array of addresses | Simple list: `["0xABC...", "0xDEF..."]` |
|
|
836
|
-
| `solkek` | JSON with `master.address` + `miners[].address` | Solkek fleet manager format |
|
|
837
|
-
| `rigdirs` | Directory containing `rig*/wallet-0x*.txt` or `.json` | Scan rig subdirectories for wallet files |
|
|
838
|
-
| `walletfiles` | Directory containing `wallet-0x*.txt` or `.json` | Scan flat directory for wallet files |
|
|
839
|
-
|
|
840
|
-
If `fleets.json` does not exist, the dashboard falls back to `wallets.json` as a single "Main" fleet.
|
|
841
|
-
|
|
842
|
-
### Example Workflow
|
|
843
|
-
|
|
844
|
-
```bash
|
|
845
|
-
# 1. Scan a directory with wallet files to populate wallets.json
|
|
846
|
-
npx apow-cli dashboard scan /path/to/mining/dir
|
|
847
|
-
|
|
848
|
-
# 2. Manually add a wallet not found by scan
|
|
849
|
-
npx apow-cli dashboard add 0x1234567890abcdef1234567890abcdef12345678
|
|
850
|
-
|
|
851
|
-
# 3. Verify your wallet list
|
|
852
|
-
npx apow-cli dashboard wallets
|
|
853
|
-
|
|
854
|
-
# 4. Launch the dashboard
|
|
855
|
-
npx apow-cli dashboard start
|
|
856
|
-
# → Opens http://localhost:3847 in your browser
|
|
857
|
-
# → Shows real-time balances, rig stats, earnings, and NFT art
|
|
858
|
-
# → Press Ctrl+C to stop
|
|
859
|
-
```
|
|
860
|
-
|
|
861
|
-
### Troubleshooting
|
|
862
|
-
|
|
863
|
-
| Issue | Cause | Fix |
|
|
864
|
-
|-------|-------|-----|
|
|
865
|
-
| "No wallets configured" | Empty `wallets.json` | Run `apow dashboard add <addr>` or `apow dashboard scan .` |
|
|
866
|
-
| Dashboard shows 0 balances | RPC rate limiting | Set a dedicated `RPC_URL` in `.env` (Alchemy recommended) |
|
|
867
|
-
| Browser doesn't open | Headless/SSH environment | Manually open `http://localhost:3847` in a browser |
|
|
868
|
-
| Stale data | 25s cache TTL | Wait for next refresh cycle or restart the dashboard |
|
|
869
|
-
|
|
870
|
-
---
|
|
83
|
+
- No wallet: allow `start` to create one encrypted APoW wallet.
|
|
84
|
+
- Password unavailable: pause for direct local entry; do not handle it in chat.
|
|
85
|
+
- Funding needed: use the Base-only handoff above.
|
|
86
|
+
- Policy not in enforce mode: stop.
|
|
87
|
+
- User approval for the scoped Easy Mode command missing: stop.
|
|
88
|
+
- Package version unavailable: stop; do not substitute `latest`.
|
|
89
|
+
- RPC, SMHL, grinder, or transaction failure: report the concise error and let the CLI’s bounded retry behavior handle transient failures.
|
|
90
|
+
- Mining stopped: report whether the user interrupted it or the CLI exited with an error.
|
|
871
91
|
|
|
872
|
-
|
|
92
|
+
Do not expand scope to “helpful” wallet operations. This skill’s complete job is the existing Easy Mode flow: encrypted APoW setup, a Base funding handoff, and policy-capped mining.
|