If you want to start learning about Ethereum DApp development right away, you can visit the excellent online interactive tutorials provided by Wisdom:

  • Ethereum DApp combat tutorial
  • Ethereum decentralized e-commerce application development practice

One, the preparation before installation

1.1 Viewing the CPU Architecture

Run the following command on the terminal to determine whether the architecture is 32-bit or 64-bit:

~$ uname –p
x86_64
Copy the code

If you see output x86_64, it’s a 64-bit system, otherwise it’s 32-bit.

1.2 Downloading Tools

Make sure you have the download tool wget installed:

~$wget -v GNU wget 1.17.1 built on Linux - GNUCopy the code

If wGET is not already installed, use apt-get to install it

~$ sudo apt-get install wget
Copy the code

2. Install the DApp development environment

2.1 installation Node. Js

First, download the different precompiled versions of Linux, depending on whether your Linux is 32-bit or 64-bit. We use the official long-supported 8.10.0LTS version: 64-bit:

~ $wget HTTP: / / https://nodejs.org/dist/v8.10.0/node-v8.10.0-linux-x64.tar.gzCopy the code

32:

~ $wget HTTP: / / https://nodejs.org/dist/v8.10.0/node-v8.10.0-linux-x86.tar.gzCopy the code

Then unzip to the current directory, using 64-bit as an example:

~ $tar ZXVF node - v8.10.0 - Linux - x64. Tar. GzCopy the code

Then next modify.bashrc to set the relevant environment variables:

~ $echo "export NODE_HOME=$HOME/ node - v8.10.0 - Linux - x64" >> .bashrc
~$ echo "export NODE_PATH=$NODE_HOME/lib/node_modules" >> .bashrc
~$ echo "export PATH=$NODE_HOME/bin:$PATH" >> .bashrc
Copy the code

Finally reload.bashrc (or re-log in) to make Node work:

~ $source .bashrc
Copy the code

Now you can use Node:

~ $node - v v8.10.0Copy the code

2.2 Installing node Emulators

To quickly develop and test Ethereum DApps, we typically use Ethereum node emulators to simulate blockchains. The most popular node emulator is Ganache, previously known as TeseRPC.

Run the following command on the terminal:

~$NPM install -g ganache-cliCopy the code

After the installation is complete, run the following command to verify the installation:

~$ ganache-cli
Ganache CLI v6.0.3 (ganache-core: 2.0.2)
Copy the code

For details on how to use the ganache command line, see the ethereum Ganache CLI command line parameters

2.3 Installing the Solidity compiler

Solidity is the programming language for developing Ethereum smart contracts. For those not familiar, check out the Ethereum Solidity Development Language introduction.

~$NPM install -g solcCopy the code

After the installation is complete, run commands to verify the installation

~ $solcjs version 0.40.2 + commit. 3155 dd80 Emscripten. ClangCopy the code

2.4 installation web3

~$NPM install -g [email protected]Copy the code

Installation verification:

~ $node - p'require("web3")'{[Function: Web3] will: {... }}Copy the code

2.5 Installing the Truffle Framework

Execute the following command to install the Truffle framework:

~$NPM install -g truffleCopy the code

Verify installation:

~$truffle version Truffle v4.1.3 (Core 4.1.3)Copy the code

2.6 installation webpack

Run the following command to install webpack:

~$NPM install -g [email protected]Copy the code

Verify the installation

~ $3.11.0 webpack - vCopy the code

Build a sample project

3.1 Creating a DApp Project

Execute the following command to create and access the project directory:

~$ mkdir demo
~$ cd demo
Copy the code

Then initialize the skeleton structure with the WebPack template:

~/ Demo $truffle unbox Webpack Downloading... Unpacking... Setting up... Unbox successful. Sweet!Copy the code

3.2 Installing the NPM package the project depends on

Run the following command to install the NMP package:

~/demo$ npm install
Copy the code

3.3 Modifying Truffle Configurations

In truffle. Js, change port to 8545 because ganache-cli listens on port 8545:

Module. exports = {networks:{development: {... Port: 8545... }}}Copy the code

3.4 Starting a Node

Execute the following command to start the node emulator to deploy the contract and execute the transaction:

~/demo$ ganache-cli
Copy the code

3.5 Compiling contracts

Execute the following command to compile the project contract:

~/demo$ truffle compile
Copy the code

3.6 Deployment Contract:

Execute the following command to deploy the contract:

~/demo$ truffle migrate
Copy the code

3.7 start DApp

Run the following command to start the DApp:

~/demo$ npm run dev
Copy the code

Just visit http://localhost:8080 in your browser

If you want your DApp to be accessible from another machine, modify package.json:

{
	scripts:{
		"dev": "Webpack dev - server - host 0.0.0.0." "}}Copy the code

Free information

  • Ethereum DApp development environment -Ubuntu platform
  • Ethereum DApp development environment setup – Windows
  • Ubuntu Ethereum private chain construction tutorial
  • Windows Ethereum private chain construction tutorial
  • Ethereum development introductory free tutorial