Ethereum Classic Difficulty Formula

Christian Seberino, Ph.D.
3 min readDec 30, 2018

--

The Ethereum Classic (ETC) difficulty is the likely number of hashes a miner will have to calculate to add the next block on the blockchain. Adjustments to the difficulty lead to blocks being added on average about every ten seconds. I will describe how the difficulty is calculated.

Formula

The difficulty of the first (genesis) block is 131,072. The difficulty of future blocks is found using the following formula:

max(131072, Dₚ + max(1 - ΔT // 10, -99) · (Dₚ // 2048))

Dₚ is the difficulty of the previous block (parent), ΔT is the difference in seconds of the creation time from the parent, and, // denotes integer division. Notice the difficulty is never less than that of the genesis block. Notice also there is no change in the difficulty when ΔT is ten seconds. The most the difficulty can ever increase in one block is Dₚ // 2048. The most the difficulty can ever decrease in one block is -99 Dₚ // 2048.

Code

Here is Python code to calculate the difficulty of future blocks:

def difficulty(Dp, dT):
"""
Calculates the difficulty of blocks. Dp is the difficulty
of the parents. dT the difference in seconds of the
creation times from the parents.
"""
return max(131072,
Dp + max(1 - dT // 10, -99) * (Dp // 2048))

Example

Here is the difficulty calculation for block 7,190,125. Notice the difficulty is unchanged:

>>> print(hex(difficulty(0x79f80be54f05, 10)))
0x79f80be54f05

Here is the difficulty calculation for block 7,006,084. Notice the difficulty increases:

>>> print(hex(difficulty(0x7ed4865d8c48, 1)))
0x7ee460ee57f9

Here is the difficulty calculation for block 7,116,610. Notice the difficulty decreases:

>>> print(hex(difficulty(0x709d39938c3e, 72)))
0x7048c3a85d98

Conclusion

The difficulty formula adjusts the mining process so that blocks are added to the ETC blockchain on average about every ten seconds. Hopefully this elaboration filled any missing pieces in your understanding.

Feedback

Feel free to leave any comments or questions below. You can also contact me by email at cs@etcplanet.org or by clicking any of these icons:

Acknowledgements

I would like to thank IOHK (Input Output Hong Kong) for funding this effort.

License

This work is licensed under the Creative Commons Attribution ShareAlike 4.0
International License.

--

--

Christian Seberino, Ph.D.

My goal is to serve the Ethereum Classic, Ethereum and related blockchain communities with educational materials including writings, podcasts, talks and videos.