react-native-chainz
Version:
React Native wrapper for the CryptoID Blockchain Explorers API. Uses Fetch so it drops in neatly into any React Native App. In addition to Phore (PHR), it works for any Altcoin for which Chainz has a code. Sample commands include getting the balance of an
130 lines (75 loc) • 4.27 kB
JavaScript
const getPhoreBalance = function(address) {
return fetch(`https://chainz.cryptoid.info/phr/api.dws?q=getbalance&a=${address}`).then(function(response) { return response.json()});
}
const getAltBalance = function(altcoin, address) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=getbalance&a=${address}`).then(function(response) { return response.json()});
}
const getAddresses = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=addresses`).then(function(response) { return response.json()});
}
const getCirculating = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=circulating`).then(function(response) { return response.json()});
}
const getBlockcount = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=getblockcount`).then(function(response) { return response.json()});
}
const getDifficulty = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=difficulty`).then(function(response) { return response.json()});
}
const getHashrate = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=hashrate`).then(function(response) { return response.json()});
}
const getNethashps = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=nethashps`).then(function(response) { return response.json()});
}
const getNetMHashps = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=netmhashps`).then(function(response) { return response.json()});
}
const getRich = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=rich`).then(function(response) { return response.json()});
}
const getTotalcoins = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=totalcoins`).then(function(response) { return response.json()});
}
//ADDRESSES
const getAddressFirstSeen = function(altcoin, address) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=getbalance&a=${address}`).then(function(response) { return response.json()});
}
const getReceivedByAddress = function(altcoin, address) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=getbalance&a=${address}`).then(function(response) { return response.json()});
}
const getRichRank = function(altcoin, address) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=getbalance&a=${address}`).then(function(response) { return response.json()});
}
//BLOCKS
const getBlockhash = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=getblockhash`).then(function(response) { return response.json()});
}
const getBlockheight = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=totalcoins`).then(function(response) { return response.json()});
}
//TRANSACTIONS
const getLasttxs = function(altcoin) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=lasttxs`).then(function(response) { return response.json()});
}
const getTxinfo = function(altcoin, txHash) {
return fetch(`https://chainz.cryptoid.info/${altcoin}/api.dws?q=txinfo&t=${txhash}`).then(function(response) { return response.json()});
}
module.exports.getPhoreBalance = getPhoreBalance;
module.exports.getAltBalance = getAltBalance;
module.exports.getAddresses = getAddresses;
module.exports.getCirculating = getCirculating;
module.exports.getBlockcount = getBlockcount;
module.exports.getDifficulty = getDifficulty;
module.exports.getHashrate = getHashrate;
module.exports.getNethashps = getNethashps;
module.exports.getNetMHashps = getNetMHashps;
module.exports.getRich = getRich;
module.exports.getAddressFirstSeen = getAddressFirstSeen;
module.exports.getReceivedByAddress = getReceivedByAddress;
module.exports.getRichRank = getRichRank;
module.exports.getBlockhash = getBlockhash;
module.exports.getBlockheight = getBlockheight;
module.exports.getLasttxs = getLasttxs;
module.exports.getTxinfo = getTxinfo;
module.exports.getTotalcoins = getTotalcoins;