35

is there a way with web3.js to get a contract abi json, knowing only the contract address?

I cannot find anymore a link in wich they explain how to do this, in this post the guy replied telling that there is a way to do this but it's not so well documented.

How can I do this?

2

4 Answers 4

21

a) you know the source code of smart-contract

programmatically: see the link to gist from Ivan's answer

manually: with Remix

b) you don't know the source code but smart-contract was verified in one of the explorers

Then, use block explorer search to get ABI of smart-contract. For example, you can read the verified source code of smart-contracts in BlockScout, Etherscan, Etherchain

c) you don't know the source code && contract is not verified

You can use Panoramix smart-contracts decompiler to get a partial ABI of smart-contract

5

To add to o0ragman0o's comment, see this doc:

https://solidity.readthedocs.io/en/v0.5.2/metadata.html

It outlines how contract metadata should be published to Swarm to avoid centralized (i.e. Etherscan) management/access to contract metadata (including ABI).

2

I have the same question before. For now is not possible, only you can do it with solc compile. Here is an example : https://gist.github.com/tomconte/4edb83cf505f1e7faf172b9252fff9bf

0

you can always solc then call the abi from a file or directly. source : Solcjs

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.