Adapted code from the great https://github.com/dethcrypto/dethcode to be able to download the code of a smart contract locally
npm i -g ethereum-sources-downloader
npm i
cd ..
npm i -g ethereum-sources-downloader/
ethereum-sources-downloader {apiName} {contractAddress} {optional:outDir}
apiName is one of:
- etherscan
- ropsten.etherscan
- rinkeby.etherscan
- goerli.etherscan
- kovan.etherscan
- bscscan
- testnet.bscscan
- hecoinfo
- testnet.hecoinfo
- ftmscan
- testnet.ftmscan
- optimistic.etherscan
- kovan-optimistic.etherscan
- polygonscan
- testnet.polygonscan
- arbiscan
- testnet.arbiscan
- snowtrace
- testnet.snowtrace
- cronoscan
- moonbeam
- aurora
- basescan
- goerli.basescan
contractAddress in hexadecimal format (i.e 0x1F98431c8aD98523631AE4a59f267346ea31F984)
outDir specifies optionally where the sources will be downloaded relative to current directory
Demo GIF illustrating the multiple contracts downloading capability which also preserves the directory structure