1. Go to this page and download the library: Download openclerk/mining-pools library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
openclerk / mining-pools example snippets
use \DiscoveredComponents\Currencies;
use \Openclerk\Currencies\Currency;
use \Openclerk\Currencies\CurrencyFactory;
class DiscoveredCurrencyFactory implements CurrencyFactory {
/**
* @return a {@link Currency} for the given currency code, or {@code null}
* if none could be found
*/
public function loadCurrency($cur) {
if (Currencies::hasKey($cur)) {
return Currencies::getInstance($cur);
}
return null;
}
}
use \Monolog\Logger;
$logger = new Logger("log");
$factory = new DiscoveredCurrencyFactory();
$instance = new Account\MiningPool\Slush();
print_r($instance->fetchSupportedCurrencies($factory, $logger));
// returns ['btc', 'nmc']
use \Monolog\Logger;
$logger = new Logger("log");
$factory = new DiscoveredCurrencyFactory();
$instance = new Account\MiningPool\Slush();
$account = array(
'api_token' => '270245-e26365e4ca8f97ddde8c76a23ec18758',
);
$balances = $instance->fetchBalances($account, $factory, $logger);
echo $balances['btc']['confirmed']; // in BTC
echo $balances['btc']['unconfirmed'];
echo $balances['btc']['estimated'];
echo $balances['btc']['hashrate']; // in MH/s
echo $balances['nmc']['confirmed']; // in NMC
echo $balances['nmc']['unconfirmed'];
echo $balances['nmc']['estimated'];
echo $balances['nmc']['hashrate']; // in MH/s