-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fork should allow to specify a network name instead of url #1164
Comments
Not sure I understand this. You want a way to check in runtime if the current network is a fork? |
Basically instead of {
...
networks: {
hardhat: {
forking: {
url: "<mainnet_url>"
}
},
mainnet {
url: "<mainnet_url>",
}
}
} it would simply be {
...
networks: {
hardhat: {
forking: {
network: "mainnet"
}
},
mainnet {
url: "<mainnet_url>",
}
}
} This remove the need to duplicate url, but more importantly it allows plugin (and hardhat) to consider the network config that could be specific or any other context added. For hardhat-deploy this include named accounts, but also deployments, etc.... |
Oh, I see now, thanks for the explanation! |
Any update on this ? This is really a shame that when things are executed on a fork, there is no information of the network it is forked from. it is always The workaround for now is to add extra info via env variable (see https://github.com/wighawag/template-ethereum-contracts/blob/9ff1bccd2e2badc2deed0eca25877ada2cd52ee5/hardhat.config.ts), but it would be logical for hardhat to keep track of what network it is being forked from an use what is already there for that, the named network |
Hey @wighawag, we are kind of overwhelmed with things to do right now. I still think this makes sense, even if there are workarounds (like using an env var to set the fork, and checking that env var in runtime), and it's probably not hard to implement, but the hardest part is to think about the best way to do this at a product/config level, and I'm not sure when we'll have time to do that 🙁 |
The forking feature requires you to specify a url and while it works it prevent plugin that add context to a network (like named accounts and deployments in hardhat-deploy) when fork is enabled.
Indeed when fork is running there is no information about the network
If the fork config would have a network field (instead of url). that field would be used by hardhat to get the url from the corresponding network.
Then hardhat could expose a runtime environemnet like
hre.forkedNetwork
that plugin could read to reconstruct the context for that particular networkWithout this plugin like hardhat require the user to specify the network the fork is from. duplicating an information that could be easily available
The text was updated successfully, but these errors were encountered: