Block Explorer for Local Network in Hardhat
Nov 11, 2022
Hardhat, by default, uses a per-process built-in local Ethereum network to run your scripts, tests, deploys, etc.
It creates the network when you run a script, and destroys it afterwards. You can get more info here.
As an alternative, you can run it in stand-alone mode, to support external wallets (MetaMask et al). For this, you need to run: npx hardhat node
.
Then, to connect your scripts to this stand-alone network, you need to specify the localhost network. As an example, to run a script called deploy.ts
, you would run something like: npx hardhat run scripts/deploy.ts --network localhost
.
Local Network Explorer
Hmm, so how do I see transactions in my local hardhat network (after running `npx hardhat node`)?
— Maximiliano Redigonda (@mredigondadev) November 11, 2022
I see people do it with Ganache, but I want something to connect to my JSON-RPC server at :8545 and be done with it...
I felt the need for an explorer of this local network, to get the actual data that is used in each transaction, gas costs data, etc.
So far, the only tool I’ve found is Etherparty Explorer, whose last commit was on 2017.
It works, although it will give you some warnings that the node version you are using is not the one specified (it was meant to be run with Node <=2).
Install its dependencies with npm install
, then run it with npm start
, and by default it will connect to your local hardhat network which serves a JSON-RPC server at port :8545.
You will need to open it manually at http://localhost:8000/
, and it will show you something like: