apow-cli 0.9.0 → 0.9.2
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 -5
- package/dist/build.js +229 -0
- package/dist/clawrouter.js +96 -0
- package/dist/config.js +4 -3
- package/dist/errors.js +16 -0
- package/dist/grinder-native.js +71 -2
- package/dist/grinder.js +14 -0
- package/dist/index.js +29 -5
- package/dist/miner.js +77 -29
- package/dist/preflight.js +17 -2
- package/dist/smhl.js +56 -0
- package/local/gpu/Makefile +39 -0
- package/local/gpu/grinder-cpu.c +241 -0
- package/local/gpu/grinder-cuda.cu +322 -0
- package/local/gpu/grinder.m +191 -0
- package/local/gpu/keccak.metal +143 -0
- package/package.json +9 -3
- package/skill.md +46 -29
package/skill.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: apow-mine
|
|
3
|
-
description: Set up and start mining AGENT tokens on Base L2 using apow-cli. Handles wallet creation, RPC setup, LLM config, minting a rig, and starting the mining loop.
|
|
3
|
+
description: Set up and start mining AGENT tokens on Base L2 using apow-cli. Handles wallet creation, RPC setup, LLM config, minting a rig, and starting the mining loop. Zero credentials needed — only ETH + USDC on Base.
|
|
4
4
|
allowed-tools: Bash(npx:*), Bash(node:*), Bash(curl:*)
|
|
5
5
|
argument-hint: [setup|mint|mine|stats]
|
|
6
6
|
metadata:
|
|
@@ -8,9 +8,6 @@ metadata:
|
|
|
8
8
|
requires:
|
|
9
9
|
env:
|
|
10
10
|
- PRIVATE_KEY
|
|
11
|
-
- RPC_URL
|
|
12
|
-
- LLM_PROVIDER
|
|
13
|
-
- LLM_API_KEY
|
|
14
11
|
anyBins:
|
|
15
12
|
- npx
|
|
16
13
|
- node
|
|
@@ -48,35 +45,51 @@ npx tsx src/index.ts mint
|
|
|
48
45
|
npx tsx src/index.ts mine
|
|
49
46
|
```
|
|
50
47
|
|
|
51
|
-
### Autonomous Agent Flow (non-interactive)
|
|
48
|
+
### Autonomous Agent Flow — Zero Credentials (non-interactive)
|
|
52
49
|
|
|
53
|
-
If you're an AI agent, skip the interactive wizard and write the `.env` directly
|
|
50
|
+
If you're an AI agent, skip the interactive wizard and write the `.env` directly.
|
|
51
|
+
**No API keys needed.** ClawRouter pays for LLM inference with USDC from your mining wallet via x402. Same private key, same USDC balance, zero credentials.
|
|
54
52
|
|
|
55
53
|
```bash
|
|
56
54
|
# 1. Generate a wallet
|
|
57
55
|
npx apow-cli wallet new
|
|
58
56
|
# Captures address + private key from output (also saved to wallet-<address>.txt)
|
|
59
57
|
|
|
60
|
-
# 2. Write .env directly
|
|
61
|
-
# LLM config is only needed for minting (one-time); mining uses algorithmic SMHL.
|
|
62
|
-
# IMPORTANT: Use an API-based provider for minting (openai/anthropic/gemini/deepseek/qwen).
|
|
63
|
-
# RPC: set RPC_URL (free from Alchemy) or USE_X402=true (auto-pay $10 USDC via QuickNode).
|
|
58
|
+
# 2. Write .env directly — ZERO API keys needed
|
|
64
59
|
cat > .env << 'EOF'
|
|
65
60
|
PRIVATE_KEY=0x<from step 1>
|
|
66
|
-
|
|
67
|
-
LLM_PROVIDER=
|
|
68
|
-
LLM_MODEL=
|
|
69
|
-
LLM_API_KEY=<your key> # Required for minting only
|
|
61
|
+
USE_X402=true
|
|
62
|
+
LLM_PROVIDER=clawrouter
|
|
63
|
+
LLM_MODEL=blockrun/eco
|
|
70
64
|
MINING_AGENT_ADDRESS=0xB7caD3ca5F2BD8aEC2Eb67d6E8D448099B3bC03D
|
|
71
65
|
AGENT_COIN_ADDRESS=0x12577CF0D8a07363224D6909c54C056A183e13b3
|
|
72
66
|
EOF
|
|
73
67
|
|
|
74
|
-
# 3. Fund the wallet
|
|
68
|
+
# 3. Fund the wallet with ETH (gas) + USDC (x402 RPC + LLM payments)
|
|
75
69
|
npx apow-cli fund --chain solana --token sol # bridge SOL → ETH+USDC on Base
|
|
76
70
|
# Or: npx apow-cli fund --chain base # send ETH or USDC on Base directly
|
|
77
71
|
# Or: ask your user to send ETH + USDC on Base directly
|
|
78
72
|
|
|
79
|
-
# 4. Mint + mine (fully autonomous from here)
|
|
73
|
+
# 4. Mint + mine (fully autonomous from here — zero human intervention)
|
|
74
|
+
npx apow-cli mint
|
|
75
|
+
npx apow-cli mine
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Legacy Flow (with API keys)
|
|
79
|
+
|
|
80
|
+
If you prefer to use your own LLM API key instead of ClawRouter:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
cat > .env << 'EOF'
|
|
84
|
+
PRIVATE_KEY=0x<your key>
|
|
85
|
+
RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY # Free from alchemy.com
|
|
86
|
+
LLM_PROVIDER=openai
|
|
87
|
+
LLM_MODEL=gpt-4o-mini
|
|
88
|
+
LLM_API_KEY=<your key>
|
|
89
|
+
MINING_AGENT_ADDRESS=0xB7caD3ca5F2BD8aEC2Eb67d6E8D448099B3bC03D
|
|
90
|
+
AGENT_COIN_ADDRESS=0x12577CF0D8a07363224D6909c54C056A183e13b3
|
|
91
|
+
EOF
|
|
92
|
+
|
|
80
93
|
npx apow-cli mint
|
|
81
94
|
npx apow-cli mine
|
|
82
95
|
```
|
|
@@ -108,9 +121,10 @@ The miner client validates locally before submitting.
|
|
|
108
121
|
|
|
109
122
|
| Requirement | Details |
|
|
110
123
|
|---|---|
|
|
111
|
-
| **Node.js** |
|
|
124
|
+
| **Node.js** | v20 or higher |
|
|
112
125
|
| **Base wallet** | A private key with ETH on Base (for gas + mint fee) |
|
|
113
|
-
| **
|
|
126
|
+
| **USDC on Base** | ~$10 covers both x402 RPC and ClawRouter LLM calls (only if using zero-credential path) |
|
|
127
|
+
| **LLM access** | ClawRouter (zero credentials, recommended) OR API key (OpenAI, Gemini, etc.) OR local Ollama (**required for minting only**) |
|
|
114
128
|
| **git** | Only if installing from source (not needed for npm) |
|
|
115
129
|
|
|
116
130
|
---
|
|
@@ -233,14 +247,15 @@ AGENT_COIN_ADDRESS=0x12577CF0D8a07363224D6909c54C056A183e13b3
|
|
|
233
247
|
|
|
234
248
|
# === LLM Configuration (required for minting only; mining uses optimized solving) ===
|
|
235
249
|
|
|
236
|
-
# Provider: "openai" | "gemini" | "deepseek" | "qwen" | "anthropic" | "ollama"
|
|
237
|
-
|
|
250
|
+
# Provider: "clawrouter" (recommended) | "openai" | "gemini" | "deepseek" | "qwen" | "anthropic" | "ollama"
|
|
251
|
+
# clawrouter: zero credentials, pays with USDC from your wallet via x402
|
|
252
|
+
LLM_PROVIDER=clawrouter
|
|
238
253
|
|
|
239
|
-
# API key (not required if LLM_PROVIDER=ollama)
|
|
240
|
-
LLM_API_KEY=sk-your-api-key
|
|
254
|
+
# API key (not required if LLM_PROVIDER=clawrouter, ollama, claude-code, or codex)
|
|
255
|
+
# LLM_API_KEY=sk-your-api-key
|
|
241
256
|
|
|
242
257
|
# Model name (provider-specific)
|
|
243
|
-
LLM_MODEL=
|
|
258
|
+
LLM_MODEL=blockrun/eco
|
|
244
259
|
|
|
245
260
|
# === Network ===
|
|
246
261
|
|
|
@@ -259,10 +274,11 @@ CHAIN=base
|
|
|
259
274
|
| `PRIVATE_KEY` | Yes | - | Wallet private key (0x + 64 hex chars) |
|
|
260
275
|
| `MINING_AGENT_ADDRESS` | Yes | - | Deployed MiningAgent contract address |
|
|
261
276
|
| `AGENT_COIN_ADDRESS` | Yes | - | Deployed AgentCoin contract address |
|
|
262
|
-
| `LLM_PROVIDER` | For minting | `
|
|
263
|
-
| `LLM_API_KEY` | For minting | - | API key for minting.
|
|
264
|
-
| `LLM_MODEL` | For minting | `
|
|
265
|
-
| `
|
|
277
|
+
| `LLM_PROVIDER` | For minting | `clawrouter` | LLM provider for minting: `clawrouter` (recommended, zero credentials), `openai`, `gemini`, `deepseek`, `qwen`, `anthropic`, or `ollama`. Not needed for mining. |
|
|
278
|
+
| `LLM_API_KEY` | For minting* | - | API key for minting. Not needed for `clawrouter`, `ollama`, `claude-code`, `codex`, or mining. Falls back to provider-specific env vars. |
|
|
279
|
+
| `LLM_MODEL` | For minting | `blockrun/eco` | Model identifier passed to the provider (minting only) |
|
|
280
|
+
| `CLAWROUTER_PORT` | No | `8402` | Port for ClawRouter local proxy (only if default is in use) |
|
|
281
|
+
| `MINER_THREADS` | No | All CPU cores | Threads for JS nonce grinding (fallback if no native GPU/CPU grinder detected) |
|
|
266
282
|
| `RPC_URL` | Yes* | — | Base JSON-RPC endpoint. Get a free URL from Alchemy or QuickNode. *Not needed if `USE_X402=true`. |
|
|
267
283
|
| `USE_X402` | No | `false` | Set to `true` to auto-pay via QuickNode x402 ($10 USDC for ~1M calls). Replaces `RPC_URL`. |
|
|
268
284
|
| `CHAIN` | No | `base` | Network selector; auto-detects `baseSepolia` if RPC URL contains "sepolia" |
|
|
@@ -277,7 +293,8 @@ CHAIN=base
|
|
|
277
293
|
|
|
278
294
|
| Provider | Model | Cost per call | Notes |
|
|
279
295
|
|---|---|---|---|
|
|
280
|
-
|
|
|
296
|
+
| ClawRouter | `blockrun/eco` | <$0.01 | **Recommended.** Zero credentials, pays with USDC via x402 |
|
|
297
|
+
| OpenAI | `gpt-4o-mini` | ~$0.001 | Cheapest API key option, fast, reliable |
|
|
281
298
|
| Gemini | `gemini-2.5-flash` | ~$0.001 | Fast, good accuracy |
|
|
282
299
|
| DeepSeek | `deepseek-chat` | ~$0.001 | Fast, accessible in China |
|
|
283
300
|
| Qwen | `qwen-plus` | ~$0.002 | Alibaba Cloud, accessible in China |
|
|
@@ -392,7 +409,7 @@ npx apow-cli mine <tokenId> # or specify a rig by token ID
|
|
|
392
409
|
- `miningTarget` (uint256): the difficulty target
|
|
393
410
|
- `smhl`: the SMHL format challenge
|
|
394
411
|
4. **Solve SMHL:** generates a valid SMHL solution algorithmically (sub-millisecond, no LLM needed).
|
|
395
|
-
5. **Grind nonce:**
|
|
412
|
+
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.
|
|
396
413
|
6. **Submit proof:** calls `mine(nonce, smhlSolution, tokenId)` on AgentCoin. The contract verifies both the hash and SMHL solution on-chain.
|
|
397
414
|
7. **Collect reward:** AGENT tokens are minted directly to your wallet.
|
|
398
415
|
8. **Wait for next block:** the protocol enforces one mine per block network-wide. The client waits for block advancement before the next cycle.
|