Appearance
cmu mine
cmu mine starts, stops and inspects mining on the node behind the session's active network, and routes block rewards to the session wallet. It is meant for a geth node with the miner API enabled, such as the CointMU server. The local DevNet started by cmu node start has no miner API; see DevNet and Geth.
Usage
bash
cmu mine <subcommand> [options]-v, --verbose is available globally; see Global Options.
Subcommands
| Subcommand | Description |
|---|---|
cmu mine start | Point the node's etherbase at the session wallet, then mine. |
cmu mine stop | Stop the node's miner. |
cmu mine status | Show mining state, hashrate, etherbase and the wallet balance. |
Requirements
Every subcommand needs an active session: the folder's .cmu-session, or else ~/.cmu-session (see Session File). cmu mine reads two plaintext fields from it:
| Field | Used for |
|---|---|
address | The etherbase mine start sets, and the wallet mine status and --watch report on. |
activeNetwork | The saved network whose RPC endpoint is called. Set it with cmu network use <name>. |
The encrypted key is never read, so no subcommand asks for a password. The address is whichever wallet cmu wallet use <name> last wrote into that session file.
INFO
cmu mine uses the saved network the session points at, not defaultNetwork in cmu.config.ts. A project that deploys to the server through cmu.config.ts still needs cmu network use <name> before cmu mine reaches the same node. See Which Network a Command Uses.
Without a session, every subcommand exits before contacting anything:
bash
error: mine start failed
no active session.
hint: run `cmu wallet use <name>` first, or `cmu wallet create --save <name>` and then `cmu wallet use <name>`.If the session's network has since been deleted from the saved list:
bash
error: mine status failed
network 'staging' is not saved.
hint: list saved networks with `cmu network list`, or add one with `cmu network save <url> --name <name>`.DevNet and Geth
Local DevNet (cmu node start) | Geth node with the miner API (e.g. Geth 1.10.26) | |
|---|---|---|
| How blocks are made | One block per transaction, automatically. | Only while a miner runs. |
miner_setEtherbase, miner_start, miner_stop | Not supported. | Supported. |
cmu mine start / cmu mine stop | Exit 1 with the error below. | Work. |
cmu mine status | Works; Mining and Hashrate read n/a. | Works. |
Against the DevNet, or any node that does not expose the miner API, start and stop explain why rather than failing with a raw provider error:
bash
Pinging http://127.0.0.1:8585...
Connected to 'local' (chain ID 1912).
Setting etherbase to 0xbc4671Dd2101BD2dC1334917eA18675f7fFC8dE2...
error: mine start failed
network 'local' has no miner_setEtherbase RPC, so mining cannot be controlled here.
hint: the local DevNet mines a block for each transaction by itself; `cmu mine` is for a geth node with the miner API enabled.cmu mine stop prints the same error naming miner_stop. "Not supported" means the node answered -32601 (method not found) or -32004, which is what the DevNet answers.
WARNING
The etherbase and the miner belong to the node, not to your session. cmu mine start moves the rewards of everyone mining on that node to your wallet, and cmu mine stop stops mining for everyone using it. Coordinate before running either against a shared server.
cmu mine start
Sets the node's etherbase to the session wallet and starts mining with one thread.
Usage
bash
cmu mine start
cmu mine start --watchOptions
| Flag | Description |
|---|---|
--watch | Keep watching mining progress after starting. Ctrl+C leaves the watch; mining continues. |
Behavior
- Reads
addressandactiveNetworkfrom the session file in effect. - Resolves
activeNetworkfrom the saved networks. - Checks that the endpoint answers within 3 seconds, the same check as
cmu deploy --ping. Since 1.7.2. - Calls
eth_miningandeth_coinbase. If the node is already mining to a different address, prints a warning and carries on. A node with no etherbase set yet counts as none, not as a failure. Since 1.7.1. - Sends
miner_setEtherbasewith the session address. - Sends
miner_startwith1, a single mining thread.
After the endpoint check, the JSON-RPC calls, in order:
| Call | Parameters |
|---|---|
eth_mining | none |
eth_coinbase | none |
miner_setEtherbase | ["<session address>"] |
miner_start | [1] |
Output
bash
Pinging http://127.0.0.1:18545...
Connected to 'geth' (chain ID 1912).
Setting etherbase to 0x70997970C51812dc3A010C7d01b50e0d17dc79C8...
Starting miner on geth...
Mining started.
Rewards are routed to 0x70997970C51812dc3A010C7d01b50e0d17dc79C8When the node is already mining to someone else, two lines come first:
bash
warning: this node is already mining to 0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc.
hint: starting moves its rewards to 0x70997970C51812dc3A010C7d01b50e0d17dc79C8. The etherbase is node-wide, and `cmu mine stop` stops mining for everyone.Errors
| Cause | Message |
|---|---|
| No session file in effect | no active session. |
| Session network no longer saved | network '<name>' is not saved. |
Node has no miner API | network '<name>' has no miner_setEtherbase RPC, so mining cannot be controlled here. |
| Node unreachable | RPC endpoint <url> is unreachable (timed out after 3000ms). |
An unreachable node fails in the endpoint check, before any miner call:
bash
Pinging http://127.0.0.1:18545...
error: mine start failed
RPC endpoint http://127.0.0.1:18545 is unreachable (timed out after 3000ms).
hint: check the node is running and the endpoint is correct - `cmu network list`.The message says timed out for every failure of the check, including a refused connection that fails at once. Since 1.7.2; before, cmu mine printed ethers' retry notice and its raw connection error.
INFO
A freshly started geth node with no local accounts has no etherbase until something sets one. Since 1.7.1 cmu mine start treats that as no etherbase and sets it to the session wallet, and cmu mine status shows Etherbase : none set. In 1.7.0 and older both commands failed on such a node with a raw could not coalesce error.
Watching Progress
With --watch, the command keeps polling the node after mining has started:
bash
Watching. Ctrl-C leaves the watch - mining keeps running until `cmu mine stop`.
The first block can take minutes while ethash builds its DAG.
Balance change counts block rewards, uncle rewards and fees, plus any transfer in or out.
#34 hashrate 0 H/s mined by you since #34: 0 balance 1024.0 ETH (change +0.0)
block #36 mined by you.
#36 hashrate 0 H/s mined by you since #34: 1 balance 1026.0 ETH (change +2.0)The status line shows the head block, the hashrate, how many blocks the session wallet mined since the watch started, and its balance with the change since then. The node is polled about every 4 seconds.
Since 1.7.0 the balance is labelled with the session network's coin symbol. The example shows ETH because its geth network was saved without --symbol. Saved with --symbol CMU, the same line reads balance 1026.0 CMU (change +2.0).
| Output | Behavior |
|---|---|
| Terminal | The status line is redrawn in place; events print above it. |
| Pipe or file | One line per event, and the status line only when it changes. |
Events are printed once, when they happen:
| Event | Meaning |
|---|---|
block #<n> mined by you. | A new block whose miner is the session wallet. |
reorg: blocks from #<n> were replaced; the count is redone. | The chain reorganised; blocks are counted again. |
warning: etherbase changed: rewards now go to 0x..., not your wallet. | Someone moved the node's etherbase. |
etherbase is back on your wallet: rewards go to 0x... again. | The etherbase returned to the session wallet. |
warning: mining stopped - someone ran `cmu mine stop`, or the node stopped its miner. | The node's mining flag turned off. |
mining resumed. | The node's mining flag turned back on. |
connection lost (<reason>), retrying in <n>s | A poll failed. Retries back off from 4 to 60 seconds. |
reconnected. | A poll succeeded after a failure. |
A lost connection never ends the watch, so it survives a node restart. Ctrl+C leaves the watch and exits 0, and mining keeps running:
bash
Stopped watching. Mining is still running on geth - stop it with `cmu mine stop`.INFO
The count only covers blocks after the watch started, and a single poll fetches at most 100 missed blocks. The hashrate comes from eth_hashrate and can read 0 H/s while the node is mining; the block count is the reliable signal.
cmu mine stop
Stops the node's miner. The etherbase is left as it is.
Usage
bash
cmu mine stopBehavior
- Reads
activeNetworkfrom the session file in effect and resolves it from the saved networks. - Sends
miner_stopwith no parameters.
The node is not asked whether it was mining first, so stopping an idle node still succeeds and prints the same output.
Output
bash
Pinging http://127.0.0.1:18545...
Connected to 'geth' (chain ID 1912).
Stopping miner on geth...
Mining stopped.cmu mine status
A one-shot, read-only view of the node's mining state. It sends no miner_* call and changes nothing.
Usage
bash
cmu mine statusBehavior
After the same endpoint check as cmu mine start, the command reads the latest block, then in parallel eth_mining, eth_hashrate, eth_coinbase, and the session wallet's balance at that same block.
Output
bash
Pinging http://127.0.0.1:18545...
Connected to 'geth' (chain ID 1912).
--- Mining status ---
Network : geth (http://127.0.0.1:18545)
Mining : yes
Hashrate : 0 H/s
Etherbase : 0x70997970c51812dc3a010c7d01b50e0d17dc79c8
Latest block : #95, 1s ago
Difficulty : 131776
Wallet : 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
Balance : 1142.999999999631051 ETH
---------------------When the node mines to another address, the Etherbase line says so:
bash
Etherbase : 0x70997970c51812dc3a010c7d01b50e0d17dc79c8 (not your session wallet - rewards go there)| Field | Source |
|---|---|
Network | The session's active network and its RPC endpoint. |
Mining | eth_mining: yes, no, or n/a when the node does not support it. |
Hashrate | eth_hashrate, scaled to H/s … TH/s, or n/a. |
Etherbase | eth_coinbase. none set when the node has no etherbase yet; n/a when the node has no miner API, such as the DevNet. Marked (not your session wallet - rewards go there) when it differs. |
Latest block | Number and age of the latest block. Ages are shown in s, m, h or, since 1.7.2, d. |
Difficulty | The latest block's difficulty. |
Wallet | The session address. |
Balance | The session wallet's balance at the latest block, labelled with the network's coin symbol, or ETH when it has none. Since 1.7.0; before, always ETH. |
Against the DevNet the miner fields read n/a:
bash
Pinging http://127.0.0.1:8585...
Connected to 'local' (chain ID 1912).
--- Mining status ---
Network : local (http://127.0.0.1:8585)
Mining : n/a
Hashrate : n/a
Etherbase : n/a
Latest block : #0, 16s ago
Difficulty : 0
Wallet : 0xbc4671Dd2101BD2dC1334917eA18675f7fFC8dE2
Balance : 100.0 CMU
---------------------CMU is the symbol of local in a ~/.cmu-networks.json created by 1.7.0. A local saved by an older cmu shows ETH until it is given a symbol.
The DevNet answers eth_coinbase with a fixed placeholder address that no reward ever goes to, so since 1.7.2 Etherbase reads n/a whenever Mining does. In 1.7.0 and 1.7.1 it printed the placeholder, marked rewards go there.
Related Commands
- cmu wallet use — makes a wallet the session wallet whose address
cmu minemines to. - cmu network use — points the session, and so
cmu mine, at a saved network. - cmu wallet transfer — on a geth node, transfers only confirm while something mines.