forked from DeltaBalances/DeltaBalances.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallTokens.html
More file actions
83 lines (58 loc) · 1.9 KB
/
allTokens.html
File metadata and controls
83 lines (58 loc) · 1.9 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Bootstrap meta tags -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Delta Balances</title>
<!-- Bootstrap js -->
<script type="text/javascript" src="js/jquery.tablesorter.combined.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- Bootstrap, bootstrap-theme, fontawesome & custom css -->
<link href="css/combinedStyles.css" rel="stylesheet">
</head>
<body >
A quick script to get all different tokens currently in the etherdelta contract with the Ethplorer api.
<script>
function GetTokens()
{
uniqueTokens = {};
$('#output').html('loading from ethplorer api (slow)');
$.getJSON('https://api.ethplorer.io/getAddressInfo/0x8d12A197cB00D4747a1fe03395095ce2A5CC6819?apiKey=freekey', (result) => {
if(result && result.tokens)
{
for(let i = 0; i < result.tokens.length; i++)
{
let tok = result.tokens[i].tokenInfo;
if(!uniqueTokens[tok.address] && tok.symbol && result.tokens[i].balance > 1)
{
uniqueTokens[tok.address] = {addr: tok.address, name: escapeHtml(tok.symbol), decimals:tok.decimals, unlisted:true};
}
}
let allTokens = Object.values(uniqueTokens);
let jsonString = JSON.stringify(allTokens);
$('#output').html(jsonString);
} else {
$('#output').html('loading failed');
}
});
}
function escapeHtml(text) {
var map = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": ''',
"{": '',
"}": '',
};
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
}
</script>
<button id ="getbutton" onclick="GetTokens()">GetTokens</button>
<div id="output">
</div>
</body>
</html>