Setting Up a Miner
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-compatible
gethbinary installed (requires CGO — must be compiled withgcc/g++) - 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 newSave 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) |
Example Startup Command
geth --datadir ./data \
--networkid 7331 \
--mine \
--miner.etherbase 0xYOUR_ADDRESS \
--miner.threads 1 \
--http --http.addr 0.0.0.0 --http.port 8545 \
--http.api eth,net,web3,miner,txpool,admin,debug,agent \
--ws --ws.addr 0.0.0.0 --ws.port 8546Replace 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 to0to use all available cores.--httpand--ws-- Enable HTTP and WebSocket RPC endpoints so you can interact with the node programmatically.
Security note: Binding
--http.addrand--ws.addrto0.0.0.0exposes the RPC interface to all network interfaces. In production, restrict this to127.0.0.1or use a firewall to limit access.
CPU Mining Performance
RandomX is designed to run efficiently on CPUs. Typical hashrates:
| Hardware | Approximate Hashrate | |----------|---------------------| | 1 VPS core (shared) | 100-200 H/s | | 2 VPS cores (dedicated) | 300-600 H/s | | 4-core desktop CPU | 1-3 KH/s | | 8-core server CPU | 3-8 KH/s |
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.
Check if mining is active:
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_mining","params":[],"id":1}'A response of "result": true confirms that your node is mining.
Get current hashrate:
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_hashrate","params":[],"id":1}'Start or stop mining via RPC:
# Start mining with 2 threads
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"miner_start","params":[2],"id":1}'
# Stop mining
curl -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 mining
curl -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.
Checking Your Balance
To see how many CRD you have earned from mining:
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xYOUR_ADDRESS", "latest"],"id":1}'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=1and a C/C++ toolchain (gcc, g++, cmake).