Ethereum (English: Ethereum) is an open source public blockchain platform with smart contract capabilities. Provides a decentralized virtual machine (“Ethereum Virtual Machine”) through its dedicated cryptocurrency, Ether, to process peer-to-peer contracts.
1. Download dependent tools
After installing the virtual machine, update the centos server and download git, wget, vim, gcc-c++, ntp components, nodejs, and add epel third-party installation sources. This step is very important, and it can save everyone's time to grope around when they often make mistakes when installing Ethereum and open frameworks later. A brief description of each tool is given below:
git, wget: tools for installing related components, downloading and installing various open source codes and tools;
vim: text editing tool, replace vi;
gcc-c++: c/c++ compilation tool, used for the compilation of some c libraries under golang and the compilation of truffle components
ntp: network clock synchronization component; Ethereum's rpc network requires time synchronization;
nodejs: ethereum front-end development JavaScript package management software
epel: linux installation package source for third-party network
yum update -y && yum install git wget bzip2 vim gcc-c++ ntp epel-release nodejs cmake -y
2. Download the golang version as
wget https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz
Unzip golang and move the working directory to /usr/local/go
tar zxvf go1.9.linux-amd64.tar.gz
mv go /usr/local/
Configure GOROOT and PATH
echo "export GOROOT=/usr/local/go" >> /etc/profile
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
source /etc/profile
verify
go version
3. Clone and compile go-ethereum
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum
make all
If make all reports the following error:
Go to go-ethereum/vendor/gopkg.in/olebedev/go-duktape.v3/api.go and change
line 976 from int64 to uint64.
and then re-execute
After the creation is complete, enter the geth path in the path
echo "export PATH=$PATH:/root/go-ethereum/build/bin" >> /etc/profile
source /etc/profile
verify:
geth version
4. Install cmake: smart contract compilation solc requires cmake compilation
Originally, I wanted to install cmake together with yum, but only 2.8.x version of cmake is available in yum and epel sources, and the installation of smart contract compiler solc requires cmake version 3.0.x or higher. Therefore, you can only go to the official website to install it independently.
Download the latest version of cmake, log in to https://cmake.org/download/ and find the download address of the latest version
cd && wget https://cmake.org/files/v3.9/cmake-3.9.2.tar.gz
Unzip and compile and install
tar -xzvf cmake-3.9.2.tar.gz
cd cmake-3.9.2
./bootstrap && make && makeinstall
5. Start network time synchronization
systemctl enable ntpd
systemctl start ntpd
In addition, geth will use ports 8078 and 30303, release firewall ports 8078 and 30303
6. Turn on the firewall
systemctl start firewalld
7. Release the port
firewall-cmd --zone=public --add-port=8087/tcp --permanent
firewall-cmd --zone=public --add-port=30303/tcp --permanent
8. Configure geth's private genesis configuration file: genesis.json, which describes how to initialize a private geth
1. cd
2. vim genesis.json
cd
vim genesis.json
#Enter the following, then save and exit
{
"nonce":"0x0000000000000042",
"timestamp": "0x00",
"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x00",
"gasLimit":"0x80000000",
"difficulty":"0x400",
"mixhash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0xa0B9171F2a60Bd1812fb0806ece01198Bd8e4A35",
"alloc": {},
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
}
}
create a private network of geteum
1. cd root & geth --datadir "/home/ethbase/chain" init genesis.json
9. Start geth
More commonly used is the test in the development environment, you can directly start the default geth development environment, note: there is no space between the double minus sign, 2 and >>
geth --dev console 2>> geth_dev_log
Entering the console actually enters the JavaScript environment of Ethereum.
Note, if you execute geth --dev console 2, the following error will be reported, because Ethereum executes miner.start and returns null
解决方案:geth --identity "TestNode" --rpc --rpcport"8545" --datadir /opt/data/ --port "30303" --nodiscover--dev --dev.period 1 console>> geth_dev_log
If you want to pay attention to the logs during the operation, you can start another SSH to observe through tail
1. tail -f geth_dev_log