-
Notifications
You must be signed in to change notification settings - Fork 29
/
cryptaur.js
27 lines (23 loc) · 890 Bytes
/
cryptaur.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* @title Cryptaur
* @symbol CPT
* @ethContractAddr 0x88d50B466BE55222019D71F9E8fAe17f5f45FCA1
* @implementation Dynamic
* @cmcId cryptaur
*/
module.exports = (callback, request) => {
request('http://api.ethplorer.io/getTokenInfo/0x88d50B466BE55222019D71F9E8fAe17f5f45FCA1?apiKey=freekey', (error, response, body) => {
if (!error && response.statusCode == 200) {
body = JSON.parse(body);
var resp = {
t: Number(body.totalSupply) * Math.pow(10, -8)
};
if (typeof body.price !== 'undefined' && typeof body.price.availableSupply !== 'undefined') {
resp.c = Number(body.price.availableSupply);
}
callback(resp);
} else {
callback(new Error('Request error ' + typeof response !== 'undefined' ? response.statusCode : error));
}
});
};