From 86ef367628935f7db623bd183ac47525314bc22f Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Thu, 18 Apr 2024 12:46:41 -0500 Subject: [PATCH] Add local setup instructions --- README.md | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/README.md b/README.md index ac500a1..85d8fba 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,139 @@ +# DGF Prototype +Decentralized Governance Framework + +## Local development setup + +Clone this repository to a directory on your machine + + git clone https://gitea.dgov.io/DGF/dgf-prototype + +### Nginx + +1. Install nginx + + brew install nginx + + +1. Install mkcert + + brew install mkcert + +1. Install root CA + + mkcert -install + +1. Create a certificate + + mkcert dgfprototype.dev + +1. Create certificates directory + + mkdir /etc/nginx/certs + +1. Copy the certificate to the directory + + cp dgfprototype.*.pem /etc/nginx/certs/ + +1. Add the following to the `http` section of `/etc/nginx/nginx.conf` + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + +1. Add the following to a new file `/etc/nginx/sites-available/dgfprototype_dev` + + server { + listen 443 ssl; + + server_name dgfprototype.dev; + ssl_certificate /etc/nginx/certs/dgfprototype.dev.pem; + ssl_certificate_key /etc/nginx/certs/dgfprototype.dev-key.pem; + + location /api/ { + proxy_pass http://127.0.0.1:3003/; + } + + location / { + proxy_pass http://127.0.0.1:3002/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $host; + } + } + + +### API + +1. In a new terminal window, navigate to `dgf-prototype/backend` + +1. Install the project + + npm install + +1. Copy the example configuration file + + cp .env.example .env + +1. Edit `.env` and set the following values + + PORT=3003 + +1. Create the data directory + + mkdir data + +1. Run the daemon + + node index.js + +### Hardhat + +1. In a new terminal window, navigate to `dgf-prototype/ethereum` + +1. Install the project + + npm install + +1. Run a hardhat node + + npx hardhat node + +1. In a separate terminal window, navigate again to `dgf-prototype/ethereum` + +1. Build and deploy the contracts + + npm run deploy-local + +### Metamask + +1. Install the Metamask extension in your browser + +1. In the Metamask extension, click the list of networks in the top left, and click "Add Network" + +1. At the bottom of the list of popular networks, click "Add a network manually" + + - Network name: Hardhat local + - RPC URL: http://127.0.0.1:8545/ + - Chain ID: 1337 + - Currency symbol: ETH + +### Frontend + +1. In a new terminal window, navigate to `dgf-prototype/client` + +2. Install the project + + npm install + +3. Run the development server + + vite dev + +4. Now you should be able to open the site at https://dgfprototype.dev + + ## To run automatic staking 1. Clone this repository to a directory on your machine