This project is for the blockchain application My Dapp. It contains code for the Smart Contract, web-based dapp and NodeJS server.
In order to develop and build "My Dapp," the following pre-requisites must be installed:
- Visual Studio Code (or any IDE for editing Javascript)
- NodeJS
- Yarn (DappStarter uses Yarn Workspaces)
Using a terminal (or command prompt), change to the folder containing the project files and type: yarn
This will fetch all required dependencies. The process will take 1-3 minutes and while it is in progress you can move on to the next step.
Note: You may see some npm warnings about "web3-bzz" after dependencies are installed. These can be ignored as the associated code is never invoked.
Using a terminal (or command prompt), change to the folder containing the project files and type: yarn start
This will run all the dev scripts in each project package.json.
To view your dapp, open your browser to http://localhost:5000
We
yarn migrate
to compile contracts/*.sol files, deploy them to the blockchain.
Run the dapp in a separate terminal. You must have run npm run deploy
for the dapp to see most recent smart contract changes.
yarn dapp
runs the dapp on http://localhost:5001 using webpack dev server
Run the server in a separate terminal. You must have run npm run deploy
for the dapp to see most recent smart contract changes.
yarn server
runs NodeJS server app on port 5002 with NestJS
test-config.js
contains settings used by test scripts
Run tests using yarn test --script=[test file]
DappStarter currently does not provide blockchain migration scripts to be used in production. However, here are the scripts for generating production builds:
yarn build:prod
generates dapp bundle for production.
This section contains installation guides for common dev environments.
(Source: Solana) We suggest that you install Rust using the 'rustup' tool. Rustup will install the latest version of Rust, Cargo, and the other binaries.
Follow the instructions at Installing Rust.
For Mac users, Homebrew is also an option. The Mac Homebrew command is brew install rustup
and then
rustup-init
. See Mac Setup &
Installing Rust for more details.
After installation, you should have rustc
, cargo
, & rustup
. You should
also have ~/.cargo/bin
in your PATH environment variable.
(Source: Solana) Docker runs as a service and it needs to be running before you invoke any script that requires the service. The exact start method depends on your system and how you installed docker.
The instructions to install Docker have changed over time. If you have
previously installed Docker, this will be a good time to update your system.
See Install Docker Engine on Ubuntu for a step-by-step walk-through. When complete, sudo docker run hello-world
should confirm that everything works correctly.
To run Docker without typing sudo
every time, take a look at Step 2 of How To Install and Use Docker on Ubuntu 18.04
Docker provides a desktop application for Mac at Docker Desktop for Mac with additional instructions here Install Docker Desktop on Mac. If you install the Docker Desktop app, you can skip the HomeBrew instructions below. If docker run hello-world
works, you are ready to Start the local Solana cluster.
If you are using HomeBrew on a Mac, the commands are:
$ brew install docker
$ brew install docker-machine
# The next two commands to install virtualbox & create a machine may need a
# password. You may also need to address a System Preference setting and
# re-try the installation.
$ brew cask install virtualbox
$ docker-machine create --driver virtualbox default
# To see config info:
$ docker-machine env default
# Port forwarding of 8899 from your OS to the Docker machine:
$ docker-machine ssh default -f -N -L 8899:localhost:8899
# To configure your shell to use the docker-machine
$ eval "$(docker-machine env default)"
NOTE: Later, you can run docker-machine stop default
to stop the docker machine.
Resources for Mac HomeBrew users: