centos 下安裝以太坊--簡單的挖礦

一、下載以太坊源碼node

    wget http://www.huiyanghua.com/js/go-ethereum-1.4.12.zip
json

二、解壓vim

tar -zxvf go-ethereum-1.4.12.zip /usr/local/bin網絡

 三、建立私有文件夾 mkdir private-gethoracle

四、進入私有文件夾app

    cd private-gethui

五、創世紀區塊文件url

vim genesis.jsonspa

    {命令行

    "config": {

        "chainId": 15,

        "homesteadBlock": 0,

        "eip155Block": 0,

        "eip158Block": 0

    },

    "coinbase" : "0x0000000000000000000000000000000000000000",

    "difficulty" : "0x40000",

    "extraData" : "",

    "gasLimit" : "0xffffffff",

    "nonce" : "0x0000000000000042",

    "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",

    "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",

    "timestamp" : "0x00",

    "alloc": { }

}

六、初始化創世紀節點,並設置data目錄:

/usr/local/bin/geth/geth  --datadir ./data/00 init genesis.json(紅色部分表示geth的安裝目錄)

能夠看到在當前目錄下新增了一個文件夾data,目錄結構以下

啓動節點, 加上console 表示啓動後,啓用命令行:

 /usr/local/bin/geth/geth --datadir ./data/00 --networkid 1234567890 console

如今私有網絡就搭建成功

 

挖礦

 

挖礦首先必須有一個帳戶,輸入下面的命令,查看當前node中的全部帳戶:

> eth.accounts
[]


 

> personal.newAccount('oracle')
"0xb241b0b47a4d773d5c8b462607f590f3ed1762c8"
> INFO [09-16|02:54:18] New wallet appeared                      url=keystore:///data/00/keystore/UT… status=Locked
> eth.accounts
["0xb241b0b47a4d773d5c8b462607f590f3ed1762c8"]
 

挖礦首先必須有一個帳戶,輸入下面的命令,查看當前node中的全部帳戶:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

> eth.accounts

[]

###輸出了一個"[]",說明毛都麼有一根,更別說帳戶了.既然沒有,那就來建立一個,繼續輸入命令:

> personal.newAccount("123456")

###正常狀況,命令行會輸出:

INFO [05-15|23:59:29] New wallet appeared                      url=keystore:///home/zl/Documents/p… status=Locked

"0x5b901c2495c077f515ae84fc53206f2eb3bf8296"

###再用以前查看帳戶的命令看看:

> eth.accounts

["0x5b901c2495c077f515ae84fc53206f2eb3bf8296"]

###有輸出了"0x5b.......96"這一串就是帳戶的地址.

###帳戶有了,接下來作點更有意思的事,開始挖礦....繼續在命令行書輸出:

> miner.start()

INFO [05-16|00:07:25] Updated mining threads                   threads=0

INFO [05-16|00:07:25] Starting mining operation

null

INFO [05-16|00:07:25] Commit new mining work                   number=1 txs=0 uncles=0 elapsed=38.053ms

INFO [05-16|00:07:28] Generating DAG in progress               epoch=0 percentage=0 elapsed=1.715

INFO [05-16|00:07:30] Generating DAG in progress               epoch=0 percentage=1 elapsed=3.448s

INFO [05-16|00:07:31] Generating DAG in progress               epoch=0 percentage=2 elapsed=5.059s

INFO [05-16|00:07:33] Generating DAG in progress               epoch=0 percentage=3 elapsed=6.799s

INFO [05-16|00:07:35] Generating DAG in progress               epoch=0 percentage=4 elapsed=8.373s

...................................這個percenage=100,也就是100%之後.,就不斷的出現下面的提示.............

INFO [05-16|00:24:54] Successfully sealed new block            number=36 hash=95fdfd…1411ee

INFO [05-16|00:24:54] 🔗 block reached canonical chain          number=31 hash=438022…f6592e

.................................好多這個提示,挖到好多礦................................

INFO [05-16|00:24:54] 🔨 mined potential block                  number=36 hash=95fdfd…1411ee

INFO [05-16|00:24:54] Commit new mining work                   number=37 txs=0 uncles=0 elapsed=122.202µs

###而後中止挖礦:

>miner.stop(

true

###而後再來看看咱們帳戶錢包有多少礦了:

> eth.getBalance(eth.accounts[0])

355000000000000000000

下一篇,我會講一講如何搭建 私有網絡節點羣:

相關文章
相關標籤/搜索