1.以太坊安装
1.1安装环境
ubuntu 20.04.1
1.2安装配件
go环境 nodejs
1.3源码安装
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum
make geth
make all //或者编译全部
这将创建一个geth go-ethereum/build/bin文件夹中的可执行文件,您可以将其移动到您想要运行的任何位置。二进制文件是独立的,不需要任何其他文件。
geth version // 查看版本号
geth -h // 指令帮助
其他安装方式
2搭建私链
2.1初始化创世区块
每一个区块链都从创世区块开始。当第一次使用默认设置运行Geth时,它会将主网genesis提交到数据库中。对于专用网络(非主网),通常需要不同的genesis块。
以太坊允许通过创世配置文件来初始化创世区块,也可使用选择使用内置的多个网络环境的创世配置。默认使用以太坊主网创世配置。
编写创世区块的配置文件genesis.json
。
{
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"clique": {
"period": 5,
"epoch": 30000
}
},
"difficulty": "1",
"gasLimit": "8000000",
"extradata": "0x00000000000000000000000000000000000000000000000000000000000000007df9a875a174b3bc565e6424a0050ebc1b2d1d820000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"alloc": {
"7df9a875a174b3bc565e6424a0050ebc1b2d1d82": { "balance": "300000" },
"f41c74c9ae680c1aa78f42e5647a62f3