crytic-compile icon indicating copy to clipboard operation
crytic-compile copied to clipboard

Etherscan now requires API key for getsourcecode, resulting in "Invalid etherscan API Key" error

Open vovikhangcdv opened this issue 7 months ago • 0 comments

Due to a recent breaking change by Etherscan, the apikey parameter is now required by default. As a result, the default command for getting the source publicly will no longer work.

For example:

$ crytic-compile 0xd3c41c85be295607e8ea5c58487ec5894300ee67
ERROR:CryticCompile:Invalid etherscan API Key
ERROR:CryticCompile:Invalid etherscan API Key: https://api.etherscan.io/api?module=contract&action=getsourcecode&address=0xd3c41c85be295607e8ea5c58487ec5894300ee67

To address this change, it is now necessary to provide the API key using --etherscan-apikey $ETHERSCAN_API_KEY. However, this is not loaded by default.

Expected Behavior

Cryptic compile should load $ETHERSCAN_API_KEY env by default.


The issue could have occurred with other explorers as well. It was only tested with Etherscan.

vovikhangcdv avatar Jul 22 '24 07:07 vovikhangcdv