Skip to content

Setting up foundry for frontend development (run foundry persistently listening on a certain port) #4465

Answered by burnto
0xTimepunk asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, for sure, with anvil. Here's what I do:

anvil --fork-url <YOUR_RPC_ENDPOINT> --fork-block-number <YOUR_BLOCK>  --chain-id 1337

This starts up anvil forked against another chain.

Then call scripts against it. You could use hardhat or ganache to deploy, or here's how you'd do it with foundry:

forge script script/00_ExampleDeploy.sol \
  --sender <FIRST_ADDRESS_IN_ANVIL_OUTPUT>  \
  --private-key <FIRST_PRIVATE_KEY_IN_ANVIL_OUTPUT> \
  --rpc-url http://127.0.0.1:8545/ \
  --broadcast

In your script you could also use CREATE2 (via new MyContract{salt: mySalt}()) to ensure the same address across network starts/stops.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by 0xTimepunk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants