foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Add `[anvil]` section to `foundry.toml`

Open 0x8f701 opened this issue 2 years ago • 6 comments

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

0x8f701 avatar Jan 30 '23 08:01 0x8f701

I'm referring to these configs including ALCHEMY_KEY etc, I have everything inside .env and network url changes according to NETWORK & FORK

0x8f701 avatar Jan 30 '23 08:01 0x8f701

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

0x8f701 avatar Jan 30 '23 08:01 0x8f701

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 \

0x8f701 avatar Jan 31 '23 05:01 0x8f701

@mattsse is it time to introduce [anvil] section in foundry.toml?

rkrasiuk avatar Jan 31 '23 14:01 rkrasiuk

no strong feelings about this, but integrating Config support would actually be trivial I think

mattsse avatar Jan 31 '23 17:01 mattsse

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.

zerosnacks avatar Jul 01 '24 14:07 zerosnacks