Add `[anvil]` section to `foundry.toml`
Component
Anvil
Describe the feature you would like
I have forking configs in hardhat.config.ts, it changes according to the following env variables:
- NETWORK
- FORK
- FORK_BLOCK_NUMBER ...
sometimes anvil node is better so I'd like to use anvil for running forkmainnet, in this case how can I let anvil read directly those configs instead of putting complex input parameters such as --fork-url etc.
Additional context
No response
I'm referring to these configs including ALCHEMY_KEY etc, I have everything inside .env and network url changes according to NETWORK & FORK
Also I still think config file is much more practical than input parameters, it's very complicated to input so many arguments:
--fork-url --fork-block-number --chain-id --host 0.0.0.0 --no-rate-limit
etc
to achieve the samething in anvil I made the following make targets:
.PHONY: hardhat
hardhat:
npx hardhat node --hostname 0.0.0.0 #this reads automatically hardhat.config.ts so it's much more clean
.PHONY: anvil
anvil:
anvil \
$(if $(FORK),--fork-url https://eth-$(FORK).alchemyapi.io/v2/$(ALCHEMY_KEY) --no-rate-limit,) \
--chain-id 522 \
--tracing \
--host 0.0.0.0 \
--state-interval 60 \
--dump-state state.json \
$(if $(wildcard state.json),--load-state state.json,) \
--code-size-limit 100000 \
@mattsse is it time to introduce [anvil] section in foundry.toml?
no strong feelings about this, but integrating Config support would actually be trivial I think
Related request from https://github.com/foundry-rs/foundry/issues/4453 by holic
anvil has a --block-time argument/option, but that doesn't appear to be configurable with foundry.toml (or, if it is, it's undocumented).
I'd love for this to be made available. In fact, it would be great if most/all anvil options were configurable via foundry.toml.