# worldrepublicorg/smart-contracts architecture

> Architecture diagram of the GitHub repository worldrepublicorg/smart-contracts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/worldrepublicorg/smart-contracts
- Repository: https://github.com/worldrepublicorg/smart-contracts

## Overview

##### Project type and purpose
- This is a blockchain smart-contract repository (no frontend or backend servers).
- It contains three core Solidity contracts:
- TokenERC20 (the Drachma payment token)
- Staking20Base (the base income distribution mechanism)
- Staking20 (the staking logic that extends Staking20Base)

##### File structure
- Top level:
- LICENSE, README.md – metadata & documentation
- funding.json – off-chain configuration (e.g., treasury or reward addresses)
- Staking20Base/ – contains the .sol files (Staking20Base.sol, Staking20.sol, possibly TokenERC20.sol)
- No frontend or orchestration services—pure on-chain logic.

##### README for insights
- Confirms contracts’ purpose, their inheritance relationship, and deployed addresses.
- Mentions thirdweb’s base contracts (so there is an external dependency/reference, but no off-chain service).

a. Main components to include
- Ethereum (or EVM) Network – the execution environment
- Externally Owned Accounts (EOAs) or users
- TokenERC20 (Drachma) contract
- Staking20Base contract
- Staking20 contract (inherits from Staking20Base)
- Off-chain configuration store (funding.json) – optional

b. Relationships & interactions
– EOAs call Staking20.stake(amount) →
- Staking20 (child) delegates common distribution logic to Staking20Base
- Staking20 interacts with TokenERC20 to transfer tokens from user to contract
– Staking20Base manages reward balances and income distributions back to EOAs

c. Architectural patterns & design principles
– Contract inheritance (Staking20 extends Staking20Base)
– Separation of concerns:
- TokenERC20 handles ERC-20 standard logic
- Staking20Base handles reward calculation & distribution
- Staking20 handles user-facing staking functions
– Immutable on-chain flows; configuration pulled from funding.json at deployment

d. Relevant technologies & frameworks
– Solidity contracts on EVM
– thirdweb base contracts (source of Staking20Base & TokenERC20)
– JSON for configuration

## Diagram (Mermaid)

```mermaid
flowchart TB
    classDef user fill:#b2f5b2,stroke:#333,stroke-width:1px
    classDef contract fill:#90cdf4,stroke:#333,stroke-width:1px
    classDef config fill:#e2e8f0,stroke:#333,stroke-width:1px
    classDef inheritance stroke-dasharray: 5 5,fill:none

    User["Externally Owned Account (EOA)"]:::user
    funding["funding.json"]:::config

    subgraph "EVM Network"
        direction TB
        TokenERC20["TokenERC20 (Drachma)"]:::contract
        Staking20Base["Staking20Base\n(Base Distribution)"]:::contract
        Staking20["Staking20\n(Staking Logic)"]:::contract
    end

    User -->|"stake()/withdraw()/claimRewards()"| Staking20
    Staking20 -->|"extends/inherits"| Staking20Base
    Staking20 -->|"transferFrom()/transfer()"| TokenERC20
    Staking20Base -->|"distributeRewards()/transfer()"| TokenERC20
    funding -.->|"config at deployment"| Staking20

    click TokenERC20 "https://github.com/worldrepublicorg/smart-contracts/blob/main/Staking20Base/TokenERC20.sol"
    click Staking20Base "https://github.com/worldrepublicorg/smart-contracts/blob/main/Staking20Base/Staking20Base.sol"
    click Staking20 "https://github.com/worldrepublicorg/smart-contracts/blob/main/Staking20Base/Staking20.sol"
    click funding "https://github.com/worldrepublicorg/smart-contracts/blob/main/funding.json"

    class User user
    class TokenERC20,Staking20Base,Staking20 contract
    class funding config
```
