-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
generateFromCoingecko.js
59 lines (59 loc) · 1.35 KB
/
generateFromCoingecko.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// change this when using this file
const folder = 'src/tokens/arb';
const api = 'https://tokens.coingecko.com/arbitrum-one/all.json';
const fs = require('fs');
const fetch = require('node-fetch');
const web3 = require('web3');
fetch(api)
.then(res => res.json())
.then(data => {
const tokenTemp = {
symbol: '',
name: '',
type: 'ERC20',
address: '',
ens_address: '',
decimals: 0,
website: '',
logo: {
src: '',
width: '',
height: '',
ipfs_hash: ''
},
support: {
email: '',
url: ''
},
social: {
blog: '',
chat: '',
discord: '',
facebook: '',
forum: '',
github: '',
gitter: '',
instagram: '',
linkedin: '',
reddit: '',
slack: '',
telegram: '',
twitter: '',
youtube: ''
}
};
const tokens = data.tokens;
tokens.forEach(token => {
const checksummedAddress = web3.utils.toChecksumAddress(token.address);
const newToken = Object.assign({}, tokenTemp, {
address: checksummedAddress,
symbol: token.symbol,
name: token.name,
decimals: token.decimals
});
fs.writeFileSync(
`${folder}/${checksummedAddress}.json`,
JSON.stringify(newToken)
);
});
});