以太坊节点搭建私链(POA)

发布于:2025-06-21 ⋅ 阅读:(19) ⋅ 点赞:(0)

geth

下载

# 克隆以太坊Go实现的仓库
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum

# 切换到v1.9.25 / v1.10.26 版本的代码
git checkout v1.9.25

# 编译并安装
make geth
cp build/bin/geth /usr/local/bin/  # 复制编译好的二进制文件

安装

创建挖矿账户

geth account new --datadir data
==========================================
Your new account is locked with a password. Please give a password. Do not forget this password.
Password: 
Repeat password: 

Your new key was generated

Public address of the key:   0x90233e23D4FfBD0954e038d78A68C6c6306Cf6c3
Path of the secret key file: data/keystore/UTC--2025-06-20T07-29-58.379560000Z--90233e23d4ffbd0954e038d78a68c6c6306cf6c3

- You can share your public address with anyone. Others need it to interact with you.
- You must NEVER share the secret key with anyone! The key controls access to your funds!
- You must BACKUP your key file! Without the key, it's impossible to access account funds!
- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!

创世文件 genesis.json

{
	"config": {
		"chainId": 6666,
		"homesteadBlock": 0,
		"eip150Block": 0,
		"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
		"eip155Block": 0,
		"eip158Block": 0,
		"byzantiumBlock": 0,
		"constantinopleBlock": 0,
		"petersburgBlock": 0,
		"istanbulBlock": 0,
		"clique": {
			"period": 10,
			"epoch": 30000
		}
	},
	"nonce": "0x0",
	"timestamp": "0x685513ea",
	"extraData": "0x000000000000000000000000000000000000000000000000000000000000000090233e23d4ffbd0954e038d78a68c6c6306cf6c30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
	"gasLimit": "0x2625a00",
	"difficulty": "0x1",
	"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
	"coinbase": "0x0000000000000000000000000000000000000000",
	"alloc": {
		"0000000000000000000000000000000000000000": {
			"balance": "0x1"
		},
		"1234e4c33249458534fcaa38aa38b194e1d0efc4": {
			"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
		}
	},
	"number": "0x0",
	"gasUsed": "0x0",
	"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
	"baseFeePerGas": null
}

对创世区块进行初始化

geth init --datadir ./data genesis.json
cp UTC--2025-06-20T07-29-58.379560000Z--90233e23d4ffbd0954e038d78a68c6c6306cf6c3 ./data/keystore/

v1.9.25启动

geth --datadir ./data --networkid=6666 --http --http.api "eth,net,web3,personal,admin,miner" --http.vhosts --rpcport 8545 --mine --miner.threads 1 --allow-insecure-unlock --unlock "0x90233e23D4FfBD0954e038d78A68C6c6306Cf6c3" --password ./password.txt --nodiscover

v1.10.26启动

geth --datadir ./data --networkid=6666 --http --http.api "eth,net,web3,personal,admin,miner" --http.addr 0.0.0.0 --http.port 8545 --mine --miner.threads 1 --allow-insecure-unlock --unlock "0x90233e23D4FfBD0954e038d78A68C6c6306Cf6c3" --password ./password.txt --nodiscover

网站公告

今日签到

点亮在社区的每一天
去签到