ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

Please provide Contract.fromEtherscan(address)

Open hiroshi-yamamoto-dublr opened this issue 3 years ago • 2 comments

Describe the Feature

Please provide Contract.fromEtherscan(address [, provider]) that will pull the contract ABI for a verified contract down from Etherscan and create a new Contract object with that ABI, so that only the address of a deployed and verified contract has to be provided to Ethers.

(Inspiration: ContractFactory.fromSolidity(json))

Code Example

`const myContract = Contract.fromEtherscan(address);`

hiroshi-yamamoto-dublr avatar Jul 21 '22 05:07 hiroshi-yamamoto-dublr

I like the idea, but would probably make it part of the EtherscanProvider, etherscanProvider.getContract(address, signer = null).

Does Etherscan offer an API for pulling contract abi by address?

ricmoo avatar Jul 21 '22 07:07 ricmoo

Yes:

https://docs.etherscan.io/api-endpoints/contracts

this may be helpful, potentially:

https://www.npmjs.com/package/etherscan-api

hiroshi-yamamoto-dublr avatar Jul 21 '22 16:07 hiroshi-yamamoto-dublr

This is available in v6. :)

Thanks! :)

ricmoo avatar Jan 31 '23 06:01 ricmoo