Search…
Setting Up Your Dev Environment
This doc will teach you how to set up your dev environment. Although it's not a hard prerequisite, we recommend skimming the DeSo Code Walkthrough first, as it provides some useful context.

Prerequisites

To run the frontend repo, you will need to be running Node v13.13.0 and NPM 6.14.4. We recommend using NVM to set this environment up. To run the backend you'll need Go v1.15.6 installed.
We will also assume that you have Goland installed. This is the recommended IDE for developing on DeSo since most of the code is Go code.

Setup

First, you must checkout all repos into the same directory. Some of these repos are technically optional, but checking them all out allows you to hop around the code more easily.
1
cd $WORKING_DIRECTORY
2
git clone https://github.com/deso-protocol/core.git
3
git clone https://github.com/deso-protocol/backend.git
4
git clone https://github.com/deso-protocol/frontend.git
5
git clone https://github.com/deso-protocol/identity.git
Copied!
Once all of these repos are checked out, we recommend importing them into a single Goland project. This allows you search across and develop on all of of the repos concurrently. To do this, open Goland, hit File > Open, select a repo folder, and select "Attach" when prompted. If you do this correctly, you should have all four repos loaded into a single Goland project.
If you're not familiar with Goland, the following hotkeys are useful for jumping around the code (full cheat sheet here):
    SHIFT+SHIFT: Open any file across all four repos with fuzzy search.
    CTRL+SHIFT+F: Search across all four repos at once with regexes.
    CTRL+SHIFT+A: Runs any action that you would normally find in a menu.
    CTRL+B: Jump to definition or find usages.
If you like Vim, you can also install the Vim plugin so you get your typical Vim hotkeys.

Building and running locally

Running the frontend in development mode

1
# Assume we're starting in $WORKING_DIRECTORY, which contains all the repos
2
cd frontend
3
npm install
4
5
# The following command will serve the frontend on localhost:4200 with
6
# auto-reloading on changes. You must run a node before the site will
7
# actually work however (see next section).
8
ng serve
Copied!

Running the node in testnet mode

1
# Assume we're starting in $WORKING_DIRECTORY, which contains all the
2
# repos. Also assume we have "ng serve" running.
3
cd backend/scripts/nodes
4
5
# The n0_test script runs a testnet blockchain locally. It starts mining
6
# blocks immediately at a much faster rate than mainnet. You can set your
7
# public key to receive the block rewards by setting it as --miner-public-key
8
# in the arguments. This gives you funds that you can test with. You can see
9
# the status of the node by going to the Admin tab after logging in with an
10
# account and then going to the Network subtab.
11
./n0_test
12
13
# Once n0_test is running, you must navigate to the following URL. 4200 is the
14
# port for ng serve. Note that in order to be
15
http://localhost:4200
Copied!
By default, your browser will point at localhost:17001, which is the default "mainnet" API port. However, when you run n0_test, your node spins up on localhost:18001. To point your frontend at your testnet node, however, you must open up your inspector and change your lastLocalNodev2 parameter to localhost:18001 as shown in the screenshot below. After you do this, you should be able to Sign Up, and everything should work normally.

Running the node in mainnet mode

Most of the time, we develop using testnet mode because it's fast and cheap. However, to make sure our changes work before pushing we like to run full-blown mainnet nodes locally.
1
# Assume we're starting in $WORKING_DIRECTORY, which contains all the repos.
2
# Also assume we have "ng serve" running.
3
cd backend/scripts/nodes
4
5
# The n0 script runs a node that connects to mainnet peers. It will download
6
# all the blocks from its peers and then start syncing its mempool from them.
7
# You can see the status of the node by going to the Admin tab after
8
# logging in with an account and then going to the Network subtab. Note that
9
# syncing the blockchain may take an hour or so.
10
$ ./n0
11
12
# Once n0 is running, you must navigate to the following URL. 4200 is the
13
# ng serve port. It should automatically hit your node, which should be
14
# exposing its API at localhost:17001.
15
http://localhost:4200
Copied!

Running a local identity service (optional)

Running an identity service locally is generally not required. However, doing so is as easy as running the Angular app:
1
# Assume we're starting in $WORKING_DIRECTORY, which contains all the repos
2
cd identity
3
npm install
4
5
# Install angular cli
6
sudo npm install -g @angular/cli typescript tslint dep
7
8
# The following command will serve identity on localhost:4201 with
9
# auto-reloading on changes.
10
ng serve --port 4201
Copied!
In order to point your browser at your local identity service rather than at identity.deso.org, you must change a localStorage value similar to what we did to get the testnet node running. In this case, we must change lastIdentityServiceURL to http://localhost:4201. See the screenshot below:
Last modified 27d ago