ape-etherscan
ape-etherscan copied to clipboard
Cannot load contract from explorer on avalanche
Environment information
apeand plugin versions:
$ ape --version
0.8.40
$ ape plugins list
Installed Plugins
alchemy 0.8.10
avalanche 0.8.1
ens 0.8.2
etherscan 0.8.4
foundry 0.8.9
hardhat 0.8.5
infura 0.8.4
solidity 0.8.5
template 0.8.0
tokens 0.8.7
vyper 0.8.9
- Python Version: 3.13.7
- OS: macOS
What went wrong?
Cannot load DAI contract on avalanche:mainnet
MRE:
from ape import networks, Contract
with networks.avalanche.mainnet.use_provider("node") as provider:
dai_contract = Contract('0xd586e7f844cea2f87f50152665bcbc2c279d8d70')
pass
Output:
INFO: Connecting to a 'v0.15.4' node.
0xd586E7F844cEa2F87f50152665BCbc2C279D8d70.0xa619486e()
ERROR: Attempted to retrieve contract type from explorer 'etherscan' from address '0xd586E7F844cEa2F87f50152665BCbc2C279D8d70' but encountered an exception: Response indicated failure: Invalid API Key (#err2)|AVAX1
Traceback (most recent call last):
File "/Users/james/projects/degen-code/scripts/(un)stablecoin-watcher.py", line 19, in <module>
dai_contract = Contract('0xd586e7f844cea2f87f50152665bcbc2c279d8d70')
File "/Users/james/projects/degen-code/.venv/lib/python3.13/site-packages/ape/managers/_contractscache.py", line 788, in instance_at
raise ContractNotFoundError(
...<3 lines>...
)
ape.exceptions.ContractNotFoundError: Failed to get contract type for address '0xd586E7F844cEa2F87f50152665BCbc2C279D8d70'. Contract may need verification.
I stepped into the code and noticed that the Etherscan object has attribute
etherscan_api_uri ='https://api.etherscan.io/v2/api?chainid=43114'.
Shouldn't the API URL be snowtrace, which states that the API does not require a key?