Skip to content

PavelSBorisov/local-devnet

Repository files navigation

Local Ethereum Development Environment

This project provides a streamlined local Ethereum development environment with integrated block explorer support. It automates the setup and deployment process for local development and testing.

Features

  • Automated Devnet Setup: One-command setup of a local Ethereum network
  • Integrated Block Explorer: Built-in Ethernal block explorer integration
  • Smart Contract Deployment: Automated deployment of contracts using Hardhat Ignition
  • Port Management: Automatic detection and handling of port conflicts
  • Environment Management: Secure handling of API keys and environment variables
  • Clean Shutdown: Graceful stopping of the development network

Tools Used

  • Hardhat: Ethereum development environment
  • Ethernal: Block explorer for local development
  • Hardhat Ignition: Declarative deployment system
  • Hardhat Ethernal Plugin: Integration with Ethernal block explorer

Scripts

Setup and Deployment (devnet_setup_and_deploy.sh)

This script automates the entire development workflow:

  1. Port Management:

    • Checks if port 8545 is available
    • Offers to kill any process using the port
  2. Environment Setup:

    • Creates/updates .env file
    • Manages Ethernal API token
    • Validates token length and format
  3. Network Initialization:

    • Starts local Ethereum network
    • Configures 5-second block mining interval
    • Sets up network parameters
  4. Contract Deployment:

    • Compiles smart contracts
    • Deploys contracts using Hardhat Ignition
    • Logs deployment process

Network Shutdown (devnet_stop.sh)

This script provides a clean way to stop the development network:

  1. Process Detection:

    • Identifies processes running on port 8545
    • Shows detailed process information
  2. Graceful Shutdown:

    • Offers to kill the process
    • Provides feedback on shutdown status
    • Allows manual intervention if needed

Usage

You can use either the shell scripts directly or the npm shortcuts:

Using NPM Scripts

  1. Start the development environment:

    npm run devnet:start
  2. Stop the development environment:

    npm run devnet:stop

Using Shell Scripts

  1. Start the development environment:

    ./scripts/devnet_setup_and_deploy.sh
  2. Stop the development environment:

    ./scripts/devnet_stop.sh

Setup Process

  1. Follow the prompts after running the script to:

    • Set up Ethernal account (first time only)
    • Configure API token
    • Deploy contracts
  2. Access the block explorer at:

    https://app.tryethernal.com/explorer/localhost
    

Notes

  • The network state resets each time you run the setup script. This can be reconfigured by removing the workspace and resetOnStart properties from the ethernal section of the hardhat.config.js file
  • The block time is set to 5 seconds, this can also be adjusted in the hardhat.config.js file
  • All transactions and blocks are automatically synced to the block explorer
  • The scripts handle port conflicts and environment setup automatically
  • Use the stop script to cleanly shut down the development network

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published