ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
872 stars 133 forks source link

Etherscan plugin doesn't work in console [APE-1247] #1577

Closed arwer13 closed 1 year ago

arwer13 commented 1 year ago

Environment information

$ cat ape-config.yaml
name: ape-playground
plugins:
  - name: hardhat
  - name: ganache
  - name: infura
  - name: etherscan
  - name: solidity

hardhat:
  fork:
    ethereum:
      mainnet:
        upstream_provider: infura
        block_number: 17240000

ganache:
  server:
    port: 8545
  fork:
    ethereum:
      mainnet:
        upstream_provider: infura
        block_number: 17240000

What went wrong?

Unable to get contract type in console although the plugin is installed.

$ ape console --network ethereum:local:ganache

INFO: Connecting to existing 'Ganache' process.

In [1]: c = Contract("0xfb7b22ca585a2B400BE99F7F2a2282724C7b54D3")
ERROR: (ChainError) Failed to get contract type for address '0xfb7b22ca585a2B400BE99F7F2a2282724C7b54D3'. Current provider 'ganache' has no associated explorer plugin. Try installing an explorer plugin using ape plugins install etherscan, or using a network with explorer support.

or

$ ape console

In [1]: c = Contract("0xfb7b22ca585a2B400BE99F7F2a2282724C7b54D3")
ERROR: (ChainError) Failed to get contract type for address '0xfb7b22ca585a2B400BE99F7F2a2282724C7b54D3'. Current provider 'test' has no associated explorer plugin. Try installing an explorer plugin using ape plugins install etherscan, or using a network with explorer support.

When run tests like ape test tests/test_foo.py -s --network :mainnet-fork:ganache no such error occurs during c = Contract(....

How can it be fixed?

I think the explorer plugin should work in console as well. Either the error message be corrected, at least I don't get why explorer plugin must be tied to a provider.

fubuloubu commented 1 year ago

Seems like it may be a bug with ape-ganache actually

Can you try this same issue with ape-hardhat or ape-foundry to verify?

arwer13 commented 1 year ago

Same: ape console --network ethereum:local:foundry --> "... Current provider 'foundry' has no associated explorer plugin. ..."

Updated to ape 0.6.15: didn't help as well.

fubuloubu commented 1 year ago

Same: ape console --network ethereum:local:foundry --> "... Current provider 'foundry' has no associated explorer plugin. ..."

Updated to ape 0.6.15: didn't help as well.

I meant try with mainnet-fork

There are no explorers that will work with local network, although it does keep track of your local deployments

arwer13 commented 1 year ago

It worked with mainnet-fork. Thank you for help!

The confusion for me happened because I mainly run stuff on a separate manually started ganache instance, which got mentally treated just as "local" node with time.

I guess a bit more clarification in the error msg might help anyone like me, but I think the issue could just be closed as well.