-
Notifications
You must be signed in to change notification settings - Fork 0
/
getabi.js
31 lines (29 loc) · 1 KB
/
getabi.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
var request = require('request');
var cheerio = require('cheerio');
var entities = require('html-entities').AllHtmlEntities;
function getInfo(err, res, body) {
var $ = cheerio.load(body);
var abi = JSON.parse(entities.decode($("#js-copytextarea2").html()));
for (var i in abi) {
//console.log(abi[i]);
if (abi[i].type == "function") {
var func = abi[i];
console.log("----------------------------------------------");
console.log("function " + func.name + " (");
for (var j in func.inputs)
console.log(" "
+ func.inputs[j].type + " "
+ func.inputs[j].name
+ ((j == func.inputs.length - 1) ? "" : ", "))
console.log(") returns (");
for (var j in func.outputs)
console.log(" "
+ func.outputs[j].type + " "
+ func.outputs[j].name
+ ((j == func.outputs.length - 1) ? "" : ", "))
console.log(")");
console.log("----------------------------------------------\n\n");
}
}
}
request("http://etherscan.io/address/" + process.argv[2] + "#code", getInfo);