This project is a custom blockchain explorer built with React, Ethers.js, and Hardhat. It allows users to explore blockchain data and interact with smart contracts on a local Hardhat node, making it ideal for development and testing in a controlled environment.
If you have Hardhat running locally, preview the explorer using your local provider: Preview with Local Provider
Or, try the explorer with sample data here: Preview with Mock Data
Ensure you have the following installed on your machine:
- Node.js (v14 or higher)
- npm or yarn
- Hardhat (for local blockchain node)
-
Clone the repository:
git clone https://github.com/Shaivpidadi/block-explorer cd block-explorer
-
Install dependencies:
npm install
The app uses environment variables to configure the connection to the blockchain node. To customize, create a .env
file in the project root with the following variables:
REACT_APP_PROVIDER='http://127.0.0.1:8545' # Fallback for local Hardhat node
REACT_APP_WS_PROVIDER='ws://localhost:8545' # WebSocket provider for real-time updates
-
Start the Hardhat Node
Open a terminal, navigate to your Hardhat project directory, and start the Hardhat node:
npx hardhat node
-
Start the Block Explorer
In another terminal window, go to the
block-explorer
project directory and start the React app:npm run start
The app should now be accessible at
http://localhost:3000
, with full interaction capabilities on the Hardhat node.
For simplified setup, the project can be run in Docker.
-
Build the Docker image:
docker build -t block-explorer --build-arg REACT_APP_PROVIDER='http://127.0.0.1:8545' --build-arg REACT_APP_WS_PROVIDER='ws://localhost:8545' .
-
Run the Docker container:
docker run -p 3000:3000 block-explorer
This will serve the app on
http://localhost:3000
.
To run tests, ensure the Hardhat node is running, then execute:
npx hardhat test --network localhost
This setup connects the tests to the running Hardhat node for more realistic testing scenarios.
- React
- Ethers.js
- Tailwind CSS
- Hardhat