blockchain | geth安装

发布时间 2023-04-03 16:45:08作者: Mz1

blockchain | geth环境搭建

下载地址:
https://geth.ethereum.org/downloads

使用geth来搭建私链环境。
参考文章:

https://blog.csdn.net/TANGYAO97/article/details/112903323   # windows
https://cloud.tencent.com/developer/article/1612791    # linux

安装好测试一下:
image

创建创世区块状态(genesis.json):

{
	"config": {
		"chainId": 15
	},
	"difficulty": "2000",
	"gasLimit": "2100000",
	"alloc": {
		"7df9a875a174b3bc565e6424a0050ebc1b2d1d82": {
			"balance": "300000"
		},
		"f41c74c9ae680c1aa78f42e5647a62f353b7bdde": {
			"balance": "400000"
		}
	}
}

然后创建一条链子:

geth --datadir C:\Users\thinkpad\Desktop\BlockChainLearn\private_net init C:\Users\thinkpad\Desktop\BlockChainLearn\private_net\genesis.json

image

启动链子:

geth --datadir C:\Users\thinkpad\Desktop\BlockChainLearn\private_net --networkid 15  # 15要与配置文件中的对应

image

可以加上--nodiscover停止发现peer。

在启动好链子的时候,可以使用geth attach进去geth控制台:
具体的连接信息在启动链子的时候可以看到。
基本操作参考:https://blog.csdn.net/wonderBlock/article/details/106314759

image

在输入命令创建账户的时候会发现报错,因为启动链子的时候没有开启ipc的权限:
image