ABI to solidity interface converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// Credits: @rangelife | |
var fs=require('fs'); | |
try { | |
var abi=JSON.parse(fs.readFileSync(process.argv[3])); | |
} catch (e) { | |
dieUsage(); | |
} | |
var contractName=process.argv[2]; | |
if(!contractName) dieUsage(); | |
var toDump=""; | |
function dump(x) { | |
toDump += x; | |
} | |
dump("contract "+contractName); | |
dump("{"); | |
var i=0; | |
for(i=0;i<abi.length;i++) { | |
var entity=abi[i]; | |
if (!Array.isArray(entity.inputs)) { | |
die("entity inputs isn't an array in "+JSON.stringify(entity)); | |
} | |
switch (entity.type) { | |
case 'constructor': | |
dumpConstructor(entity); | |
break; | |
case 'function': | |
dumpFunction(entity); | |
break; | |
case 'event': | |
// these don't go in the interface file | |
break; | |
default: | |
die("Unknown entity type "+entity.type+" in ABI."); | |
} | |
} | |
dump("}"); | |
console.log(toDump); | |
/////////// | |
function die(x) { | |
console.error(x); | |
process.exit(1); | |
} | |
function dieUsage() { | |
die("Usage: "+process.argv[1]+" [contractName] [ABI file]"); | |
} | |
function dumpConstructor(entity) { | |
dump("function "+contractName+"("); | |
dumpArgs(entity.inputs); | |
dump(");"); | |
} | |
function dumpFunction(entity) { | |
dump("function "+entity.name+"("); | |
dumpArgs(entity.inputs); | |
dump(") "); | |
if (entity.constant) { | |
dump("constant "); | |
} | |
if (entity.outputs.length) { | |
dump("returns ("); | |
dumpArgs(entity.outputs); | |
dump(")") | |
} | |
dump(";"); | |
} | |
function dumpArgs(args) { | |
var i; | |
for (i=0;i<args.length;i++) { | |
var arg = args[i]; | |
if(i) dump(","); | |
dump(arg.type+" "+arg.name); | |
} | |
} |
Hi can you assist me?
You know I can assistance because I have the access of this contract, I can provide you the CoinMarketCap information and ethereum information to get all your access
Sry I just saw this. How do you mean?
…On Fri, Sep 23, 2022 at 1:52 AM Marykassman ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
You know I can assistance because I have the access of this contract, I
can provide you the CoinMarketCap information and ethereum information to
get all your access
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/8f533d133fa0c15b0d6eaf3ec502c82b#gistcomment-4312771>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIVSNK4XT3O6APUFATLKJILV7VOVNANCNFSM4234LWUQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello