10

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?

4

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 of the Blocks 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

1

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

1

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).

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, privacy policy and cookie policy

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