Miner API

The web3.geth.miner object exposes methods to interact with the RPC APIs under the miner_ namespace that are supported by the Geth client.

Methods

The following methods are available on the web3.geth.miner namespace.

GethMiner.make_dag(number)
  • Delegates to miner_makeDag RPC Method

Generate the DAG for the given block number.

>>> web3.geth.miner.make_dag(10000)
GethMiner.makeDAG(number)

Warning

Deprecated: This method is deprecated in favor of make_dag()

GethMiner.set_extra(extra)
  • Delegates to miner_setExtra RPC Method

Set the 32 byte value extra as the extra data that will be included when this node mines a block.

>>> web3.geth.miner.set_extra('abcdefghijklmnopqrstuvwxyzABCDEF')
GethMiner.setExtra(extra)

Warning

Deprecated: This method is deprecated in favor of set_extra()

GethMiner.set_gas_price(gas_price)
  • Delegates to miner_setGasPrice RPC Method

Sets the minimum accepted gas price that this node will accept when mining transactions. Any transactions with a gas price below this value will be ignored.

>>> web3.geth.miner.set_gas_price(19999999999)
GethMiner.setGasPrice(gas_price)

Warning

Deprecated: This method is deprecated in favor of set_gas_price()

GethMiner.start(num_threads)
  • Delegates to miner_start RPC Method

Start the CPU mining process using the given number of threads.

>>> web3.geth.miner.start(2)
GethMiner.stop()
  • Delegates to miner_stop RPC Method

Stop the CPU mining operation

>>> web3.geth.miner.stop()
GethMiner.start_auto_dag()
  • Delegates to miner_startAutoDag RPC Method

Enable automatic DAG generation.

>>> web3.geth.miner.start_auto_dag()
GethMiner.startAutoDag()

Warning

Deprecated: This method is deprecated in favor of start_auto_dag()

GethMiner.stop_auto_dag()
  • Delegates to miner_stopAutoDag RPC Method

Disable automatic DAG generation.

>>> web3.geth.miner.stop_auto_dag()
GethMiner.stopAutoDag()

Warning

Deprecated: This method is deprecated in favor of stop_auto_dag()