{"skill":{"slug":"claw-mining","displayName":"$CLAW Mining - Proof of AI Work","summary":"Mine $CLAW tokens via Proof of AI Work on Ethereum. Install this Skill and tell your agent 'mine CLAW' — the agent handles everything automatically. No techn...","description":"---\nname: claw-mining\ndescription: \"Mine $CLAW tokens via Proof of AI Work on Ethereum. Install this Skill and tell your agent 'mine CLAW' — the agent handles everything automatically. No technical knowledge required.\"\nlicense: MIT-0\nmetadata: {\"author\": \"Cliai21\", \"version\": \"3.0\", \"network\": \"Ethereum Mainnet\", \"github\": \"https://github.com/Cliai21/clawing\", \"openclaw\": {\"emoji\": \"⛏️\", \"homepage\": \"https://minewithclaw.com\", \"requires\": {\"bins\": [\"node\", \"git\"], \"env\": [\"AI_API_KEY\", \"PRIVATE_KEY\", \"RPC_URL\", \"POAIW_MINT_ADDRESS\"]}, \"primaryEnv\": \"AI_API_KEY\"}}\n---\n\n# CLAW Mining Skill\n\nMine $CLAW tokens on Ethereum mainnet using Proof of AI Work (PoAIW). The miner calls an AI API (e.g., xAI Grok), submits the result to an Oracle for verification, and the user receives CLAW tokens on-chain.\n\n**Compatible platforms**: OpenClaw (recommended), Hermes Agent, Perplexity Computer, or any AgentSkills-compatible agent.\n\n## When to Use This Skill\n\nUse when the user wants to:\n\n- Set up and run CLAW mining\n- Configure the miner with wallet, API keys, and contract addresses\n- Check mining status (cooldown, balance, epoch info)\n- Start single-cycle or automatic continuous mining\n- Troubleshoot mining errors (cooldown, gas, Oracle issues)\n\n## Security: Private Key Handling\n\n**CRITICAL — READ BEFORE PROCEEDING**\n\n- The `init` command optionally asks the user if they want to enter their private key. If they decline, the `.env` file is created with an empty `PRIVATE_KEY=` placeholder for them to fill in later. Either way, the choice is entirely the user's.\n- The agent MUST NOT ask the user to paste, share, or reveal their private key in conversation. Only the CLI's local `init` prompt handles this.\n- The `.env` file is created with `chmod 600` permissions (owner-only read/write).\n- At runtime, the miner reads `PRIVATE_KEY` from the environment, loads it into an in-memory `ethers.Wallet` object, and removes it from the config object immediately. The key is used only for local transaction signing and is never logged, transmitted, or sent to the Oracle, AI API, or any external service.\n- All transactions are signed locally by the miner process on the user's own computer.\n\n## Architecture Overview\n\n```\nMiner Engine (Node.js/TypeScript) — runs on user's local machine\n    │\n    ├── 1. Read chain state (Era, Epoch, Seed, Cooldown)\n    ├── 2. Check gas price (abort early if too high, saves API costs)\n    ├── 3. Request nonce from Oracle (format-validated)\n    ├── 4. Call AI API (grok-4.1-fast via xAI or OpenRouter)\n    ├── 5. Submit AI response to Oracle for verification + signing\n    ├── 6. Validate attestation (miner address, deadline, field integrity)\n    └── 7. Sign and send mint() transaction on-chain (LOCAL signing)\n             → CLAW tokens minted to miner's wallet\n```\n\nEach mining cycle takes ~30-60 seconds. After a successful mine, a cooldown of 3,500 blocks (~11.67 hours) must pass before the same address can mine again.\n\n## Contract Addresses (Mainnet v2)\n\n| Contract | Address |\n|----------|---------|\n| CLAW_Token | `0x4ba1209b165b62a1f0d2fbf22d67cacf43a6df2b` |\n| PoAIWMint | `0x511351940d99f3012c79c613478e8f2c887a8259` |\n| MinterProxy | `0xe7fc311863b95e726a620b07607209965ee72bce` |\n| OracleVerifier | `0xc24a0ba99b9ff6b7ccea6beb4013b69f39024fd5` |\n\nOracle URL: `https://oracle.minewithclaw.com`\n\n## Prerequisites\n\n| Requirement | Details |\n|-------------|---------|\n| Node.js | Version 20+ |\n| Ethereum wallet | A private key with ETH for gas (~0.01 ETH is enough for many mines) |\n| AI API key | xAI API key (recommended) or OpenRouter API key |\n| Ethereum RPC | Alchemy, Infura, or any mainnet RPC endpoint |\n| ETH for gas | ~0.0002 ETH per mine at 2 gwei gas price |\n\n## Step-by-Step Deployment Instructions\n\nFollow these steps in order. The agent collects only the AI API key and RPC URL from the user. The private key is set by the user directly — the agent never handles it.\n\n### Step 1: Obtain Credentials from the User\n\nAsk the user for these 2 items (they can provide them one at a time):\n\n1. **AI API Key** — from [console.x.ai](https://console.x.ai) (format: `xai-...`) or [openrouter.ai](https://openrouter.ai)\n2. **Ethereum RPC URL** — from [alchemy.com](https://www.alchemy.com) or [infura.io](https://infura.io) (format: `https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY`)\n\n**IMPORTANT about private key**: Do NOT ask the user for their private key. Instead, instruct them to set the `PRIVATE_KEY` environment variable themselves by editing the `.env` file directly. The agent never sees, handles, or stores the private key. Use a hot wallet with some ETH for gas — NOT their main wallet or Ledger.\n\n### Step 2: Clone and Install\n\n```bash\ngit clone https://github.com/Cliai21/clawing.git\ncd clawing/miner\nnpm install\n```\n\nVerify installation:\n\n```bash\nnpx tsx src/index.ts --version\n# Expected output: 1.0.0\n```\n\n### Step 3: Configure the .env File\n\nThe user creates the `.env` file in the `miner/` directory. There are two methods:\n\n#### Method A: Interactive Setup (Recommended)\n\nThe user runs this command in their terminal:\n\n```bash\nnpx tsx src/index.ts init\n```\n\nThis will prompt the user for AI API provider and API key. All other settings (Oracle URL, RPC, contract address, gas limit) use sensible built-in defaults. When prompted:\n- **AI API provider**: Choose `[1] xAI Direct` (recommended) or `[2] OpenRouter`\n- **Customize advanced settings?**: Press Enter for No (defaults are correct for mainnet)\n- **Enter private key now?**: The user chooses — they can enter it in the CLI or add it to `.env` later\n\nIf the user skipped the private key step, tell them to open `.env` and paste their `PRIVATE_KEY` on the designated line.\n\n#### Method B: Manual .env File\n\nInstruct the user to create the file manually. Show them the template below but tell them to fill in their own values directly — the agent must not handle `PRIVATE_KEY`:\n\n```bash\ncat > .env << 'EOF'\n# === Wallet ===\nPRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE\n\n# === AI API ===\n# Provider: xAI Direct (recommended)\nAI_API_KEY=xai-YOUR_KEY_HERE\nAI_API_URL=https://api.x.ai/v1/chat/completions\nAI_MODEL=grok-4-1-fast-non-reasoning\n\n# === Oracle ===\nORACLE_URL=https://oracle.minewithclaw.com\n\n# === Chain ===\nRPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_ALCHEMY_KEY\nPOAIW_MINT_ADDRESS=0x511351940d99f3012c79c613478e8f2c887a8259\n\n# === Mining Config ===\nMAX_GAS_PRICE_GWEI=3\nTASK_PROMPT=Write an extremely detailed, comprehensive, and thorough 2500-word academic analysis of decentralized proof-of-work systems, covering historical evolution, consensus mechanisms, game theory incentives, energy considerations, security models, and future outlook. Include specific technical details, mathematical reasoning, concrete examples, and citations to relevant research. Structure your response with clear sections and subsections.\nEOF\n```\n\n**CRITICAL**: Protect the file:\n\n```bash\nchmod 600 .env\n```\n\n#### Environment Variable Reference\n\n| Variable | Required | Default | Description |\n|----------|----------|---------|-------------|\n| `PRIVATE_KEY` | Yes | — | Mining wallet private key (0x-prefixed hex). Stays local, never transmitted. |\n| `AI_API_KEY` | Yes | — | xAI or OpenRouter API key |\n| `AI_API_URL` | No | `https://api.x.ai/v1/chat/completions` | AI chat completions endpoint |\n| `AI_MODEL` | No | `grok-4.1-fast` | Model name (must match on-chain Era model) |\n| `ORACLE_URL` | No | `https://oracle.minewithclaw.com` | Oracle verification server URL. **Must use HTTPS** in production (only localhost allowed over HTTP). |\n| `RPC_URL` | No | `https://eth.llamarpc.com` | Ethereum mainnet JSON-RPC endpoint. Free public RPC; replace with Alchemy/Infura for higher reliability. |\n| `POAIW_MINT_ADDRESS` | No | `0x511351940d99f3012c79c613478e8f2c887a8259` | PoAIWMint contract address |\n| `MAX_GAS_PRICE_GWEI` | No | `2` | Max gas price — auto-waits if exceeded. Must be a finite positive number. |\n| `TASK_PROMPT` | No | (built-in default) | Text prompt sent to AI model |\n\n#### AI Provider Options\n\n| Provider | AI_API_URL | AI_MODEL | Notes |\n|----------|-----------|----------|-------|\n| xAI Direct | `https://api.x.ai/v1/chat/completions` | `grok-4-1-fast-non-reasoning` | Recommended, lowest cost |\n| OpenRouter | `https://openrouter.ai/api/v1/chat/completions` | `x-ai/grok-4.1-fast` | Alternative, has markup |\n\n**Note on .env loading**: If the system does not use `dotenv` (e.g., on a deployed server), load environment variables manually before running:\n\n```bash\nset -a && source .env && set +a\n```\n\n### Step 4: Verify Configuration\n\n```bash\nnpx tsx src/index.ts status\n```\n\nExpected output shows:\n- Miner address and ETH balance\n- Current Era and Epoch\n- Cooldown status (Ready or blocks remaining)\n- Claim count (X/14 this epoch)\n- Oracle health (healthy)\n\nIf everything shows correctly, proceed to mining.\n\n### Step 5: Start Mining\n\n#### Single Mine (Test First)\n\n```bash\nnpx tsx src/index.ts mine\n```\n\nThis executes one mining cycle. If successful, you will see the CLAW reward and transaction hash.\n\n#### Automatic Continuous Mining (Recommended)\n\n```bash\nnpx tsx src/index.ts auto\n```\n\nThe `auto` command:\n- Mines whenever cooldown has elapsed\n- Automatically waits between cycles (~11.67 hours)\n- Pauses if gas exceeds `MAX_GAS_PRICE_GWEI`\n- Retries on errors with backoff\n- Press Ctrl+C to stop gracefully\n\n## CLI Commands Reference\n\n| Command | Description | Usage |\n|---------|-------------|-------|\n| `init` | Interactive setup — creates `.env` file | `npx tsx src/index.ts init` |\n| `status` | Show mining status, balance, cooldown | `npx tsx src/index.ts status` |\n| `mine` | Execute one mining cycle | `npx tsx src/index.ts mine` |\n| `auto` | Start continuous mining loop | `npx tsx src/index.ts auto` |\n\n## Mining Economics Quick Reference\n\n### Reward Formula\n\n```\nR = perBlock x (1 + ln(T))\n```\n\n- `perBlock`: Base reward for current Era (Era 1 = 100,000 CLAW)\n- `T`: AI tokens consumed (range: 100-100,000)\n\n### Era 1 Reward Examples\n\n| AI Tokens (T) | Reward per Mine |\n|----------------|-----------------|\n| 2,100 (minimum practical) | ~862,300 CLAW |\n| 5,000 | ~931,600 CLAW |\n| 10,000 | ~1,000,900 CLAW |\n\n### Key Limits\n\n| Parameter | Value |\n|-----------|-------|\n| Cooldown | 3,500 blocks (~11.67 hours) |\n| Max claims per Epoch | 14 per address |\n| Epoch duration | 50,000 blocks (~6.94 days) |\n| Era duration | 21 Epochs (~145 days) |\n| Total Eras | 24 (~9.6 years) |\n| Max supply | 210 billion CLAW |\n| Gas per mint | ~100k gas (~0.0002 ETH at 2 gwei) |\n\n### Cost-Efficiency Tip\n\nUse `T=2100` (minimum practical tokens). The reward formula is logarithmic — increasing T from 2,100 to 100,000 (47x more API cost) only increases reward by ~40%. Minimize AI API spend for maximum ROI.\n\n## Troubleshooting\n\n### Common Errors and Solutions\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `CooldownNotMet` | Mined too recently | Wait ~11.67 hours, or use `auto` mode |\n| `EpochClaimLimitReached` | 14 claims already this Epoch | Wait for next Epoch (~1 week) |\n| `Gas price exceeds limit` | Network gas too high | Wait, or increase `MAX_GAS_PRICE_GWEI` |\n| `Oracle nonce error` | Oracle rate limit or downtime | Wait 60 seconds and retry |\n| `AI API error: 401` | Invalid API key | Check `AI_API_KEY` in `.env` |\n| `AI API error: 429` | API rate limit | Wait and retry, or check API quota |\n| `InvalidSignature` | Oracle signing mismatch | Retry; if persistent, check Oracle status |\n| `Missing required environment variable` | `.env` not loaded | Run `set -a && source .env && set +a` first, or check `.env` file exists |\n| `EpochExhausted` | Epoch cap fully mined | Wait for next Epoch |\n\n### Checking Oracle Health\n\n```bash\ncurl https://oracle.minewithclaw.com/health\n# Expected: {\"status\":\"ok\", ...}\n```\n\n### Checking Wallet Balance\n\n```bash\nnpx tsx src/index.ts status\n```\n\nIf ETH balance is too low, send more ETH to the mining wallet address shown in the status output.\n\n## Security Audit Status (v2.1)\n\n15 issues identified and fixed (1 critical, 4 high, 5 medium, 5 low), 67 tests passing including 52 adversarial tests. Key protections:\n\n- **F-01**: Attestation miner_address verification — prevents reward redirection attacks\n- **F-02**: HTTPS enforcement for Oracle URL — prevents MITM attacks\n- **F-03**: Gas price input validation — prevents Infinity/NaN bypass\n- **F-05**: Nonce format regex validation — prevents prompt injection\n- **F-07**: Attestation field completeness checks — prevents null crashes\n- **F-08**: Private key removed from config object — reduces memory exposure risk\n- **F-12**: AI response body size limit (2MB) — prevents memory exhaustion\n\n## Project Links\n\n- GitHub: [https://github.com/Cliai21/clawing](https://github.com/Cliai21/clawing)\n- Oracle: [https://oracle.minewithclaw.com](https://oracle.minewithclaw.com)\n- Mining Guide: See `docs/MINING_GUIDE.md` in the repository\n- CLAW_Token on Etherscan: [0x4ba1209b165b62a1f0d2fbf22d67cacf43a6df2b](https://etherscan.io/address/0x4ba1209b165b62a1f0d2fbf22d67cacf43a6df2b)\n- PoAIWMint on Etherscan: [0x511351940d99f3012c79c613478e8f2c887a8259](https://etherscan.io/address/0x511351940d99f3012c79c613478e8f2c887a8259)\n","tags":{"latest":"1.0.3"},"stats":{"comments":0,"downloads":742,"installsAllTime":28,"installsCurrent":0,"stars":0,"versions":4},"createdAt":1773506459656,"updatedAt":1778999693700},"latestVersion":{"version":"1.0.3","createdAt":1773513512775,"changelog":"- Interactive setup flow improved: the `init` command now optionally prompts the user to enter their private key directly in the CLI, or to skip and fill it in later.\n- Default values added for several environment variables: `ORACLE_URL`, `RPC_URL`, and `POAIW_MINT_ADDRESS` now have built-in defaults for faster setup.\n- Advanced settings are now hidden behind an \"advanced\" prompt, streamlining the initial configuration for new users.\n- Security instructions clarified: agents must never handle or transmit the private key; this can only be set through the local CLI prompt or by editing `.env` directly.\n- Updated environment variable documentation to reflect new defaults, making setup more accessible to non-technical users.","license":"MIT-0"},"metadata":{"setup":[{"key":"AI_API_KEY","required":true},{"key":"PRIVATE_KEY","required":true},{"key":"RPC_URL","required":true},{"key":"POAIW_MINT_ADDRESS","required":true}],"os":null,"systems":null},"owner":{"handle":"minewithclaw","userId":"s172vz1xw38rmq3c9kec4jc7gd8853pa","displayName":"minewithclaw","image":"https://avatars.githubusercontent.com/u/189420301?v=4"},"moderation":{"isSuspicious":false,"isMalwareBlocked":false,"verdict":"clean","reasonCodes":["review.llm_review"],"summary":"Review: review.llm_review","engineVersion":"v2.4.24","updatedAt":1780089889700}}