Skip to content

Better error reporting when interacting with undeployed contracts #4141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
PaulRBerg opened this issue Jan 20, 2023 · 4 comments · May be fixed by #10446
Open

Better error reporting when interacting with undeployed contracts #4141

PaulRBerg opened this issue Jan 20, 2023 · 4 comments · May be fixed by #10446
Assignees
Labels
C-forge Command: forge T-feature Type: feature
Milestone

Comments

@PaulRBerg
Copy link
Contributor

PaulRBerg commented Jan 20, 2023

Component

Forge

Describe the feature you would like

I have bumped into many EvmError errors that were caused by an attempt to interact with a contract which was either undeployed already or was deployed to a local network and by the time I was making the call, the contract did no longer exist because I had used a fork cheatcode.

I think that this is such a common scenario that it would be extremely helpful (and prevent many angry reports in the Foundry Support group) for Foundry to handle this sort of error more gracefully and display a clearer error, e.g.:

You have attempted to make a call to address 0xCAFE..., but not contract is present there

@PaulRBerg PaulRBerg added the T-feature Type: feature label Jan 20, 2023
@PaulRBerg
Copy link
Contributor Author

Another related use case - calling undeployed library functions.

When library functions are declared as public or external, the library must be deployed separately and then linked before it can be used.

@PaulRBerg
Copy link
Contributor Author

PaulRBerg commented Jun 18, 2023

I keep bumping into this issue every time I make a new deployment which I need to cross-reference in another repository - I forget to bump the block number.

The error message is generic and difficult to reverse engineer:

Screenshot 2023-06-18 at 4 32 26 PM

@Evalir Evalir self-assigned this Jun 18, 2023
@Evalir
Copy link
Member

Evalir commented Jun 18, 2023

sg @PaulRBerg — agreed we could probably improve this error. Will take a stab at this during the next week to see if we can improve this

@PaulRBerg
Copy link
Contributor Author

I've bumped into the same situation again and spent ~15 minutes that would have been spared had Foundry detected that the contract doesn't exist on the network.

cc @grandizzy

I suspect this is a common debugging situation, especially when running tests against mainnet forks.

@grandizzy grandizzy added this to the v1.2.0 milestone Apr 23, 2025
@grandizzy grandizzy modified the milestones: v1.2.0, v1.3.0 May 5, 2025
@jenpaff jenpaff moved this from Todo to In Progress in Foundry May 5, 2025
@0xrusowsky 0xrusowsky linked a pull request May 6, 2025 that will close this issue
@0xrusowsky 0xrusowsky linked a pull request May 6, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge T-feature Type: feature
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

5 participants