crytic / crytic-compile

Abstraction layer for smart contract build systems
GNU Affero General Public License v3.0
157 stars 84 forks source link

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

Open vovikhangcdv opened 4 months ago

vovikhangcdv commented 4 months ago

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.