ApeWorX / ape-etherscan

Etherscan explorer plugin using EVM-based networks for the Ape Framework
https://www.apeworx.io/
Apache License 2.0
21 stars 25 forks source link

Fails to verify contract ( err: Unable to locate a contract with the name ) #138

Closed ShubhamChndrvnshi closed 2 days ago

ShubhamChndrvnshi commented 2 days ago

Environment information

What went wrong?

Tried verifying the contract with publish: True, I got error that it's unable to locate a contract.

@click.command(cls=ConnectedProviderCommand) @ape_cli_context() @network_option() def cli(cli_ctx, network): """ Get public parameter of cicada vote instance """ try:

custom gas fee

    max_fee = '200 gwei'
    max_priority_fee = '10 gwei'
    # Check network details
    ecosystem_name = networks.provider.network.ecosystem.name
    network_name = networks.provider.network.name
    provider_name = networks.provider.name

    click.secho(f"Selected network: {network_name}", fg="blue")

    account = accounts.load("olas")

    click.secho(
        f"You are connected to network '{ecosystem_name}:{network_name}:{provider_name}'.",
        fg="yellow",
    )
    click.secho(f"Deployer is set to '{account}'.", fg="yellow")

    # Deploy the contract
    click.secho("Deploying the PrivateVote contract...", fg="green")
    project.PrivateVote.deploy(sender=account, publish=True, max_fee=max_fee, max_priority_fee=max_priority_fee)
    click.secho("Contract deployed successfully!", fg="green")
except Exception as e:
    click.secho(f"An error occurred: {e}", fg="red")
- full output of the error you received

Unable to verify. Unable to locate a contract with the name 'PrivateVote.sol:PrivateVote', did you specify the correct Contract Name?


Have attached a txt file that contains the output from terminal for command run with ```-v DEBUG```
[debug.txt](https://github.com/user-attachments/files/16077730/debug.txt)

### How can it be fixed?

Fill this in if you have ideas on how the bug could be fixed.
linear[bot] commented 2 days ago

APE-1780 Fails to verify contract ( err: Unable to locate a contract with the name )

antazoey commented 2 days ago

As an aside, there are some things with your script I want to comment on!

  1. Since 0.7.0, you no longer need to specify @network_option() with ConnectedProviderCommand, you get it automatically and it works better without it
  2. When using ConnectedProviderCommand, you can also accept provider and ecosystem right in the command args,

Here is an example!

@click.command(cls=ConnectedProviderCommand)
@ape_cli_context()
def cli(cli_ctx, ecosystem, network, provider):
    ...
    # No need for lines like `network_name = networks.provider.network.name`
    click.secho(f"Selected network: {network.name}", fg="blue")

(Partially shilling this feature)

And also, for the record, I am looking into the issue now and working on ape-etherscan as a whole

antazoey commented 2 days ago

fixed by https://github.com/ApeWorX/ape-etherscan/pull/140

ShubhamChndrvnshi commented 1 day ago

Worked for me https://sepolia.etherscan.io/address/0xd9aaBA4a0Cf1F087cEc266e2811e8ae5cAb1Faf3#code

Thanks @antazoey