2

I have the address and ABI of a contract. I can also view the bytecode from that address on Etherscan but not the source code. Is it possible to get the contract source code using these information?

2 Answers 2

0

In general - no. Only bytecode is stored on the blockchain so you won't get it unless the author made it available by other means.

Etherscan's source verification is one way for the author to do that. You could also check the Sourcify contract repository to see if the contract metadata was uploaded there.

Other than that, if the project is open-source, you'll likely find the source repository on github or gitlab. In that case, however, you'll need to verify it manually to be sure it matches the bytecode deployed at that address - you can do that by compiling it locally and diffing the resulting bytecode.

0

You can decompile the code using a tool, but the output will not be what the input was, and is usually pretty far off. I believe etherscan has a tool to do this for contracts that are not verified. However, this can still give you some idea of what is going on inside the contract.

In terms of getting the exact source code, no. Unless the author makes it public somewhere, you will not be able to see it.

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.