其他分享
首页 > 其他分享> > 以太坊Geth私链环境搭建

以太坊Geth私链环境搭建

作者:互联网

Ubuntu环境

安装Geth:

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum

查看geth版本

dell@dell-VirtualBox:~/dapp/course$ geth version

Geth
Version: 1.9.25-stable
Git Commit: e7872729012a4871397307b12cc3f4772ffcbec6
Architecture: amd64
Protocol Versions: [65 64 63]
Go Version: go1.15.6
Operating System: linux
GOPATH=
GOROOT=go

生成genesis.json文件

dell@dell-VirtualBox:~/dapp/course$ vim genesis.json

输入

{
	"nonce": "0x0000000000000042",
	"difficulty": "0x200",
	"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
	"coinbase": "0x0000000000000000000000000000000000000000",
	"timestamp": "0x00",
	"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
	"extraData": "0x",
	"gasLimit": "0x2CD29C0",
	"alloc": {},
	"config": {
		"chainId": 6500,
		"homesteadBlock": 0
    }
}

初始化

geth --datadir “chain” init genesis.json

启动geth

geth --identity "myethereum" --rpc --rpccorsdomain "*" --datadir "chain" --port "30303" --rpcapi "db,eth,net,web3,personal,miner" --networkid "6500" console 2>1.txt
> eth.blockNumber
0
> personal.newAccount("account1")
"0x22b7d9435328d56266d8ea9a7def7d3366133bd4"
> eth.accounts
["0x22b7d9435328d56266d8ea9a7def7d3366133bd4"]
> miner.start()
null
> eth.mining
true
> miner.stop()
null
> eth.mining
false

标签:Geth,geth,以太,--,dell,rpc,eth,私链
来源: https://blog.csdn.net/weixin_43405220/article/details/111419931