ubuntu16.04下cpp-ethereum搭建

一、下载cpp-ethereum源码

1、安装git

输入 sudo apt-get install git

2、下载cpp-ethereum源码

git clone --recursive https://github.com/ethereum/aleth.git
cd aleth

二、安装CMake编译工具

https://cmake.org/download/中直接下载Platform文件

在下载目录中将cmake-3.13.2.tar.gz解压,将解压后的文件夹复制到/usr/local/中,和已有的文件夹合并。然后在终端输入cmake -version即可看到cmake已正确安装。

三、编辑cpp-ethereum源文件

这里主要参考github,过程需要很久耐心等待

mkdir build; cd build  # Create a build directory.
cmake ..               # Configure the project.
cmake --build .        # Build all default targets.

这时在build/aleth文件夹下就有了aleth命令文件。

扫描二维码关注公众号,回复: 4916353 查看本文章

四、安装ethereum-concole控制台

首先下载安装nodejs。

这里主要采用和CMake安装相同的方法,在nodejs.org/en/的首页面直接下载10.14.2LTS源文件,然后将解压后的文件夹复制到/usr/local/中合并文件夹。这时在终端输入nodejs -v和npm -v都可正常使用

接下来安装ethereum-console

直接使用sudo npm install -g ethereum-console

会报错EACCES:permission denied when tring install ...

解决办法有两种

1:mkdir ~/.npm-global

     npm config set prefix '~/.npm-global'

     //然后打开或创建一个?/ .profile文件并添加以下行:

     export PATH=~/.npm-global/bin:$PATH

     source ~/.profile

2:Use --unsafe-perm=true and --allow-root flags with npm install 像这样

sudo npm install -g ethereum-console --unsafe-perm=true --allow-root

即可安装ethereum-console ,输入ethconsole即可显示控制台内容

五、运行ethereum 

在aleth的/build/aleth文件夹创建创世区块文件genesis.json

{
    "sealEngine": "Ethash",
    "params": {
            "accountStartNonce": "0x00",
            "frontierCompatibilityModeLimit": "0xffffffff",
            "maximumExtraDataSize": "0x0400",
            "tieBreakingGas": false,
            "minGasLimit": "125000",
            "gasLimitBoundDivisor": "0x0400",
            "minimumDifficulty": "0x020000",
            "difficultyBoundDivisor": "0x0800",
            "durationLimit": "0x08",
            "blockReward": "0x14D1120D7B160000",
            "registrar": "5e70c0bbcd5636e0f9f9316e9f8633feb64d4050",
            "networkID" : "0x0"
    },
    "genesis": {
            "nonce": "0x000000000000002a",
            "difficulty": "0x20000",
            "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
            "author": "0x0000000000000000000000000000000000000000",
            "timestamp": "0x00",
            "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
            "extraData": "0x",
            "gasLimit": "0x2fefd8"
    },
    "accounts": {
            "0000000000000000000000000000000000000001": { "wei": "1", "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
            "0000000000000000000000000000000000000002": { "wei": "1", "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
            "0000000000000000000000000000000000000003": { "wei": "1", "precompiled": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
            "0000000000000000000000000000000000000004": { "wei": "1", "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
            "dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6": { "wei": "1606938044258990275541962092341162602522202993782792835301376" },
            "e6716f9544a56c530d868e4bfbacb172315bdead": { "wei": "1606938044258990275541962092341162602522202993782792835301376" },
            "b9c015918bdaba24b4ff057a92a3873d6eb201be": { "wei": "1606938044258990275541962092341162602522202993782792835301376" },
            "1a26338f0d905e295fccb71fa9ea849ffa12aaf4": { "wei": "1606938044258990275541962092341162602522202993782792835301376" },
            "2ef47100e0787b915105fd5e3f4ff6752079d5cb": { "wei": "1606938044258990275541962092341162602522202993782792835301376" },
            "cd2a3d9f938e13cd947ec05abc7fe734df8dd826": { "wei": "1606938044258990275541962092341162602522202993782792835301376" },
            "6c386a4b26f73c802f34673f7248bb118f97424a": { "wei": "1606938044258990275541962092341162602522202993782792835301376" },
            "e4157b34ea9615cfbde6b4fda419828124b70c78": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }
    }
}
 

1、在aleth/build/aleth文件夹下

创建一个文件夹ipctest

2、打开终端,进入aleth/build/aleth

输入 ./aleth --config genesis.json -m on --network-id 1108 --ipc --listen 30307 --port 30307 -d ipctest --private "myPrivateChain"

私有链启动,开始挖矿

3、ipctest文件夹中出现geth.ipc文件

然后使用控制台连接私有链

打开一个新的终端

输入 ethconsole aleth/build/aleth/ipctest/geth.ipc

即可成功链接

猜你喜欢

转载自blog.csdn.net/u012149181/article/details/85268746