Skip to content

Instantly share code, notes, and snippets.

@hesido
Last active March 6, 2022 21:17
Show Gist options
  • Save hesido/8f016624cbcef105f1bd819786df69a6 to your computer and use it in GitHub Desktop.
Save hesido/8f016624cbcef105f1bd819786df69a6 to your computer and use it in GitHub Desktop.
Google Spreadsheet Script To Get Mining Pool Balances - for Flexpool and Ethermine
/**
* Returns Balance From Flexpool api v2
*
* @param {string} account (required)
* @return {number} Amount in balance
* @customfunction
**/
function FlexPoolBalance(account) {
let Result = 0;
coinType = "eth";
let APIUrls = {
"eth": "https://api.flexpool.io/v2/miner/balance?coin=eth&address=",
};
if(typeof account !== 'undefined') {
let PoolResponse = JSON.parse(UrlFetchApp.fetch(APIUrls[coinType || "eth"] + account).getContentText());
Result = (PoolResponse["result"]["balance"] || 0);
} else {
throw new Error("No Account Specified");
}
return Result;
}
/**
* Returns Balance From EtherMine api
*
* @param {string} account (required)
* @param {string} coinType (optional)
* @return {number} Amount in balance
* @customfunction
**/
function EtherMineBalance(account, coinType) {
coinType = coinType || "eth";
let APIUrls = {
"eth": "https://api.ethermine.org/miner/",
"etc": "https://api-etc.ethermine.org/miner/"
};
if(typeof account !== 'undefined') {
let PoolResponse = JSON.parse(UrlFetchApp.fetch(APIUrls[coinType || "eth"] + account + "/dashboard").getContentText());
Result = (PoolResponse["data"]["currentStatistics"]["unpaid"] || 0) + (PoolResponse["data"]["currentStatistics"]["unconfirmed"] || 0);
} else {
throw new Error("No Account Specified");
}
return Result;
}
@hesido
Copy link
Author

hesido commented Aug 30, 2021

This is incorrectly flagged as a virus by Windows defender, however, as one can easily see this is nothing more than a Google spreadsheet javascript. You do not have to download it, just copy and paste the script to your Google Spreadsheet script editor.

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