# pgurav-rgng/erc20pgtoken architecture

> Architecture diagram of the GitHub repository pgurav-rgng/erc20pgtoken, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pgurav-rgng/erc20pgtoken
- Repository: https://github.com/pgurav-rgng/erc20pgtoken

## Overview

##### Project type and purpose
- This is an Ethereum smart-contract development project built with Hardhat. It implements a custom ERC20 token (PGToken) in Solidity, includes automated tests, and provides deployment scripts targeting the Sepolia testnet (and a local Hardhat node).

##### File structure
- Top-level files and dirs:
- contracts/ – Solidity source for PGToken, leveraging OpenZeppelin (Ownable, ERC20, Pausable, ReentrancyGuard, EIP-2612)
- scripts/ – JS/TS scripts to deploy and interact with the contract
- test/ – Hardhat‐based TypeScript tests
- ignition/ – additional deployment metadata (addresses, build info for Sepolia)
- hardhat.config.ts & tsconfig.json – Hardhat and TypeScript configuration
- typechain-types/ – auto-generated TS bindings for contracts and OpenZeppelin interfaces
- Key patterns:
- Modular contract code under contracts/
- Automated builds: Hardhat compile → TypeChain generation → test and deployment
- Separation of concerns: contracts, tests, scripts, deployment artifacts

##### README for additional insights
- Purpose: teaching ERC20 token creation, testing, and Sepolia‐net deployment
- Features: Ownable, mint/burn controls, pausable, permit approvals, secure guards
- Workflow steps: npm install → .env setup → hardhat node → deploy scripts → run tests

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Workspace
    Developer["Developer Workstation"]:::tools

    ConfigPkg["package.json"]:::artifacts
    ConfigTS["tsconfig.json"]:::artifacts
    ConfigGit[".gitignore"]:::artifacts
    ConfigReadme["README.md"]:::artifacts

    Developer -->|"provides" | ConfigPkg
    Developer -->|"provides" | ConfigTS
    Developer -->|"provides" | ConfigGit
    Developer -->|"provides" | ConfigReadme

    %% Hardhat Framework
    Hardhat["Hardhat Framework"]:::tools
    click Hardhat "https://github.com/pgurav-rgng/erc20pgtoken/blob/main/hardhat.config.ts"

    Developer -->|"invoke compile/tests/deploy"| Hardhat

    %% Plugins
    TypeChainPlugin["TypeChain Plugin"]:::tools
    EthersPlugin["Ethers.js Plugin"]:::tools

    Hardhat -->|"uses plugin"| TypeChainPlugin
    Hardhat -->|"uses plugin"| EthersPlugin

    %% Source Layer
    subgraph "Source Layer"
        Contracts["Solidity Contracts (PGToken + OZ)"]:::code
        click Contracts "https://github.com/pgurav-rgng/erc20pgtoken/tree/main/contracts/"
    end

    %% Build Artifacts
    subgraph "Build Artifacts"
        TypeBindings["TypeChain Bindings"]:::artifacts
        click TypeBindings "https://github.com/pgurav-rgng/erc20pgtoken/tree/main/typechain-types/"

        Ignition["Ignition Metadata"]:::artifacts
        click Ignition "https://github.com/pgurav-rgng/erc20pgtoken/tree/main/ignition/"

        BuildInfo["Sepolia Build Info"]:::artifacts
        click BuildInfo "https://github.com/pgurav-rgng/erc20pgtoken/tree/main/ignition/deployments/sepolia-deployment/build-info/"

        DeployedAddrs["Sepolia Addresses"]:::artifacts
        click DeployedAddrs "https://github.com/pgurav-rgng/erc20pgtoken/blob/main/ignition/deployments/sepolia-deployment/deployed_addresses.json"

        Journal["Deployment Journal"]:::artifacts
        click Journal "https://github.com/pgurav-rgng/erc20pgtoken/blob/main/ignition/deployments/sepolia-deployment/journal.jsonl"

        LockModule["Lock Module"]:::artifacts
        click LockModule "https://github.com/pgurav-rgng/erc20pgtoken/blob/main/ignition/modules/Lock.ts"
    end

    %% Scripts
    subgraph "Scripts"
        DeployScript["Deploy Script"]:::code
        click DeployScript "https://github.com/pgurav-rgng/erc20pgtoken/blob/main/scripts/deploy.js"
        InteractionScript["Interaction Script"]:::code
        click InteractionScript "https://github.com/pgurav-rgng/erc20pgtoken/blob/main/scripts/interaction.ts"
    end

    %% Tests
    subgraph "Test Suite"
        TestSuite["Automated Tests"]:::code
        click TestSuite "https://github.com/pgurav-rgng/erc20pgtoken/blob/main/test/myPGTokenTest.ts"
    end

    %% Networks & External
    LocalNode["Local Hardhat Network"]:::external
    SepoliaNet["Sepolia Testnet"]:::external
    RPC["Sepolia RPC Provider"]:::external
    Metamask["Metamask Wallet"]:::external

    %% Workflow
    Hardhat -->|"compile contracts"| Contracts
    Contracts -->|"artifacts"| Hardhat
    TypeChainPlugin -->|"generate bindings"| TypeBindings

    Developer -->|"run deploy"| DeployScript
    DeployScript -->|"use bindings"| TypeBindings
    DeployScript -->|"send tx"| SepoliaNet
    SepoliaNet -->|"access via"| RPC
    RPC -->|"relay to"| SepoliaNet
    SepoliaNet -->|"mine tx"| BuildInfo
    BuildInfo --> DeployedAddrs
    BuildInfo --> Journal

    Developer -->|"run tests"| TestSuite
    TestSuite -->|"connect to"| LocalNode
    LocalNode -->|"respond to tests"| TestSuite

    Metamask -->|"interact with token"| SepoliaNet

    %% Styles
    classDef code fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef tools fill:#d4edda,stroke:#333,stroke-width:1px
    classDef external fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef artifacts fill:#e2e3e5,stroke:#333,stroke-width:1px
```
