# 0xnaxzerrr/goldlink architecture

> Architecture diagram of the GitHub repository 0xnaxzerrr/goldlink, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0xnaxzerrr/goldlink
- Repository: https://github.com/0xnaxzerrr/goldlink

## Overview

##### Project Type and Purpose
- GoldLink is a blockchain inter-chain project that facilitates the transfer of tokens between Sepolia (an Ethereum test network) and Binance Smart Chain Testnet using Chainlink’s CCIP. It also includes an automated lottery feature via Chainlink VRF whenever tokens are minted.
- The project’s purpose is to deploy and manage cross-chain contracts including ERC-20 tokens and bridge contracts on two different networks.

##### Analyzing the File Structure
- Top-level directories include:
- .github (with workflows for CI/CD tests)
- script (for deployment scripts)
- src (likely containing Solidity contracts)
- test (for tests)
- foundry.toml and remappings.txt (indicators of a Foundry-based Solidity project)
- The structure confirms that the project is built on Solidity (smart contracts), with deployment/configuration scripts and automated tests.

##### Insights from the README
- The README details deployment and configuration instructions for both Sepolia and BSC networks.
- It specifies key contracts deployed on each network: GoldToken, GoldBridge, GoldLottery on Sepolia and GoldTokenBSC, GoldBridgeBSC on BSC.
- It also indicates the use of Chainlink functions: CCIP for cross-chain communication and VRF for lottery randomness.
- The configuration steps and transaction commands reveal clear interactions and dependencies among the tokens, bridges, and additional Chainlink-powered functionalities.

##### Main Components and Their Relationships
- Components to include:
- Two distinct blockchain environments: Sepolia and BSC Testnet.
- On Sepolia: Contracts such as GoldToken, GoldBridge, and GoldLottery.
- On BSC Testnet: Contracts such as GoldTokenBSC and GoldBridgeBSC.
- Auxiliary services: Chainlink CCIP (cross-chain messaging) and Chainlink VRF (randomness for lottery).
- Deployment and configuration scripts (as represented by the script directory) which interact with these contracts.
- Relationships and interactions:
- Users interact with the GoldToken contract (minting, approving tokens) which subsequently triggers calls to the GoldBridge contract to perform the cross-chain transfer.
- Upon token minting, users are automatically enrolled in a lottery indicated by interactions with the GoldLottery contract.
- The GoldBridge contracts on Sepolia and BSC are configured to communicate with one another — with set functions to configure remote contracts, chain IDs, source/destination addresses, and to fund transactions (using Chainlink CCIP).
- The system relies on external Chainlink services to provide reliable cross-chain execution and randomness.

##### Architectural Patterns and Technologies
- The project demonstrates a decentralized design pattern with clear separation between on-chain logic (smart contracts) and off-chain deployment/configuration scripts.
- It follows a multi-network (or microservice-like) approach by splitting similar functionality between the two chains, using bridging contracts.
- Key Technologies/Frameworks:
- Solidity smart contracts (residing in src),
- Foundry for testing and deployment (evidenced by foundry.toml and script/ directory),
- Chainlink services (CCIP and VRF) for cross-chain messaging and randomness.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    User["User"]:::user

    %% Sepolia Network
    subgraph "Sepolia Network"
        GoldToken["GoldToken (Sepolia)"]:::sepolia
        GoldBridge["GoldBridge (Sepolia)"]:::sepolia
        GoldLottery["GoldLottery (Sepolia)"]:::sepolia
    end

    %% BSC Testnet Network
    subgraph "BSC Testnet"
        GoldTokenBSC["GoldTokenBSC (BSC Testnet)"]:::bsc
        GoldBridgeBSC["GoldBridgeBSC (BSC Testnet)"]:::bsc
    end

    %% External Chainlink Services
    subgraph "External Chainlink Services"
        CCIP["Chainlink CCIP"]:::external
        VRF["Chainlink VRF"]:::external
    end

    %% Deployment and Configuration Tools
    Deployment["Deployment Scripts"]:::script
    CICD["CI/CD Workflows"]:::ci
    Foundry["Foundry Config"]:::config

    %% Relationships
    User -->|"mint/approve"| GoldToken
    GoldToken -->|"bridgeOut"| GoldBridge
    GoldToken -->|"enrollLottery"| GoldLottery

    GoldBridge -->|"viaCCIP"| CCIP
    CCIP -->|"message"| GoldBridgeBSC

    GoldLottery -->|"triggerVRF"| VRF
    VRF -->|"notify"| User

    Deployment -->|"deployAndConfigure"| GoldToken
    Deployment -->|"deployAndConfigure"| GoldBridge
    Deployment -->|"deployAndConfigure"| GoldLottery
    Deployment -->|"deployAndConfigure"| GoldTokenBSC
    Deployment -->|"deployAndConfigure"| GoldBridgeBSC

    CICD -->|"triggerDeploy"| Deployment
    Foundry -->|"configureProject"| Deployment

    %% Styling
    classDef sepolia fill:#FFCCCB,stroke:#333,stroke-width:2px;
    classDef bsc fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef external fill:#F6E3B4,stroke:#333,stroke-width:2px,stroke-dasharray: 5, 5;
    classDef script fill:#A8D5BA,stroke:#333,stroke-width:2px;
    classDef ci fill:#D5A8D5,stroke:#333,stroke-width:2px;
    classDef config fill:#D1E8FF,stroke:#333,stroke-width:2px;
    classDef user fill:#FFE699,stroke:#333,stroke-width:2px;

    %% Click Events
    click GoldToken "https://github.com/0xnaxzerrr/goldlink/tree/main/src"
    click GoldBridge "https://github.com/0xnaxzerrr/goldlink/tree/main/src"
    click GoldLottery "https://github.com/0xnaxzerrr/goldlink/tree/main/src"
    click GoldTokenBSC "https://github.com/0xnaxzerrr/goldlink/tree/main/src"
    click GoldBridgeBSC "https://github.com/0xnaxzerrr/goldlink/tree/main/src"
    click Deployment "https://github.com/0xnaxzerrr/goldlink/tree/main/script"
    click CICD "https://github.com/0xnaxzerrr/goldlink/tree/main/.github/workflows"
    click Foundry "https://github.com/0xnaxzerrr/goldlink/blob/main/foundry.toml and remappings.txt"
```
