Skip to content

The Crypto Native Portal, an app that creates a mechanism to financially acknowledge the micro contributions of Open Source collaborators along with tools that promote effective governance.

Notifications You must be signed in to change notification settings

globe-and-citizen/cnc-portal

Repository files navigation

CNC PORTAL

Often, several open-source developers coalesce around a particular project and that project that becomes a very successful company or foundation. Due to the nature of these open-source projects, however, there is no direct way to concretely recognize the innumerable micro contributions of each contributor along the way. Furthermore, large open projects often struggle to get contributors acting in unison in ways that are decisive, unified, and directed. The CNC Portal is to solve these two problems by

  1. Creating the mechanism to financially recognize micro contributions
  2. Creating tools that promote the emergence of effective governance.

The Crypto Native Corporation Portal (CNC Portal) has the potential to be an extremely large and extremely complex project.

Table of Contents

Setting up postgres database

Note: If you plan on using docker-compose up at the root directory, you can skip this part as that sets the database up automatically

Installing the database using docker

To create and run a PostgreSQL Docker container with the correct port and database URL as specified in your .env file, you can use the following command:

docker run --name cnc-db -e POSTGRES_USER=root -e POSTGRES_PASSWORD=root -e POSTGRES_DB=cnc-db -p 5432:5432 -d postgres:16-alpine

Here's the breakdown:

  • --name cnc-db: This names your Docker container cnc-db.
  • -e POSTGRES_USER=root: This sets the PostgreSQL username to root.
  • -e POSTGRES_PASSWORD=root: This sets the PostgreSQL password to root.
  • -e POSTGRES_DB=cnc-db: This creates a database named cnc-db.
  • -p 5432:5432: This maps port 5432 in the Docker container to port 5432 on your host machine.
  • -d postgres: This runs the postgres Docker image in detached mode.

After running this command, you should be able to connect to your PostgreSQL database at postgresql://root:root@localhost:5432/cnc-db.

Running prisma migrations

npx prisma migrate dev --name init

See the Environment Variables section for the relevant DATABASE_URL envronment variable.

Folder structure

.
├── app
├── backend
└── contract

Environment Variables

Backend

In the ./backend folder, create a .env file with the following variables:

  • DATABASE_URL: A valid PostgreSQL database URL. Example: DATABASE_URL=postgres://username:password@localhost:5432/database_name

    PS : If you are using the docker container we setup in the top section, the URL should be: DATABASE_URL=postgres://root:root@localhost:5432/cnc-db

  • SECRET_KEY: An HS256 compatible key for securing the application. Example: SECRET_KEY=1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0a1b²

  • FRONTEND_URL: The URL for the frontend application. Example: FRONTEND_URL=http://localhost:5173

Frontend

Constants

First, go to ./app folder and run npm run git:ignore-locally. This command will ignore changes made to the deployed_addresses of the local hardhat network ensuring no conflict.

Go to the ./contract folder and run npm run moveConstants

This action will copy your deployed_addresses from different chains to src/artifacts/deployed_addresses directory and imports these constants in src/constant/index.ts.

Environment variables

In the ./app folder, create a .env file with the following variable:

  • VITE_APP_BACKEND_URL: The URL for the backend API. Example: VITE_APP_BACKEND_URL=http://localhost:8000
  • VITE_APP_ETHERSCAN_URL: The URL to see transaction detail. Example: VITE_APP_ETHERSCAN_URL=https://sepolia.etherscan.io
  • VITE_APP_NETWORK_ALIAS: The string identifier of an EVM compatible network that the app uses. Example: VITE_APP_NETWORK_ALIAS=polygon. This variable is optional but if you don't set your own network parameters it has to be provided. Use this if you want to use one of the preset networks which the application provides. Available options are:
    1. etherem - The Ethereum Main Network
    2. polygon - The Polygon Main Network
    3. sepolia - The Sepolia Test Network
    4. holesky - The Holesky Test Network
    5. amoy - The Polygon Amoy Test Network
    6. hardhat - The Hardhat Local Network
  • VITE_APP_NETWORK_NAME: The full name of the EVM compatible network the app uses. Example: VITE_APP_NETWORK_NAME=Optimism Mainnet. This variable is optional but if you don't set VITE_APP_NETWORK_ALIAS it has to be provided.
  • VITE_APP_RPC_URL: The URL used to access the EVM compatible network the app uses. Example: VITE_APP_RPC_URL=https://optimism-mainnet.infura.io. This variable is optional but if you don't set