Closed drhus closed 5 years ago
Hi and welcome, we can delete this line if I remember it's the old line for the Market sheet
script for wallet(etherscan, blockchain.info) would be cool for ppl who dont use centralized exchanges, or is there already?
I think you need this for cold wallets https://github.com/LesterCovax/crypto-sheets
I haven't tested this much, but I wrote this a while back. You can use it like =getWalletBalance("ETH", "address")
function getWalletBalance(coin, address){
if(coin == "BTC"){ var response = UrlFetchApp.fetch("https://bitaps.com/api/address/"+address); response = JSON.parse(response.getContentText()); var balance = response.confirmed_balance; var balanceString = JSON.stringify(balance); var convert = balanceString.length;
if(convert <= 8){
for(i = convert; i < 8; i++){
balanceString = "0"+balanceString;
}
balanceString = "0."+balanceString;
}
else{
balanceString = balanceString.substring(0, convert - 8)+"."+balanceString.substring(convert - 8, convert);
}
balanceString = parseInt(balanceString, 10);
return balanceString;
} else if(coin == "ETH"){
var response = UrlFetchApp.fetch("https://api.ethplorer.io/getAddressInfo/"+address+"?apiKey=freekey");
response = JSON.parse(response.getContentText());
response = JSON.stringify(response);
response = parseInt(response, 10);
return response;
} else if(coin == "GIN"){ var response = UrlFetchApp.fetch("https://explorer.gincoin.io/ext/getbalance/"+address); response = JSON.parse(response.getContentText()); response = JSON.stringify(response); response = parseInt(response, 10); return response; }
var erc20Tokens = UrlFetchApp.fetch("https://raw.githubusercontent.com/kvhnuke/etherwallet/mercury/app/scripts/tokens/ethTokens.json"); erc20Tokens = JSON.parse(erc20Tokens.getContentText());
for (j=0; j < erc20Tokens.length; j++){ if(erc20Tokens[j].symbol == coin){ var response = UrlFetchApp.fetch("https://api.ethplorer.io/getAddressInfo/"+address+"?apiKey=freekey"); response = JSON.parse(response.getContentText()); response = response.tokens;
// [{balance=6.0261038102197996E18, totalIn=0, totalOut=0, tokenInfo={owner=0x000000000000000000000000000000000000dead, symbol=OMG, lastUpdated=1524187729, holdersCount=602237, address=0xd26114cd6ee289accf82350c8d8487fedb8a0c07, totalIn=6.9789611135704E26, totalSupply=140245398245132780789239631, price={marketCapUsd=1618639773.0, rate=15.8624, availableSupply=102042552.0, volume24h=126697000.0, diff=5.19, currency=USD, diff7d=23.43, ts=1524188053}, decimals=18, name=OMGToken, issuancesCount=0, totalOut=6.9789611135704E26}},
for(var x in response){
var tokenInfo = response[x].tokenInfo;
var symbol = tokenInfo.symbol;
if(tokenInfo.symbol == coin){
var balanceString = response[x].balance;
}
}
}
balanceString = parseInt(balanceString, 10);
return balanceString;
} }
No update. I close this issue
https://github.com/ManuCart/Cryptocurrency-Portfolio/blob/f62cef4479ecf0b0b0ed4015ba504220675dbb2c/main.js#L65