Blockchain-Ethereum Development Environment Construction Introduction

      Before starting to learn each technology, one of the initial tasks is to build various development environments, and the development environment of blockchain is more troublesome. Here we come to a complete realization. The following operations are all done under mac.

(1) Install python2.7, use the following command directly in the terminal on mac:

brew install python (note that python is lowercase)

(2) Install solc (solidity language compiler) and execute the following command in the terminal:

sudo npm install -g solc

Also need to install solc-cli:

sudo npm install -g solc-cli

Use the following command to install solc and solc-cli together. It is recommended to use this command to install:

sudo npm install -g solc solc-cli --save-dev

(3) Install ethereum/cpp-ethereum (Ethereum client geth), and execute the following commands in sequence:

brew update

brew upgrade

brew tap ethereum/ethereum

brew install cpp-ethereum

brew linkapps cpp-ethereum

Or directly execute the following command:

brew tap ethereum/ethereum

brew install ethereum

(4) Install testrpc (as the local test environment of Ethereum, it can be used to deploy smart contracts, which is convenient for debugging and development)

pip install eth-testrpc

Upgrade pip:

python -m pip install -upgrade pip 

After installation, there may be exceptions... scrypt/index.js, reference: http://blog.csdn.net/wo541075754/article/details/53155578This  blog.

(5) Install node.js, download and install directly from the official website:

https://nodejs.org/en/

(6) Install truffle (truffle can quickly compile and deploy smart contracts locally)

npm install -g truffle

(7) Tip: You may install node's package management tool nvm. After nvm is installed, you need to configure the following in the environment variables, and you need to add it to .bash_profile:

export NVM_DIR="~/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm 
(8) After installing geth and solc, it is found that solidity cannot be compiled in the geth console. The following is the solution:

The recommended commands online are as follows:

brew update
brew upgrade
brew tap ethereum/ethereum
brew install solidity
brew linkapps solidity 

But after executing the last brew linkapps solidity, there is no return in the terminal, which actually means that the last line of command failed to execute.

After we execute brew install solidity, the terminal will prompt to use "brew link solidity" to link, instead of using "brew linkapps solidity" as mentioned on the Internet. 

So execute brew link solidity. The terminal prompts that you need to force the link and rewrite, and then execute the command as follows:

brew link --overwrite solidity

After performing the above steps, you can find the solc compiler in geth:

eth.getCompilers ()

or

web3.eth.getCompilers ()

The compiler name can be returned.


The following may also be solutions, you can try:

View the installation path of solc through which solc, and then enter in the geth console:

admin.setSolc("solc path")

       After performing the above steps, the environment for blockchain development is basically set up. However, during the installation process, there are still many pits, such as network reasons. The author has been failing when executing some of the above commands, but after changing the network in another place, the installation was very smooth. In the next blog, I will share with you how to use the above software, as well as the development of blockchain applications, the writing of smart contracts and other technologies.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325357346&siteId=291194637