GoodDocs
Search…
Getting Started
How to install a local dev env in one click
This guide will walk you through how to install our learn project GoodBootstrap that will install all our sub projects: GoodServer , GoodContracts, GoodDAPP and GoodGun

Prerequisites

Important: Use node version 14
The most easier way to manage node version is using nvm. Here's example how to set proper node version with it:
1
nvm install 14.17.6
2
nvm use 14.17.6
3
nvm alias default 14.17.6
Copied!

Install build tools

1
# linux / macOS
2
> npm install -g node-gyp
3
# debian / ubuntu
4
> sudo apt-get install build-essential
5
# macOS
6
> xcode-select --install
7
8
# windows
9
npm install -g --production windows-build-tools
Copied!

Install mobile developer tools

IOS
    install / update to the latest xCode
    install CocoaPods:
1
sudo gem install cocoapods
Copied!
Android
Follow the guides:

Quick start

DApp-only install

Clone the repository and install dependencies
1
git clone [email protected]:GoodDollar/GoodDAPP.git
2
cd GoodDAPP
3
yarn --frozen-lockfile
4
cd ios
5
pod install
Copied!
Important: always specify --frozen-lockfile yarn flag to keep packages to being updated. Otherwise you could get error during build because the latest versions of some packages aren't compatible for the RN version used.

Environment .env file

Copy .env.development to .env, then append .env file with the following creds:
1
REACT_APP_ALCHEMY_KEY=
2
REACT_APP_AMPLITUDE_API_KEY=
3
REACT_APP_AUTH0_CLIENT_ID=
4
REACT_APP_AUTH0_DOMAIN=
5
REACT_APP_AUTH0_SMS_CLIENT_ID=
6
REACT_APP_FACEBOOK_APP_ID=
7
REACT_APP_FACE_VERIFICATION_PRIVACY_URL=https://medium.com/gooddollar/gooddollar-identity-pillar-balancing-identity-and-privacy-part-i-face-matching-d6864bcebf54
8
REACT_APP_GOOGLE_CLIENT_ID=
9
REACT_APP_TORUS_NETWORK=ropsten
10
REACT_APP_TORUS_PROXY_CONTRACT=
11
REACT_APP_WEB3_SITE_URL=https://w3.gooddollar.org
12
REACT_APP_MARKET_URL=https://www.facebook.com/groups/gooddollarmarketplace
13
REACT_APP_SENTRY_DSN=
14
REACT_APP_DASHBOARD_URL=https://gooddashboard-dev.herokuapp.com
15
REACT_APP_SERVER_URL=https://good-server.herokuapp.com
16
REACT_APP_GUN_PUBLIC_URL=https://goodgun-dev.herokuapp.com/gun
17
REACT_APP_ZOOM_LICENSE_KEY=
18
REACT_APP_ZOOM_ENCRYPTION_KEY=
Copied!
You could take missing creds from the Netlify's gooddev.netlify.app instance or ask your team leader for the complete .env file

Running the app

1
cd GoodDAPP
2
npm run web # browser
3
npm run ios # IOS
4
npm run android # Android
Copied!

iOS hints

Don't forget to open ios/GoodDollar.xcworkspace (NOT .xcodeproj!) and set up provisional profile and developer account.

Install with the local server instance

Prerequisites

Install MongoDB 4.x:
Configure mongo to run as a cluster. Add your local computer's hostname or it's IP in the home network to the bindIp list:
1
# mongod.conf
2
systemLog:
3
destination: file
4
path: /usr/local/var/log/mongodb/mongo.log
5
logAppend: true
6
storage:
7
dbPath: /usr/local/var/mongodb
8
net:
9
bindIp: 127.0.0.1,Alexs-MacBook-Pro-2.local
10
replication:
11
replSetName: local
Copied!

GunDB

Clone the repository and install dependencies
1
git clone [email protected]:GoodDollar/GoodGun.git
2
cd GoodGun
3
npm i
Copied!
The .env.example file provided is using mongoDB as the storage. Don't use it. For the local development, the direct filesystem should be used. To achieve this, create .env file with the following contents:
1
GUN_PUBLIC_S3=
2
GUN_PEERS=
3
MONGO_URL=
4
MONGO_QUERY=
5
MONGO_PORT=27017
6
MONGO_DB=gun
7
MONGO_COLLECTION=local
Copied!

GoodServer

Clone the repository and install dependencies
1
git clone [email protected]:GoodDollar/GoodServer.git
2
cd GoodServer
3
npm i
Copied!
Copy .env.dev to .env, then append .env file with the following creds:
1
MONGO_DB_URI=mongodb://localhost:27017,<additional hostname/ip from mongod.conf>:27017/gooddollar?replicaSet=local
2
GUNDB_PEERS=http://localhost:8765/gun
3
GUNDB_PASS=password
4
ZOOM_SERVER_BASEURL=https://api.facetec.com/api/v3/biometrics
5
ZOOM_LICENSE_KEY=
6
ALCHEMY_API=
7
INFURA_API=
8
MAUTIC_BASIC_TOKEN=
9
MAUTIC_TOKEN=
10
MNEMONIC=
11
SECURE_KEY=
12
TWILIO_AUTH_ID=
13
TWILIO_AUTH_TOKEN=
14
TWILIO_VERIFY_ID=
Copied!
You could take missing creds from the Heroku's good-server instance or ask your team leader for the complete .env file

GoodDAPP

Install and configure application the same way as described in the "DApp-only install" section of this document. To use local instances of the GoodServer and GunDB, edit the following env variables:
1
REACT_APP_SERVER_URL=http://localhost:3003
2
REACT_APP_GUN_PUBLIC_URL=http://localhost:8765/gun
Copied!

Running

The most preferrable way to run the whole app (gun + server + dapp) locally is to use separate Terminal's tabs.
Gun
1
cd GoodGun
2
npx pm2 start --only gun-local
3
npx pm2 logs # enables logs output
Copied!
Don't forget to unload Gun after your work is done:
1
npx pm2 stop all
Copied!
GoodServer
1
cd GoodServer
2
npm run dev
Copied!
GoodDAPP
1
cd GoodDAPP
2
npm run web
Copied!

Mobile devices/emulators hints

There are issues when you want to run the app on iOS or Android with local server. It won't connect to the local GoodServer/GoodGUN instances.
The simplest way to solve this - to run the app with gooddev/goodqa server (see "DApp-only install" section of this document).
If you need the exactly local server, you have to use services to expose it to some public domain. Something like Serveo or its analogue. More detailed solution is explained at the end of this document.

Complete guide

Prerequisites

Additionally to the preparations listed at the beginning of this doc, you also have to:

Install truffle + ganache-cli

1
npm install -g truffle ganache-cli
Copied!

Install python 2.7.*

Clone and install

Clone the repository and install dependencies
1
git clone https://github.com/GoodDollar/GoodBootstrap.git
2
cd GoodBootstrap
3
npm i
Copied!
This will create a git folder for dapp, server and contracts projects in the ./packages folder
make sure master branch is checked out.
if not run: npm run master-submodules

Set environment variables

Environment .env files

Default environment variables are set up in .env.dev you can overwrite these variables by setting up .env which should include all required variables
Preferably copy .env.dev to .env in all projects. .env.dev contains reasonable defaults for using with pm2. Go over env.example to for more info.
.env.dev only works when using pm2, otherwise use .env

Update missing env

in folder packages/server edit .env.dev
1
MONGO_DB_URI=<your local mongo>
Copied!

Start Project

1
#linux
2
npm start
Copied!
This will start the local blockchain, will wait 60 seconds for contracts to finish compile and deploy and then start the server+dapp that will be linked (npm link) to use the local version of the contracts package (that's why we need to wait for them to be deployed)

Start dev env

Usually when developing you'll want to change the env variables of the dapp+server which isnt very friendly with pm2 so you might consider starting the project as follows instead of the above
1
#on linux
2
npx pm2 start --only good-blockchain,good-gun
3
4
#alternatively on windows
5
cd packages/gun
6
npm start
7
8
#alternatively on windows
9
cd ../packages/contracts
10
npm start
11
12
#wait until contracts have been deployed (npx pm2 logs)
13
14
cd packages/server
15
npm run dev:local
16
17
#maybe on a new shell
18
cd packages/dapp
19
npm run web:local
Copied!

Using a different blockchain network

    contracts: add network in truffle-config.js and modify $NETWORK in .env
    dapp: add network in src/config/config.js and modify $NETWORK in .env
    server: add network in src/server/networks.js and modify $NETWORK in .env
Please note that both server and dapp must use the same blockchain network and the same @goodcontracts version.
If you are running a local blockchain make sure you start server+dapp after contracts finish deploying

GoodServer

Server side of the project is responsible to some actions that cannot be decentralized as creating a user, topping the wallet and sending confirmation emails.
Default environment variables are set up in .env.dev you can overload this variables by setting up .env which should include all required variables

DAPP Unit Testing

1
# Web
2
$ npm run test:web
3
4
# Update Snapshots
5
$ npm run test:web -- -u
6
7
# Web watch mode
8
$ npm run test:web-watch
9
10
# Coverage - web
11
$ npm run coverage
Copied!

Mobile Development Environment

If you want to connect with a mobile you'd need to make sure your services run with SSL (since webcrypto requires ssl).
The easiest option is to use serveo.net by:
1
#If you use a local blockchain, change the .env variable
2
REACT_APP_WEB3_RPC=https://<yourchainsubdomain>.serveo.net
3
#Goodserver url
4
REACT_APP_SERVER_URL=https://<serversubdomain.serveo.net
5
6
#then run
7
ssh -R <dappsubdomain>:80:localhost:3000 -R <serversubdomain>:80:localhost:3003 -R <chainsubdomain>:80:localhost:9545 serveo.net
Copied!
Last modified 14d ago