Windows搭建以太坊的私有链环境

1、下载Geth.exe 运行文件,并安装
下载后,只有一个Geth.exe的文件
2、cmd进入按章目录运行:geth -help看看是否可用geth命令
3、在Geth安装目录下放置初始化创世块文件genesis.json
{
    "nonce":"0x0000000000000042",
    "mixhash":"0x0000000000000000000000000000000000000000000000000000000000000000",
    "difficulty": "0x4000",
    "alloc": {},
    "coinbase":"0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "PICC GenesisBlock",
    "gasLimit":"0xffffffff"
}
4、初始化创世块geth --datadir "%cd%\chain" init genesis.json
%cd%:代表Geth安装目录
5、打开geth控制台geth -datadir "%cd%\chain" console
6、创建账号,键入:personal.newAccount()
会提示输入密码,我输入:12341234
 
生成后:
 New wallet appeared: keystore://E:\ChainblockTool\Geth\chain\keystore\UTC--2017-02-21T09-46-27.893010800Z--dc96ed19ac0efa363166ba32d9f887280a9ce710, Locked
"0xdc96ed19ac0efa363166ba32d9f887280a9ce710"
 
7、下载打开图形化钱包https://github.com/ethereum/mist/releases/
下载解压缩后,Ethereum-Wallet即为以太坊图形化界面,打开Ethereum Wallet.exe
8、连接其他节点
首先要知道自己的节点信息,在Geth命令行界面下输入命令,注意大小写
admin.nodeInfo
系统会显示
enode:"enode://1e3c1727cd3bee9f25edeb5dbb3b880e03e41f8eec99566557f3ee0422734a8fcad17c161aa93d61bdbfb28ed152c143c7eb501db58bc63502a104a84b62d742@0.0.0.0:30303“
其中
enode://1e3c1727cd3bee9f25edeb5dbb3b880e03e41f8eec99566557f3ee0422734a8fcad17c161aa93d61bdbfb28ed152c143c7eb501db58bc63502a104a84b62d742@0.0.0.0:30303
就是自己节点的信息,注意要把“0.0.0.0“换成你自己的IP。将这个信息发送给其他节点,在其他节点的命令行中输入:
admin.addPeer(‘enode://1e3c1727cd3bee9f25edeb5dbb3b880e03e41f8eec99566557f3ee0422734a8fcad17c161aa93d61bdbfb28ed152c143c7eb501db58bc63502a104a84b62d742@192.168.1.101:30303’)
如果添加成功,输入admin.peers会显示出新添加的节点。
 
9、挖矿
开始挖矿miner.start()
结束挖矿miner.stop()
上一篇:JAVA CAS单点登录(SSO) 教程


下一篇:java 读写excle