An app for volunteers to manage and view badges and bounties.
client: JavaScript, React, Ant Designapi: TypeScript, Node, PostgreSQL, Knex.js (query builder), Objection.js (ORM)
- Smart contracts on Ethereum written in Solidity for badges.
- Subgraph using The Graph, an indexing protocol for querying Ethereum network.
- IPFS for storing badges metadata.
It requires multiple repositories to run the app.
You will need the following pre-requisites common across all repos:
- Yarn
- NVM (Node Version Manager) for your OS which install node version locally from
.nvmrc - PostgreSQL – PostgreSQL Downloads
- By default
postgresshould be the super user which will be used to create databases for the project. psql- an interactive command-line Postgres client.- Ensure that Postgres service is up and running on your system.
- By default
The following components have to be up and running to start development:
- Run local blockchain node and deploy smart contracts here.
- Run local graph node.
- Deploy subgraph to local graph node.
- Run local app.
Start with creating a folder named ubi-rebel-alliance. From now on, this will be the root of the project directory. All repos will be cloned at the project root.
mkdir ubi-rebel-alliance && cd ubi-rebel-alliance
Run the below commands in project root to start a local blockchain node and deploy the contracts.
- Clone the repo -
git clone https://github.com/UBI-Rebel-Alliance/badges-contracts.git && cd badges-contract - Install node version locally -
nvm install - Install dependencies -
yarn - Start blockchain node -
yarn start - Deploy contracts - open another terminal window and run
yarn deploy
To build and run a local graph node you need to have the following installed on your system:
- Rust (latest stable) – How to install Rust
- IPFS – Installing IPFS
- First time, create database named
graph-nodein Postgres- Enter psql command-line interface -
psql -U postgres -h localhost - Create database -
create database "graph-node";(NOTE: don't forget the semicolen at the back)
- Enter psql command-line interface -
Run below commands in project root to start local graph node:
- Clone repo -
git clone https://github.com/graphprotocol/graph-node.git && cd graph-node - Run IPFS node -
ipfs initfollowed byipfs daemon - If using Ubuntu, you may need to install additional packages:
sudo apt-get install -y clang libpq-dev libssl-dev pkg-config - Run below command a new terminal window to spin local graph node:
cargo run -p graph-node --release -- \
--postgres-url postgresql://postgres:postgres@localhost:5432/graph-node \
--ethereum-rpc mainnet:http://127.0.0.1:8545 \
--ipfs 127.0.0.1:5001
NOTE: If you are trying to run a local graph node after the initial setup you will have to drop and recreate the graph-node database before proceeding to run the local graph node:
- Enter psql command-line interface -
psql -U postgres -h localhost - Drop database -
drop database if exists "graph-node"; - Recreate database -
create database "graph-node";
If you have issues installing the graph node on your system, refer to this repo for more details.
- Graph CLI -
yarn global add @graphprotocol/graph-cli
Run below commands in project root to deploy subgraph to local graph node:
- Clone repo -
git clone https://github.com/UBI-Rebel-Alliance/badges-subgraph.git && cd badges-subgraph - Install dependencies -
yarn - Create local subgraph -
yarn create-local - Deploy local subgraph -
yarn deploy-local
- Create Postgres database named
badges_dev- Enter psql command-line interface -
psql -U postgres -h localhost - Create database -
create database "badges_dev";
- Enter psql command-line interface -
- Environment variables:
api- create an dotenv file/api/.envfile with the following key-value pairs.
NODE_ENV=development
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/badges_dev
client- for Pinata access create a dotenv file in/client/.envwith the below key-value pairs (NOTE: Go to Pinata to sign up for API keys)
REACT_APP_PINATA_API_KEY=
REACT_APP_PINATA_SECRET_API_KEY=
Run below commands in project root to run local app:
- Clone repo -
git clone https://github.com/UBI-Rebel-Alliance/volunteer-app.git && cd volunteer app(NOTE: This is the root of the repo) - Install dependencies -
yarn setupto install dependencies for all folders. - Migrate database -
cd api && NODE_ENV=development yarn migrateto migrate database. - Run app - go back to root of repo with
cd ..followed byyarn devto run client and api in one terminal OR runyarn api:devandyarn client:devin separate terminals.