Last active
March 6, 2022 21:17
-
-
Save hesido/8f016624cbcef105f1bd819786df69a6 to your computer and use it in GitHub Desktop.
Google Spreadsheet Script To Get Mining Pool Balances - for Flexpool and Ethermine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.