I want to know about how can i get ethereum blockchain network hash rate via geth console or web3.
Like the result of this api - https://www.etherchain.org/api/miningEstimator


The way of deriving the information can be found here. So via the console,

function getNetworkStats(
        sampleSize //!< [in] Larger n give more accurate numbers but with longer latency.
    ) {
    blockNum = eth.blockNumber; // Save this value to atomically get a block number.
    blockTime = (eth.getBlock(blockNum).timestamp - eth.getBlock(blockNum - sampleSize).timestamp) / sampleSize;
    difficulty = eth.getBlock(blockNum).difficulty; // You can sum up the last n-blocks and average; this is mathematically sound.

    return {
      "blocktime": blockTime,
      "difficulty": difficulty,
      "hashrate": difficulty / blockTime,

Values are in seconds, hashes, and hashes per second, respectively.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.