I can "spin up" a local fake blockchain in Terminal using
$ hardhat node
I can also make it fork the real mainnet using Alchemy, even pin it to a specific block
N. Other local applications can then connect at
http://localhost:8545 and interact with the forked local chain until I press
Ctrl+C in that Terminal window and my local
JSON-RPC node disappears. So far so good.
My question is: How do I combine this feature with deploying a contract?
How do I do BOTH:
- Spin up the forked chain at block
N, so it is usable via port 8545 (launch an
JSON-RPCserver that runs until I stop it)
- And while my forked chain spins up, how do I deploy a test contract "into it" (probably will increase my block number from
N + 1)?
What I have tried:
I have tried a deploy script. It seems that I can "spin up" the desired forked chain at block N momentarily, but at no time is it accessible via port 8545 to other applications.
Inside the script, I can deploy a contract with the usual deploy commands, and even interact with my contract.
What I really need though, is a "live" (accessible via port 8545 or 8546) forked chain with my brand new contract "in it", so another app (that is not launched via
hh commands) can interact with it.
Is this possible?