建立一个自己的Ethereum区块链
genesis.json
,定义了链的唯一ID,挖矿难度,等{
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc" : {
"0x0000000000000000000000000000000000000001": {"balance": "111111111"},
"0x0000000000000000000000000000000000000002": {"balance": "222222222"}
},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x00001",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000107",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}
geth --datadir=/root/ucsfnet/data init /root/ucsfnet/genesis.json
bootnode --genkey=boot.key
bootnode --nodekey=boot.key
geth --datadir=/root/ucsfnet/data --bootnodes=enode://[email protected]:3031
如上,一个Ethereum区块链就部署成功了(单节点区块链)。其实主要就是配置生成创世块,初始化节点,就可以了。
生成账号并挖矿,用来后面部署智能合约用
geth attach /root/ucsfnet/data/geth.ipc
> eth.accounts
> personal.newAccount("mypassword")
> web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")
注意记录密码,和账号地址