以太币私有链搭建教程

sudo apt-get update

sudo apt-get install software-properties-common

sudo add-apt-repository -y ppa:ethereum/ethereum

sudo add-apt-repository -y ppa:ethereum/ethereum-dev

sudo apt-get update

sudo apt-get install ethereum

geth #启动

创始块配置文件 piccgenesis.json

{
  "config": {
        "chainId": 10,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc"      : {},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x02000000",
  "extraData"  : "",
  "gasLimit"   : "0x2fefd8",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

mixhash

与nonce配合用于挖矿,由上一个区块的一部分生成的hash。注意他和nonce的设置需要满足以太坊的Yellow paper, 4.3.4. Block Header Validity, (44)章节所描述的条件。.
nonce nonce就是一个64位随机数,用于挖矿,注意他和mixhash的设置需要满足以太坊的Yellow paper, 4.3.4. Block Header Validity, (44)章节所描述的条件。
difficulty 设置当前区块的难度,如果难度过大,cpu挖矿就很难,这里设置较小难度
alloc 用来预置账号以及账号的以太币数量,因为私有链挖矿比较容易,所以我们不需要预置有币的账号,需要的时候自己创建即可以。
coinbase 矿工的账号,随便填
timestamp 设置创世块的时间戳
parentHash 上一个区块的hash值,因为是创世块,所以这个值是0
extraData 附加信息,随便填,可以填你的个性信息
gasLimit 该值设置对GAS的消耗总量限制,用来限制区块能包含的交易信息总和,因为我们是私有链,所以填最大。
geth  --datadir "Your/Path" init piccgenesis.json

创建数据存放地址并初始化创世块

geth --identity "YourName"  --rpc  --rpccorsdomain "*" --datadir "Your/Path" --port "30303"  --rpcapi "db,eth,net,web3" --networkid  95518  console

#如果nohup 请去掉 console

从第二个节点连接。创建目录并将piccgenesis.json拷贝进去。

geth --datadir . init ./piccgenesis.json  #初始化目录
geth --datadir . --networkid 95518 --ipcdisable --port 61911 --rpcport 8101 --bootnodes "enode://8a0127669dc890530d868aa2a08efaff12933c885da21882ed935f563b7cdb7aa3497aa24807bc348c143017dba4c4433d97e64571a1962e257726a7c0725ed8@172.18.100.205:8888" console

创建账号

personal.newAccount()

#启动挖矿
miner.start()

#查看账户余额,不为零即已经在挖矿了
eth.getBalance(eth.accounts[0])

显卡挖矿

下载二进制安装包

https://github.com/ethereum-mining/ethminer/releases

或(注意两种安装方式的命令不一样,请  -h 查看)

apt-get install ethminer
ethminer -G

解锁账户

personal.unlockAccount("0x00530bc8552639fd8479c22f403e84fe5e98896f","===pwd===")

转账3以太币

eth.sendTransaction({from:"0x00530bc8552639fd8479c22f403e84fe5e98896f",to:"0xa6993059b5a31e53f4df0e84a59ccf13abf86b86",value:web3.toWei(3,"ether")})

矿池挖矿

./ethminer --farm-recheck 2000 -G -S us2.ethpool.org:3333 -FS us1.ethpool.org:3333 -O 0x550ce8f9cacae8d5137feb704fbfa45e213bcd30

 

CBB(抄币币)的创世节点:enode://3251729f9c8622826f9a94c40c6f8566505ffd2f34771f77468797858cae8f16b7e7b923a694431f14815b7460c910349d981801a2637a30a8bc503eedee781d@13.115.164.167:30303

配置文件:

 
{
        "config": {
                "chainId": 10,
                        "homesteadBlock": 0,
                        "eip155Block": 0,
                        "eip158Block": 0
        },
                "alloc"      : {},
                "coinbase"   : "0x0000000000000000000000000000000000000000",
                "difficulty" : "0x020000",
                "extraData"  : "",
                "gasLimit"   : "0x2fefd8",
                "nonce"      : "0x0000000000000042",
                "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
                "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
                "timestamp"  : "0x00"
}

发表评论

电子邮件地址不会被公开。

This site uses Akismet to reduce spam. Learn how your comment data is processed.