Bitcoin Forum
May 05, 2024, 12:52:50 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Reward/bounty for some PHP help on a bitcoin profit calculator  (Read 2166 times)
cloverme (OP)
Legendary
*
Offline Offline

Activity: 1512
Merit: 1054


SpacePirate.io


View Profile WWW
February 24, 2014, 10:09:41 PM
 #1

Hi,

Sorry in advance if this is in the wrong forum (also if I'm breaking any rule or protocol here).  I'm working on integrating a bitcoin calculator into my website and I need some help factoring in the difficulty increase. I'm more a c# developer and not much of a PHP developer.  Anyway, if you get it to work how I'd like it to work, I'll send you 0.1 BTC as a reward/bounty for doing this for me.

Here's what I'd like it to do:
-Have difficulty as a set variable (such as 28%) in the code ($difficultyPercent = 0.28) etc
-Factor in difficulty for the monthly and yearly estimates (everyone seems to use 28% every 9 or 11 days)

So as an example, for 1.3 Th/s the output would show yearly about ~10 BTC rather than ~76 BTC

Current output looks like this with no difficulty adjustment (for 1.3Th/s):
Bitcoins per Year: 76.30313052
Bitcoins per Month: 6.27555384
Bitcoins per Week: 1.46234610
Bitcoins per Day: 0.20890659

Would like the output to be adjusted for difficulty like so after factoring in the difficulty increase:
Bitcoins per Year: 10.xxxxxxx
Bitcoins per Month: 4.xxxxxxx
Bitcoins per Week: 2.xxxxxxx
Bitcoins per Day: 0.2xxxxxxx

You can check your proof of work here using this calc: http://aleks1k.github.io/bitcoin-calculator/


Code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://blockexplorer.com/q/getdifficulty");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$difficulty = curl_exec($ch);
$hashRate = 1300000000;
$blockCoins = 25.00;

$day1 = "86,400";
$share =  $day1 / ($difficulty * 2^32 / $hashRate);
$hashTime = ((float) $difficulty) * (pow(2.0, 32) / ($hashRate * 1000.0)) ;
$blocksPerYear  = (365.25 * 24.0 * 3600.0) / $hashTime ;
$blocksPerMonth = (30.04 * 24.0 * 3600.0) / $hashTime;
$blocksPerWeek  = (7.0 * 24.0 * 3600.0) / $hashTime;
$blocksPerDay   = (24.0 * 3600.0) / $hashTime;
$coinsPerYear   = number_format($blockCoins * $blocksPerYear, 8);
$coinPerMonth = number_format($blockCoins * $blocksPerMonth, 8);
$coinPerWeek = number_format($blockCoins * $blocksPerWeek, 8);
$coinPerDay = number_format($blockCoins * $blocksPerDay, 8);
echo "Bitcoins per Year: ".$coinsPerYear."<br>";
echo "Bitcoins per Month: ".$coinPerMonth."<br>";
echo "Bitcoins per Week: ".$coinPerWeek."<br>";
echo "Bitcoins per Day: ".$coinPerDay."<br>";

Thanks Smiley

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!