7.5 KiB
Mining Setup for OpenClaw Agents
Level: Beginner
Prerequisites: Wallet Basics (Scenario 01), AITBC CLI installed
Estimated Time: 25 minutes
Last Updated: 2026-05-02
Version: 1.0
🧭 Navigation Path:
🏠 Documentation Home → 🎭 Agent Scenarios → You are here
breadcrumb: Home → Scenarios → Mining Setup
🎯 See Also:
- 📖 Previous Scenario: 12 Database Operations
- 📖 Next Scenario: 14 Staking Basics
- 🤖 Agent SDK: Agent SDK Documentation
- ⛏️ Mining: Mining Documentation
📚 Scenario Overview
This scenario demonstrates how OpenClaw agents set up and run mining operations on the AITBC blockchain to earn block rewards and secure the network.
Use Case
An OpenClaw agent needs mining to:
- Earn AIT tokens through block rewards
- Participate in network consensus
- Validate blockchain transactions
- Secure the AITBC network
- Generate passive income
What You'll Learn
- Start mining operations
- Configure mining parameters
- Monitor mining performance
- Manage mining rewards
- Handle mining failures
📋 Prerequisites
Knowledge Required
- Completed Scenario 01 (Wallet Basics)
- Understanding of blockchain mining
- Consensus mechanism basics
Tools Required
- AITBC CLI installed
- Python 3.13+
- Wallet for mining rewards
- Compute resources (CPU/GPU)
Setup Required
- Blockchain node running
- Wallet with sufficient balance
- Mining software installed
🔧 Step-by-Step Workflow
Step 1: Start Mining
Begin mining with your wallet.
aitbc mining start \
--wallet my-agent-wallet \
--threads 4
Output:
Mining started
Wallet: my-agent-wallet
Threads: 4
Status: active
Hash Rate: 25.2 MH/s
Step 2: Check Mining Status
Monitor your mining operations.
aitbc mining status --wallet my-agent-wallet
Output:
Mining Status: active
Hash Rate: 25.2 MH/s
Blocks Mined: 5
Total Rewards: 500 AIT
Uptime: 2h 30m
Step 3: Adjust Mining Parameters
Modify mining configuration.
aitbc mining config \
--wallet my-agent-wallet \
--threads 8 \
--difficulty-adjustment true
Step 4: Stop Mining
Halt mining operations.
aitbc mining stop --wallet my-agent-wallet
Step 5: View Mining History
Check past mining rewards.
aitbc mining history --wallet my-agent-wallet
💻 Code Examples Using Agent SDK
Example 1: Start Mining Programmatically
from aitbc_agent_sdk import Agent, AgentConfig
config = AgentConfig(
name="mining-agent",
blockchain_network="mainnet",
wallet_name="mining-wallet"
)
agent = Agent(config)
agent.start()
# Start mining
result = agent.start_mining(threads=4)
print(f"Mining started: {result['status']}")
print(f"Hash rate: {result['hash_rate']} MH/s")
Example 2: Monitor Mining Performance
from aitbc_agent_sdk import Agent, AgentConfig
import asyncio
async def monitor_mining():
config = AgentConfig(
name="mining-monitor",
blockchain_network="mainnet",
wallet_name="mining-wallet"
)
agent = Agent(config)
await agent.start()
# Start mining
await agent.start_mining(threads=4)
# Monitor performance
while True:
status = await agent.get_mining_status()
print(f"Hash Rate: {status['hash_rate']} MH/s")
print(f"Blocks Mined: {status['blocks_mined']}")
print(f"Rewards: {status['total_rewards']} AIT")
await asyncio.sleep(60)
asyncio.run(monitor_mining())
Example 3: Adaptive Mining
from aitbc_agent_sdk import Agent, AgentConfig
import asyncio
class AdaptiveMiner:
def __init__(self, config):
self.agent = Agent(config)
self.running = False
async def start(self):
await self.agent.start()
self.running = True
await self.adaptive_mining()
async def adaptive_mining(self):
"""Adjust mining based on network conditions"""
while self.running:
# Get network difficulty
network_stats = await self.agent.get_network_stats()
difficulty = network_stats['difficulty']
# Adjust threads based on difficulty
if difficulty > 1000000:
threads = 8 # High difficulty, more power
elif difficulty > 500000:
threads = 6
else:
threads = 4 # Low difficulty, save resources
# Update mining configuration
await agent.update_mining_config(threads=threads)
# Check profitability
rewards = await self.agent.get_mining_rewards()
cost = await self.calculate_mining_cost(threads)
if rewards < cost:
print("Mining not profitable, pausing...")
await self.agent.stop_mining()
await asyncio.sleep(300) # Wait 5 minutes
await self.agent.start_mining(threads=4)
await asyncio.sleep(60)
async def calculate_mining_cost(self, threads):
"""Calculate mining cost based on resources"""
# Simplified cost calculation
power_cost = threads * 0.01 # $ per hour per thread
return power_cost
async def main():
config = AgentConfig(
name="adaptive-miner",
blockchain_network="mainnet",
wallet_name="adaptive-wallet"
)
miner = AdaptiveMiner(config)
await miner.start()
asyncio.run(main())
🎯 Expected Outcomes
After completing this scenario, you should be able to:
- Start and stop mining operations
- Configure mining parameters
- Monitor mining performance
- Implement adaptive mining strategies
- Manage mining rewards
🧪 Validation
Validate this scenario with the shared 3-node harness:
bash scripts/workflow/44_comprehensive_multi_node_scenario.sh
Node coverage:
aitbc1: genesis / primary node checksaitbc: follower / local node checksgitea-runner: automation / CI node checks
Validation guide:
Expected result:
- Scenario-specific commands complete successfully
- Cross-node health checks pass
- Blockchain heights remain in sync
- Any node-specific step is documented in the scenario workflow
🔗 Related Resources
AITBC Documentation
External Resources
Next Scenarios
- 14 Staking Basics - Alternative to mining
- 26 Staking Validator Agent - Advanced staking
- 36 Autonomous Compute Provider - Mining + compute
📊 Quality Metrics
- Structure: 10/10 - Clear mining setup workflow
- Content: 10/10 - Comprehensive mining operations
- Code Examples: 10/10 - Working Agent SDK examples
- Status: Active scenario
Last updated: 2026-05-02
Version: 1.0
Status: Active scenario document