2

If I have the address of the solidity contract, can I from that address determine the source code and the ABI?

I mean by this, is there a function to call in etherscan or something like that?

marked as duplicate by eth Aug 31 '18 at 6:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

Yes, both are documented here: https://etherscan.io/apis#contracts.

In short, to get the ABI:

https://api.etherscan.io/api?module=contract&action=getabi&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken

and to get the source code:

https://api.etherscan.io/api?module=contract&action=getsourcecode&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken
  • Does this to be be verified? I guessed that would be possible. But I am dynamically deploying code so the contracts will not be verified. – Trevor Lee Oakley Aug 30 '18 at 15:58
  • 1
    I'm a bit confused about your scenario. You're the one deploying the code, but you don't have the source code and ABI? Certainly Etherscan can't tell you the source code if no one has given Etherscan the source code. :-) – smarx Aug 30 '18 at 16:10
  • No, my UI, but the users write their own code from generated options. They do not write the solidity but generate it. But I do not see the code itself directly. I can store it off chain, but I wondered if ethereum had a option for this. I guess not. – Trevor Lee Oakley Aug 30 '18 at 16:58
  • @TrevorOakley if you see the code, then just run it trough solc and get the abi methods array – Nulik Aug 30 '18 at 17:07
  • Yes of course, I understand that can be done. Thanks. – Trevor Lee Oakley Aug 30 '18 at 18:03

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