Skip to content

Instantly share code, notes, and snippets.

@cicrijerzs
Created August 17, 2017 17:13
Show Gist options
  • Save cicrijerzs/1171b664853d0ff46fe3c5fc65b11615 to your computer and use it in GitHub Desktop.
Save cicrijerzs/1171b664853d0ff46fe3c5fc65b11615 to your computer and use it in GitHub Desktop.
Bitcoin Cash mining calculator
#!/usr/bin/python
import urllib2,simplejson,sys
# usage python cashmine.py <ths>
# example to calculate bitcoin cash earning for 14 ths, python cashmine.py 14
def calc():
usd = simplejson.load(urllib2.urlopen("https://api.coinmarketcap.com/v1/ticker/bitcoin-cash/"))[0]["price_usd"]
month_bcc = (30* int(sys.argv[1]) * 1e12 * 12.5 * 86400) / (simplejson.load(urllib2.urlopen("https://cashexplorer.bitcoin.com/api/status?q=getDifficulty"))["difficulty"]*2**32)
print "[*]Bitcoin Cash mining calculator using %s ths" %sys.argv[1]
print "[*]Difficulty changes every 2016 blocks, 2 weeks"
print
print "Hour: %f bcc ||-> %.2f usd" %(month_bcc / 30 / 24, float(usd) * month_bcc / 30 / 24)
print "Day: %f bcc ||-> %.2f usd" %(month_bcc / 30 , float(usd) * month_bcc / 30 )
print "Week: %f bcc ||-> %.2f usd" %(month_bcc / 30 * 7, float(usd) * month_bcc / 30 * 7)
print "Month: %f bcc ||-> %.2f usd" %(month_bcc, float(usd) * month_bcc)
if __name__ == '__main__':
calc()
@kelliecolonna5
Copy link

I

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment