1

Is it possible to get an ABI from the source code without using solc compiler? Like I can get source code of verified contracts through etherscan API and I want to convert it into ABI.

Are there any ways to do this with ether.js or web3.js? Or any other way?

Thank you.

1 Answer 1

1

In theory, you could create your own code that creates the ABI of a contract given the source code of that contract, reading the function's name and parameters and producing a javascript/JSON output, but you would be reinventing the wheel since you would be implementing something similar to a compiler.

Web3js and Ethersjs don't do this.

You could put the contract source code in Remix and compile it and get the source code. But I guess this is not what you want since it will use solc.

You could create a tool in, like, nodejs to programmatically handle the abi generation given some contract code base, using 'solc' under the hood, but adding more functionality, like receiving source code of contracts dynamically and compiling it, taking the abi and returning it, etc. Like a backend, like Etherscan and Remix do.

Check out this project: https://github.com/smartcontractkit/solc-api

1
  • 1
    I guess that is the only way. Thanks for your time.
    – Ad-h0c
    Sep 7, 2022 at 3:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.