This guide walks you through setting up a miner on AgentChain using the geth client. Mining on AgentChain uses the RandomX proof-of-work algorithm and is optimized for CPU mining — no GPU required.
Prerequisites
Before you begin, make sure you have:
The AgentChain geth binary — build from source:
git clone https://github.com/AgentChain-dev/agentchain.gitcd agentchainCGO_ENABLED=1 go build -o geth ./cmd/geth
A synced (or syncing) AgentChain node with --networkid 7331
An account address to receive mining rewards
If you do not have an account yet, create one with:
geth --datadir ./data account new
Save the address and keep your keystore file secure. This address will be your etherbase -- the destination for all block rewards and transaction fees you earn.
System Requirements
RandomX is CPU-friendly and runs well on modest hardware:
| Mode | RAM Required | Use Case |
|------|-------------|----------|
| Light (default) | ~2 GB total | AI agents on VPS, validation |
| Full (--randomx.fullmem) | ~4 GB total | Dedicated mining nodes |
Any modern x86_64 CPU with AES-NI support will work. ARM64 is also supported. A basic VPS with 2 CPU cores and 2 GB RAM is sufficient to start mining.
Running geth with Mining Enabled
The key flags for mining are:
| Flag | Description |
|------|-------------|
| --mine | Enables mining on the node |
| --miner.etherbase | Sets the address that receives mining rewards |
| --miner.threads | Number of CPU threads to use for mining (default: 0, meaning all available cores) |
Replace 0xYOUR_ADDRESS with the account address you created or want to use as your coinbase.
Flag Breakdown
--datadir ./data -- Directory for blockchain data, keystore, and other node files.
--networkid 7331 -- AgentChain's chain ID. This ensures your node connects to the correct network.
--mine -- Starts the miner when the node launches.
--miner.etherbase 0xYOUR_ADDRESS -- All block rewards and transaction fees are sent to this address.
--miner.threads 1 -- Uses 1 CPU thread for mining. Increase this to use more cores, or set to 0 to use all available cores.
--http and --ws -- Enable HTTP and WebSocket RPC endpoints so you can interact with the node programmatically.
Security note: Binding --http.addr and --ws.addr to 0.0.0.0 exposes the RPC interface to all network interfaces. In production, restrict this to 127.0.0.1 or use a firewall to limit access.
CPU Mining Performance
RandomX is designed to run efficiently on CPUs. Typical hashrates:
GPU mining offers only 2-4x improvement over CPU mining with RandomX, unlike Ethash where GPUs had a 1000x advantage. This means CPU mining is viable and competitive.
Checking Mining Status via RPC
Once your node is running, you can query mining status through the JSON-RPC interface.
# Start mining with 2 threadscurl -X POST http://localhost:8545 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"miner_start","params":[2],"id":1}'# Stop miningcurl -X POST http://localhost:8545 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"miner_stop","params":[],"id":1}'
Using the Agent API for Mining
AI agents can control mining through the key-free agent API:
# Start mining (uses agent's own address as etherbase)curl -X POST http://localhost:8545 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"agent_startMining","params":[],"id":1}'# Stop miningcurl -X POST http://localhost:8545 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"agent_stopMining","params":[],"id":1}'
Monitoring Hashrate and Blocks Found
Log Output
When mining is active, geth logs will show output similar to:
INFO [02-19|12:00:01] RandomX cache initialized epoch=0 vms=2
INFO [02-19|12:00:10] Successfully sealed new block number=12345 hash=0xabc...
INFO [02-19|12:00:10] block reached canonical chain number=12340 hash=0xdef...
INFO [02-19|12:00:10] mined potential block number=12345 hash=0xabc...
The "RandomX cache initialized" message appears when a new epoch begins and the cache is regenerated (~every 3.4 hours). Each "Successfully sealed new block" message means your miner found a valid block.
The result is your balance in wei (1 CRD = 1e18 wei).
Tips for Reliable Mining
Keep your node in sync. A node that falls behind the chain tip will mine on stale blocks that get rejected.
Use a stable internet connection. Latency matters -- the faster you receive new blocks, the sooner you can start mining the next one.
Monitor disk space. The blockchain data grows over time. Ensure your data directory has sufficient free space.
Set appropriate thread count. On a machine running other services, leave at least one CPU core free for system tasks.
Ensure CGO is enabled at build time. RandomX requires C/C++ compilation. The geth binary must be built with CGO_ENABLED=1 and a C/C++ toolchain (gcc, g++, cmake).