Skip to content

Duplicate contract names error for contracts with different file names #7042

Closed
@divine-comedian

Description

@divine-comedian

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (2cf84d9 2024-02-07T00:16:06.769732275Z)

What command(s) is the bug in?

forge create

Operating System

Linux

Describe the bug

While running forge create I receive an error saying I have duplicate contract names. While that is true I have them in two separate, distinctly named files - ModifiedTokenDistro.sol and TokenDistro.sol.
image

When I run this command:

forge create --private-key $PRIVATE_KEY --etherscan-api-key $GNOSISSCAN_API_KEY --chain-id 100 --verify --rpc-url $GNOSIS_RPC_URL --verifier-url https://api.gnosisscan.io/api contracts/ModifiedTokenDistro.sol:TokenDistro

I get this error:

Error: 
If cache is disabled, compiler version must be either provided with `--compiler-version` option or set in foundry.toml

Context:
- contract with duplicate name `TokenDistro`. please pass the path instead

image

However I did specify the relative path to the contract file and the contract name - so why does it think there is a duplicate contract if I did explicitly specify the file path?

here is a public URL to the contract in question
https://github.com/Giveth/giveconomy-foundry/blob/modify-allocation-functions/contracts/ModifiedTokenDistro.sol

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Completed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions