以太坊私有链搭建

已实际操作测试验证,有问题可以一起探讨:个人有道笔记链接

以太坊私有链搭建

以太坊私有链环境搭建

http://www.it-jason.com/archives/395

先总体说一下步骤:

1.操作系统准备

2.golang安装

3.下载以太坊

4.安装以太坊

5.创世区块文件的准备

6.创世区块初始化

7.以太坊启动

创世区块文件

{
    "nonce": "0x0000000000000042",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "difficulty": "0x4000",
    "alloc": {},
    "coinbase": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x12345668",
    "gasLimit": "0xffffffff",
   "config":{  
      "chainId":15,  
      "homesteadBlock":0,  
      "eip155Block":0,  
      "eip158Block":0 
    } 
}

chainId : 以太坊区块链网络Id,ethereum主链是1,私有链只用不要与主链冲突即可。

alloc : 预留账户,如下
“alloc”:{
“0x0000000000000000000000000000000000000001”:{“balance”:”121312321”},
“0x0000000000000000000000000000000000000002”:{“balance”:”121312321”},
}

Coinbase: 旷工账户

Difficulty: 挖矿难度,0x400,这个是简单。

extraData:相当于备注

gasLimit:最小消耗gas

nonce : 64位随机数,用于挖矿,注意他和mixhash的设置需要满足以太坊黄皮书中的要求

parentHash : 上一个区块的Hash值,因为是创世块,石头里蹦出来的,没有在它前面的,所以是0

Timestamp : 时间戳

创世区块初始化

[root@host-10-72-77-171 bin]# geth -datadir "/root/blockchain/data" init init.json 
INFO [05-14|07:06:31] Maximum peer count                       ETH=25 LES=0 total=25
INFO [05-14|07:06:31] Allocated cache and file handles         database=/root/blockchain/data/geth/chaindata cache=16 handles=16
INFO [05-14|07:06:31] Persisted trie from memory database      nodes=0 size=0.00B time=5.264µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [05-14|07:06:31] Successfully wrote genesis state         database=chaindata                            hash=c714d5…60474c
INFO [05-14|07:06:31] Allocated cache and file handles         database=/root/blockchain/data/geth/lightchaindata cache=16 handles=16
INFO [05-14|07:06:31] Persisted trie from memory database      nodes=0 size=0.00B time=3.513µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [05-14|07:06:31] Successfully wrote genesis state         database=lightchaindata     

以太坊启动

使用命令 geth -h 可以查看geth 相关的帮助文档。这里我说几个常用的属性。
    --Identity : 节点身份标识,起个名字
    --datadir : 指定节点存在位置,“data”
    --rpc : 启用http-rpc服务器
    --rpcapi : 基于http-rpc提供的api接口。eth,net,web3,db...
    --rpcaddr : http-rpc服务器接口地址:默认“127.0.0.1    --rpcport : http-rpc 端口(多节点时,不要重复)
    --port : 节点端口号(多节点时,不要重复)
    --networkid : 网络标识符 随便指定一个id(确保多节点是统一网络,保持一致)
[root@host-10-72-77-171 bin]# geth --rpc --rpccorsdomain "*" --datadir "/root/blockchain/data" --port "30303" --rpcapi "db,eth,net,web3" --networkid 100000 console
INFO [05-14|07:07:07] Maximum peer count                       ETH=25 LES=0 total=25
INFO [05-14|07:07:07] Starting peer-to-peer node               instance=Geth/v1.8.2-stable/linux-amd64/go1.8.3
INFO [05-14|07:07:07] Allocated cache and file handles         database=/root/blockchain/data/geth/chaindata cache=768 handles=512
WARN [05-14|07:07:07] Upgrading database to use lookup entries 
INFO [05-14|07:07:07] Initialised chain configuration          config="{ChainID: 15 Homestead: 0 DAO:  DAOSupport: false EIP150:  EIP155: 0 EIP158: 0 Byzantium:  Constantinople:  Engine: unknown}"
INFO [05-14|07:07:07] Disk storage enabled for ethash caches   dir=/root/blockchain/data/geth/ethash count=3
INFO [05-14|07:07:07] Disk storage enabled for ethash DAGs     dir=/root/.ethash                     count=2
INFO [05-14|07:07:07] Initialising Ethereum protocol           versions="[63 62]" network=100000
INFO [05-14|07:07:07] Loaded most recent local header          number=0 hash=c714d5…60474c td=16384
INFO [05-14|07:07:07] Loaded most recent local full block      number=0 hash=c714d5…60474c td=16384
INFO [05-14|07:07:07] Loaded most recent local fast block      number=0 hash=c714d5…60474c td=16384
INFO [05-14|07:07:07] Regenerated local transaction journal    transactions=0 accounts=0
INFO [05-14|07:07:07] Starting P2P networking 
INFO [05-14|07:07:07] Database deduplication successful        deduped=0
INFO [05-14|07:07:10] UDP listener up                          self=enode://5f6c8847f417379bad81c1c2e61c84f17e8e9739349414eec65e8e14d7d33e7af15243fd638cfc30b6434373ce1b88cb264ce9264611c3987f92616298cd2e2a@[::]:30303
INFO [05-14|07:07:10] HTTP endpoint opened                     url=http://127.0.0.1:8545 cors=* vhosts=localhost
INFO [05-14|07:07:10] RLPx listener up                         self=enode://5f6c8847f417379bad81c1c2e61c84f17e8e9739349414eec65e8e14d7d33e7af15243fd638cfc30b6434373ce1b88cb264ce9264611c3987f92616298cd2e2a@[::]:30303
INFO [05-14|07:07:10] IPC endpoint opened                      url=/root/blockchain/data/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.8.2-stable/linux-amd64/go1.8.3
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

>

查看、创建账号

> personal.listAccounts
["0x23b2f955dff331f9680a85139e41d7db81cc59ac", "0xcaceae12023820a33754c9dcacc6867aee1ade13"]

> personal.newAccount()
Passphrase: 
Repeat passphrase: 
"0x2b366bad152dddf98f7c8e4144c6e5529a48f37e"

> personal.listAccounts
["0x23b2f955dff331f9680a85139e41d7db81cc59ac", "0xcaceae12023820a33754c9dcacc6867aee1ade13", "0x2b366bad152dddf98f7c8e4144c6e5529a48f37e"]

查询余额

> web3.fromWei(eth.getBalance(eth.coinbase),"ether")
3645
> web3.fromWei(eth.getBalance(eth.accounts[1]),"ether")
0
> web3.fromWei(eth.getBalance(eth.accounts[2]),"ether")
0
> 

挖矿

> miner.start(1)
INFO [05-14|20:44:07] Updated mining threads                   threads=1
INFO [05-14|20:44:07] Transaction pool price threshold updated price=18000000000
INFO [05-14|20:44:07] Starting mining operation 
null
> INFO [05-14|20:44:07] Commit new mining work                   number=730 txs=0 uncles=0 elapsed=263.516µs
INFO [05-14|20:44:09] Successfully sealed new block            number=730 hash=900ce9…f470f7
INFO [05-14|20:44:09]  mined potential block                  number=730 hash=900ce9…f470f7
INFO [05-14|20:44:09] Commit new mining work                   number=731 txs=0 uncles=0 elapsed=235.184µs
INFO [05-14|20:44:17] Successfully sealed new block            number=731 hash=bf5a8b…6f3c5a
INFO [05-14|20:44:17]  mined potential block                  number=731 hash=bf5a8b…6f3c5a
INFO [05-14|20:44:17] Commit new mining work                   number=732 txs=0 uncles=0 elapsed=97.672µs
INFO [05-14|20:44:19] Successfully sealed new block            number=732 hash=3eee14…1b4c40
INFO [05-14|20:44:19]  mined potential block                  number=732 hash=3eee14…1b4c40
INFO [05-14|20:44:19] Commit new mining work                   number=733 txs=0 uncles=0 elapsed=120.901µs
> minINFO [05-14|20:44:23] Successfully sealed new block            number=733 hash=403486…b54676
INFO [05-14|20:44:23]  mined potential block                  number=733 hash=403486…b54676
INFO [05-14|20:44:23] Commit new mining work                   number=734 txs=0 uncles=0 elapsed=106.64µs
> miner.INFO [05-14|20:44:26] Successfully sealed new block            number=734 hash=6fa39d…c74842
INFO [05-14|20:44:26]  mined potential block                  number=734 hash=6fa39d…c74842
INFO [05-14|20:44:26] Commit new mining work                   number=735 txs=0 uncles=0 elapsed=223.073µs


> miner.stop()
true
> 
> web3.fromWei(eth.getBalance(eth.coinbase),"ether")
3670
> 

转账

> eth.sendTransaction({from:'0x23b2f955dff331f9680a85139e41d7db81cc59ac',to:'0xcaceae12023820a33754c9dcacc6867aee1ade13',value:web3.toWei(1000,"ether")})
Error: authentication needed: password or unlock
    at web3.js:3143:20
    at web3.js:6347:15
    at web3.js:5081:36
    at :1:1

> personal.unlockAccount("0x23b2f955dff331f9680a85139e41d7db81cc59ac","888888",500)
true

> 
> eth.sendTransaction({from:'0x23b2f955dff331f9680a85139e41d7db81cc59ac', to:'0xcaceae12023820a33754c9dcacc6867aee1ade13',value:web3.toWei(500,"ether")})
INFO [05-14|20:50:03] Submitted transaction                    fullhash=0xa153d2940013345e1a0deda583787ed5917e509e53b5f0e5c9e89132002c36cd recipient=0xCaCeAe12023820a33754C9dCAcC6867Aee1aDE13
"0xa153d2940013345e1a0deda583787ed5917e509e53b5f0e5c9e89132002c36cd"
> 

> eth.sendTransaction({from:'0x23b2f955dff331f9680a85139e41d7db81cc59ac', to:'0x2b366bad152dddf98f7c8e4144c6e5529a48f37e',value:web3.toWei(100,"ether")})
INFO [05-14|20:50:28] Submitted transaction                    fullhash=0xcd3c2308e50a4cdc407091bbb951d5e523a8fb9e61cf30794c8a5e6306f7fcf1 recipient=0x2B366BaD152DddF98f7c8E4144c6e5529A48F37E
"0xcd3c2308e50a4cdc407091bbb951d5e523a8fb9e61cf30794c8a5e6306f7fcf1"


> web3.fromWei(eth.getBalance(eth.accounts[0]),"ether")
3670
> web3.fromWei(eth.getBalance(eth.accounts[1]),"ether")
0
> web3.fromWei(eth.getBalance(eth.accounts[2]),"ether")
0

转账后需要启动挖矿才会使得交易生效
> miner.start(1)
INFO [05-14|20:51:25] Updated mining threads                   threads=1
INFO [05-14|20:51:25] Transaction pool price threshold updated price=18000000000
null
> INFO [05-14|20:51:25] Starting mining operation 
INFO [05-14|20:51:25] Commit new mining work                   number=735 txs=2 uncles=0 elapsed=914.115µs
INFO [05-14|20:51:28] Successfully sealed new block            number=735 hash=c982e6…79bae8
INFO [05-14|20:51:28]  block reached canonical chain          number=730 hash=900ce9…f470f7
INFO [05-14|20:51:28]  mined potential block                  number=735 hash=c982e6…79bae8
INFO [05-14|20:51:28] Commit new mining work                   number=736 txs=0 uncles=0 elapsed=132.393µs
INFO [05-14|20:51:28] Successfully sealed new block            number=736 hash=61ea70…33599a
INFO [05-14|20:51:28]  block reached canonical chain          number=731 hash=bf5a8b…6f3c5a
INFO [05-14|20:51:28]  mined potential block                  number=736 hash=61ea70…33599a
INFO [05-14|20:51:28] Commit new mining work                   number=737 txs=0 uncles=0 elapsed=111.211µs
INFO [05-14|20:51:33] Successfully sealed new block            number=737 hash=9d19b4…229eea
INFO [05-14|20:51:33]  block reached canonical chain          number=732 hash=3eee14…1b4c40
INFO [05-14|20:51:33]  mined potential block                  number=737 hash=9d19b4…229eea
INFO [05-14|20:51:33] Commit new mining work                   number=738 txs=0 uncles=0 elapsed=101.021µs
INFO [05-14|20:51:37] Successfully sealed new block            number=738 hash=8974cb…f12f46
INFO [05-14|20:51:37]  block reached canonical chain          number=733 hash=403486…b54676
INFO [05-14|20:51:37]  mined potential block                  number=738 hash=8974cb…f12f46
INFO [05-14|20:51:37] Commit new mining work                   number=739 txs=0 uncles=0 elapsed=137.48µs
INFO [05-14|20:51:43] Successfully sealed new block            number=739 hash=afd02d…0512db
INFO [05-14|20:51:43]  block reached canonical chain          number=734 hash=6fa39d…c74842
INFO [05-14|20:51:43]  mined potential block                  number=739 hash=afd02d…0512db
INFO [05-14|20:51:43] Commit new mining work                   number=740 txs=0 uncles=0 elapsed=124.415µs
INFO [05-14|20:51:44] Successfully sealed new block            number=740 hash=1b4c1f…e56605
INFO [05-14|20:51:44]  block reached canonical chain          number=735 hash=c982e6…79bae8
INFO [05-14|20:51:44]  mined potential block                  number=740 hash=1b4c1f…e56605
INFO [05-14|20:51:44] Commit new mining work                   number=741 txs=0 uncles=0 elapsed=148.473µs
> miner.stop()
true
> 
> web3.fromWei(eth.getBalance(eth.coinbase),"ether")
3100
> web3.fromWei(eth.getBalance(eth.accounts[1]),"ether")
500
> web3.fromWei(eth.getBalance(eth.accounts[2]),"ether")
100

启动多节点、同步

多节点启动

  • CentOS Linux release 7.2.1511
geth --identity "znv etherum" --rpcaddr 0.0.0.0 --rpc --rpcport 8545 --maxpeers 5 --rpcapi "db,eth,net,web3,debug" --networkid 100 --datadir "/root/blockchain/data" --port 30303 console
geth attach ipc://root/blockchain/data/geth.ipc
geth --identity "znv etherum2" --rpcaddr 0.0.0.0 --rpc --rpcport 8546 --maxpeers 5 --rpcapi "db,eth,net,web3,debug" --networkid 100 --datadir "/root/blockchain/data2" --port 30304 console
geth attach ipc://root/blockchain/data2/geth.ipc
  • windows 2012
PS D:\05 BlockChain\Mist\geth> geth --identity "znv win etherum" --rpcaddr 0.0.0.0 --rpc --rpcport 8545 --maxpeers 5 --rpcapi "db,eth,net,web3,debug" --networkid 100 --datadir "C:\Program Files\Geth\chain" --port 30303 console
PS C:\Program Files\Mist> .\Mist.exe

添加多节点

> 
> admin.nodeInfo
{
  enode: "enode://83baf978ba22823b343d9261a6644b2d8f6d579fdf8876d762c26da20c2b316aef159df8c2817ad7500bd575412a1d34028e3ecaa19e9d1d4e777a8586dd1a49@[::]:30304",
  id: "83baf978ba22823b343d9261a6644b2d8f6d579fdf8876d762c26da20c2b316aef159df8c2817ad7500bd575412a1d34028e3ecaa19e9d1d4e777a8586dd1a49",
  ip: "::",
  listenAddr: "[::]:30304",
  name: "Geth/znv etherum2/v1.8.2-stable/linux-amd64/go1.8.3",
  ports: {
    discovery: 30304,
    listener: 30304
  },
  protocols: {
    eth: {
      config: {
        chainId: 15,
        eip150Hash: "0x0000000000000000000000000000000000000000000000000000000000000000",
        eip155Block: 0,
        eip158Block: 0,
        homesteadBlock: 0
      },
      difficulty: 383783597,
      genesis: "0xc714d500378d47ed62e667c65e90e4dfe2534d9346e5063c2d0caaa2b460474c",
      head: "0x7b226732133284b1e8cec85145e32231bccdac9bdb1d24af62967cdb5456dac7",
      network: 100
    }
  }
}

这里”enode://…….” 是指admin.nodeInfo.enode的信息

> admin.addPeer("enode://83baf978ba22823b343d9261a6644b2d8f6d579fdf8876d762c26da20c2b316aef159df8c2817ad7500bd575412a1d34028e3ecaa19e9d1d4e777a8586dd1a49@[::]:30304")
true
> 
> admin.nodeInfo
{
  enode: "enode://5f6c8847f417379bad81c1c2e61c84f17e8e9739349414eec65e8e14d7d33e7af15243fd638cfc30b6434373ce1b88cb264ce9264611c3987f92616298cd2e2a@[::]:30303",
  id: "5f6c8847f417379bad81c1c2e61c84f17e8e9739349414eec65e8e14d7d33e7af15243fd638cfc30b6434373ce1b88cb264ce9264611c3987f92616298cd2e2a",
  ip: "::",
  listenAddr: "[::]:30303",
  name: "Geth/znv etherum/v1.8.2-stable/linux-amd64/go1.8.3",
  ports: {
    discovery: 30303,
    listener: 30303
  },
  protocols: {
    eth: {
      config: {
        chainId: 15,
        eip150Hash: "0x0000000000000000000000000000000000000000000000000000000000000000",
        eip155Block: 0,
        eip158Block: 0,
        homesteadBlock: 0
      },
      difficulty: 395612269,
      genesis: "0xc714d500378d47ed62e667c65e90e4dfe2534d9346e5063c2d0caaa2b460474c",
      head: "0x5273a127959a3e622bdfbb832430602ca7307309fda7d7c47ecd27050daba120",
      network: 100
    }
  }
}
> admin.peers
[{
    caps: ["eth/62", "eth/63"],
    id: "83baf978ba22823b343d9261a6644b2d8f6d579fdf8876d762c26da20c2b316aef159df8c2817ad7500bd575412a1d34028e3ecaa19e9d1d4e777a8586dd1a49",
    name: "Geth/znv etherum2/v1.8.2-stable/linux-amd64/go1.8.3",
    network: {
      inbound: false,
      localAddress: "[::1]:40201",
      remoteAddress: "[::1]:30304",
      static: true,
      trusted: false
    },
    protocols: {
      eth: {
        difficulty: 395334677,
        head: "0xfc8f525a1ec5f807faa5b35a75298778b850b6406cedfe4626b878101a4f328b",
        version: 63
      }
    }
}]
> net.peerCount
1
> eth.syncing
{
  currentBlock: 1243,
  highestBlock: 1247,
  knownStates: 133,
  pulledStates: 133,
  startingBlock: 0
}
> 

列如:

admin.addPeer("enode://83baf978ba22823b343d9261a6644b2d8f6d579fdf8876d762c26da20c2b316aef159df8c2817ad7500bd575412a1d34028e3ecaa19e9d1d4e777a8586dd1a49@10.72.77.171:30304")
admin.addPeer("enode://9720d755481e36f2da26290da621679d3228223af9bdb0923d14d192bf37af2390224e38637291f8186bbaabd14c84d47864891b5f58f4c564e73011f070fe49@10.72.77.167:30303")
admin.addPeer("enode://5f6c8847f417379bad81c1c2e61c84f17e8e9739349414eec65e8e14d7d33e7af15243fd638cfc30b6434373ce1b88cb264ce9264611c3987f92616298cd2e2a@10.72.77.171:30303")

Q&A

  • 多节点同步异常

    1. 问题1:不同节点时间不同步
      解决办法:修改时间,同步

    2. 问题2:同步异常
      解决办法:停止多个节点挖矿,稍后启动

例如:若同步有异常或失败,可以重新启动节点再次尝试同步,成功后有类似打印

INFO [05-17|04:19:12] Imported new chain segment               blocks=1  txs=0 mgas=0.000 elapsed=4.089ms   mgasps=0.000 number=2148 hash=95cc1d…ea6b35 cache=38.97kB
INFO [05-17|04:19:12] Commit new mining work                   number=2149 txs=0 uncles=0 elapsed=101.695µs
INFO [05-17|04:19:12]  block reached canonical chain          number=2143 hash=6152b7…823223
INFO [05-17|04:19:18] Imported new chain segment               blocks=1  txs=0 mgas=0.000 elapsed=3.807ms   mgasps=0.000 number=2149 hash=fd7ac1…862de2 cache=38.97kB
INFO [05-17|04:19:18] Commit new mining work                   number=2150 txs=0 uncles=0 elapsed=155.586µs
INFO [05-17|04:19:18]  block reached canonical chain          number=2144 hash=dc6866…24aab3
INFO [05-17|04:19:20] Imported new chain segment               blocks=1  txs=0 mgas=0.000 elapsed=4.407ms   mgasps=0.000 number=2150 hash=32fd48…761c29 cache=38.97kB
INFO [05-17|04:19:20] Commit new mining work                   number=2151 txs=0 uncles=0 elapsed=125.496µs
INFO [05-17|04:19:20]  block reached canonical chain          number=2145 hash=7f5d92…5f66ff
INFO [05-17|04:19:20] Successfully sealed new block            number=2151 hash=e4e5cf…ae3a16
INFO [05-17|04:19:20]  block reached canonical chain          number=2146 hash=760feb…814e84
INFO [05-17|04:19:20]  mined potential block                  number=2151 hash=e4e5cf…ae3a16
INFO [05-17|04:19:20] Commit new mining work                   number=2152 txs=0 uncles=0 elapsed=117.866µs
INFO [05-17|04:19:22] Successfully sealed new block            number=2152 hash=062660…a9c741
INFO [05-17|04:19:22]  block reached canonical chain          number=2147 hash=d2fdec…09fd1f
INFO [05-17|04:19:22]  mined potential block                  number=2152 hash=062660…a9c741
INFO [05-17|04:19:22] Commit new mining work                   number=2153 txs=0 uncles=0 elapsed=122.851µs
INFO [05-17|04:19:23] Imported new chain segment               blocks=1  txs=0 mgas=0.000 elapsed=3.775ms   mgasps=0.000 number=2153 hash=34d6ca…7b41bd cache=38.97kB
INFO [05-17|04:19:23] Commit new mining work                   number=2154 txs=0 uncles=0 elapsed=119.592µs
  1. 问题3:没有同步
    解决办法:admin.addPeer()添加节点

    • 多节点自动启动(暂未尝试)

智能合约

简单智能合约的编写与编译

IDE browser-solidity

pragma solidity ^0.4.0;

contract SimpleStorage {
    uint storedData;

    function set(uint x) public {
        storedData = x;
    }

    function getString() public constant returns (string) {
        return "HelloWorld Ethereum solidity!";
    }

    function get() public constant returns (uint) {
        return storedData;
    }
}

简单智能合约的编写与编译

将第1步中IDE右侧的Web3 deploy后面文本框的内容粘贴到控制台中,然后回车:

> 
> var simplestorageContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]);
undefined
> var simplestorage = simplestorageContract.new(
...    {
......      from: web3.eth.accounts[0], 
......      data: '0x608060405234801561001057600080fd5b5060df8061001f6000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c146078575b600080fd5b348015605957600080fd5b5060766004803603810190808035906020019092919050505060a0565b005b348015608357600080fd5b50608a60aa565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a723058208b69fbc02c020b5fd556a5b5ff4aa097023d088641fa4fec0b3eaf8015f2fe540029', 
......      gas: '4700000'
......    }, function (e, contract){
......     console.log(e, contract);
......     if (typeof contract.address !== 'undefined') {
.........          console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
.........     }
......  })
INFO [05-14|21:30:24] Submitted contract creation              fullhash=0xb6c56bc6c721f790a35ed161929edb28f0cd868fe38c7d413ffc6716138ebf96 contract=0xB6c6FbEfb1a19118ccc9935c504c979610899dDA
null [object Object]
undefined
> 
> 

这里0xb6c56bc6c721f790a35ed161929edb28f0cd868fe38c7d413ffc6716138ebf96是交易哈希,0xb6c56bc6c721f790a35ed161929edb28f0cd868fe38c7d413ffc6716138ebf96是合约地址,这个地址非常重要

如果有如下报错,先解锁账号

Error: authentication needed: password or unlock undefined
> personal.unlockAccount('0x23b2f955dff331f9680a85139e41d7db81cc59ac','888888',1000)

下面开启挖矿,将合约写进以太坊的区块链,挖矿成功后关闭挖矿:

> 
> miner.start(1)
INFO [05-14|21:32:36] Updated mining threads                   threads=1
INFO [05-14|21:32:36] Transaction pool price threshold updated price=18000000000
INFO [05-14|21:32:36] Starting mining operation 
null
> INFO [05-14|21:32:36] Commit new mining work                   number=746 txs=1 uncles=0 elapsed=758.437µs
INFO [05-14|21:32:38] Successfully sealed new block            number=746 hash=b2d926…41352a
INFO [05-14|21:32:38]  block reached canonical chain          number=741 hash=4430e5887113
INFO [05-14|21:32:38] Commit new mining work                   number=747 txs=0 uncles=0 elapsed=295.97µs
INFO [05-14|21:32:38]  mined potential block                  number=746 hash=b2d926…41352a
null [object Object]
Contract mined! address: 0xb6c6fbefb1a19118ccc9935c504c979610899dda transactionHash: 0xb6c56bc6c721f790a35ed161929edb28f0cd868fe38c7d413ffc6716138ebf96
> miINFO [05-14|21:32:41] Successfully sealed new block            number=747 hash=367fc3…64e31e
INFO [05-14|21:32:41]  block reached canonical chain          number=742 hash=3ab797…9524b4
INFO [05-14|21:32:41]  mined potential block                  number=747 hash=367fc3…64e31e
INFO [05-14|21:32:41] Commit new mining work                   number=748 txs=0 uncles=0 elapsed=122.296µs
> minerINFO [05-14|21:32:44] Successfully sealed new block            number=748 hash=e24939…2963de
INFO [05-14|21:32:44]  block reached canonical chain          number=743 hash=5aa77e…b269d3
INFO [05-14|21:32:44]  mined potential block                  number=748 hash=e24939…2963de
INFO [05-14|21:32:44] Commit new mining work                   number=749 txs=0 uncles=0 elapsed=158.248µs
> miner.stop()
true

智能合约的执行或调用

> simplestorage.set(99,{"from":eth.coinbase})
"0x71a1570bbd4572d2bd40786616ef9494943319c143d6f507a2b4f24029b1a741"
> simplestorage.get()
0

需重新启动挖矿确定交易,挖矿后

> simplestorage.get()
99
> 

我们创建的simplestorage这个JavaScript变量仅仅在当前context中有效,如果我们将控制台关闭,再次打开控制台,这个变量将不复存在。那如何从新的控制台中创建出simplestorage这个变量呢?

我们回到第1步,编译那步。我们将使用编译结果中的ABI

> var abi = [ { "constant":false, "inputs":[ { "name":"x", "type":"uint256" } ], "name":"set", "outputs":[ ], "payable":false, "stateMutability":"nonpayable", "type":"function" }, { "constant":true, "inputs":[ ], "name":"get", "outputs":[ { "name":"", "type":"uint256" } ], "payable":false, "stateMutability":"view", "type":"function" }, { "constant":true, "inputs":[ ], "name":"getString", "outputs":[ { "name":"", "type":"string" } ], "payable":false, "stateMutability":"view", "type":"function" } ]
undefined

> var simplestorage = eth.contract(abi).at("0x385d245f5f2e2e4ba256c05814a0972ba177e6fe")
undefined
> 
> simplestorage.
simplestorage._eth            simplestorage.address         simplestorage.constructor     simplestorage.getString       simplestorage.transactionHash 
simplestorage.abi             simplestorage.allEvents       simplestorage.get             simplestorage.set             
> simplestorage.get()
99

上面代码中我们创建出了simplestorage。其中,eth、contract()和at()都是以太坊提供的API。abi是我们之前创建的JavaScript变量,0x385d245f5f2e2e4ba256c05814a0972ba177e6fe是我们之前记住的智能合约的地址。也可以通过0x385d245f5f2e2e4ba256c05814a0972ba177e6fe

由于simplestorage仅仅是当前context中的一个变量,并不是需要写进区块链的数据,因此这个变量的创建不需要挖矿。后面的 就和之前一样的方式进行set和get操作

Mist / Ethereum-Wallet

windows Server 2012

安装Windows下Geth客户端

  • Windows必须64位系统,从官方网站下载编译好的win64客户端,解压缩即可运行,下载地址如下:
    https://github.com/ethereum/go-ethereum/releases/ 下载后,只有一个Geth.exe的文件。

  • 安装图像化客户端Mist,依然是从官方地址下载编译好的客户端即可,下载地址:
    https://github.com/ethereum/mist/releases/ 下载解压缩后,Ethereum-Wallet即为以太坊图形化界面。

  • 在Geth安装目录下放置初始化创世块文件,同Linux下的init.json一样,如果需要和linux下的节点连接起来,init.json内容必须一样。初始化的网络id也一样;

  • 初始化创世块geth –datadir “%cd%\chain” init init.json; //%cd%:代表Geth安装目录
  • 打开geth控制台geth -datadir “%cd%\chain” console
PS D:\05 BlockChain\Mist\geth> geth --identity "znv win etherum" --rpcaddr 0.0.0.0 --rpc --rpcport 8545 --maxpeers 5 --rpcapi "db,eth,net,web3,debug" --networkid 100 --datadir "C:\Program Files\Geth\chain" --port 30303 console
PS C:\Program Files\Mist> .\Mist.exe
admin.addPeer("enode://83baf978ba22823b343d9261a6644b2d8f6d579fdf8876d762c26da20c2b316aef159df8c2817ad7500bd575412a1d34028e3ecaa19e9d1d4e777a8586dd1a49@10.72.77.171:30304")
admin.addPeer("enode://9720d755481e36f2da26290da621679d3228223af9bdb0923d14d192bf37af2390224e38637291f8186bbaabd14c84d47864891b5f58f4c564e73011f070fe49@10.72.77.167:30303")
admin.addPeer("enode://5f6c8847f417379bad81c1c2e61c84f17e8e9739349414eec65e8e14d7d33e7af15243fd638cfc30b6434373ce1b88cb264ce9264611c3987f92616298cd2e2a@10.72.77.171:30303")
  • windows下的mist,自动连接私有链。

Q&A

Q1: Ethereum Wallet & Mist 差异

参考链接

  • Mist DApp Browser

Mist is the browser for decentralized web apps. What Mozilla Firefox or Google Chrome are for the Web 2.0, the Mist Browser will be for the Web 3.0 (which will be decentralized).

Mist is still in heavy development (for instance it’s not recommended to visit untrusted DApps until the full security audit is done). You can find the releases to date here. The current release allows you to open any Ethereum DApp with the Mist Browser (with the disclaimer above).

  • Ethereum Wallet DApp

All other releases of ‘Mist’ are no Mist releases at all, but a bundle of Mist Browser with a single DApp: The Ethereum Wallet, also known as the Meteor DApp Wallet.

These releases are therefore called Ethereum Wallet as it only offers a bundle of the Mist browser with a single DApp: the wallet.

The future, with Metropolis release, will provide a full Mist Browser able to open any DApp available out there. The Ethereum wallet will only be one among them.

Q2: Ethereum Wallet 节点数据存储路径修改

  1. 描述环境

    安装Ethereum Wallet时,区块链文件存储目录是==C:\Users\Administrator\AppData\Roaming\Ethereum==,准备转移到==E:\Ethereum Wallet\Ethereum==。

  2. 剪切文件夹

    ==C:\Users\Administrator\AppData\Roaming\Ethereum==剪切到==E:\Ethereum Wallet\Ethereum==。切记,这里是剪切,如果==C:\Users\Administrator\AppData\Roaming\Ethereum==这个目录下还有“Ethereum”文件夹,会导致下一步的命令报错,“无法创建该文件”。

  3. 打开命令行窗口CMD,敲入命令,成功创建符号链接:

     mklink /J "C:\Users\Administrator\AppData\Roaming\Ethereum" "E:\Ethereum Wallet\Ethereum"
  4. 打开mist以太坊钱包,验证是否成功

Q3: windows Mist/wallet连接centos节点

PS C:\Program Files\Mist> .\Mist.exe --rpc http://10.72.77.171:8545

ps:需要启动geth的时候加上“–rpc –rpcport 8545”启动参数

Mist 和 geth节点不在同一计算机运行时,可能同步会很慢,可以先停止geth挖矿,再启动

Q4: Mist钱包 无法连接节点

  • 错误信息1:

    Mist钱包 无法连接节点,查看日志获取更多信息


如果你遇到这个错,找到钱包的安装目录,双击启动,别用快捷方式那个图标启动了
PS C:\Program Files\Mist> .\Mist.exe

Q4: Error starting protocol stack: Access is denied.

  • 错误信息2:

    Fatal: Error starting protocol stack: Access is denied.


解决办法:
https://ethereum.stackexchange.com/questions/10616/fatal-error-starting-protocol-stack-access-is-denied
This occurs when you have another instance of geth already running.
Use your Operating System’s process handler to end the process if there are no visible windows.
This happened to me when I started (and then closed) mist before I had set a private network running.
  • 错误信息3(暂未解决):

    The method personal_sendTransaction does not exist/is not available


分析办法:
抓包分析
POST / HTTP/1.1
user-agent: got/6.7.1 (https://github.com/sindresorhus/got)
accept-encoding: gzip,deflate
content-type: application/json
content-length: 301
Host: 10.72.77.171:8545
Connection: close

{"jsonrpc":"2.0","id":"6760149d-3f43-49be-9f41-23b9e9b5a433","method":"personal_sendTransaction","params":[{"data":"","from":"0x23b2f955dff331f9680a85139e41d7db81cc59ac","gas":"0x1d8a8","gasPrice":"0x430e23400","to":"0xcaceae12023820a33754c9dcacc6867aee1ade13","value":"0x98a7d9b8314c0000"},"888888"]}

HTTP/1.1 200 OK
Content-Type: application/json
Date: Fri, 18 May 2018 09:31:48 GMT
Content-Length: 166
Connection: close

{"jsonrpc":"2.0","id":"6760149d-3f43-49be-9f41-23b9e9b5a433","error":{"code":-32601,"message":"The method personal_sendTransaction does not exist/is not available"}}
用jsonrpc相同的params,在171本机测试可以成功:
> var tx = {"data":"","from":"0x23b2f955dff331f9680a85139e41d7db81cc59ac","gas":"0x1d8a8","gasPrice":"0x430e23400","to":"0xcaceae12023820a33754c9dcacc6867aee1ade13","value":"0x98a7d9b8314c0000"}
undefined
> personal.sendTransaction(tx, "888888")
"0x5f1529df204cae4e4a3715f84096a20bb04d62e5d3b34f4882841317db9681b9"
> 
  • 错误信息4
> netINFO [06-08|01:59:31] Block synchronisation started
INFO [06-08|01:59:31] Mining aborted due to sync
INFO [06-08|01:59:31] Imported new chain segment               blocks=1 txs=0 mgas=0.000 elapsed=1.955ms mgasps=0.000 number=9085  hash=371dfc…f87445 cache=726.00B
INFO [06-08|01:59:32] Imported new chain segment               blocks=107 txs=0 mgas=0.000 elapsed=45.912ms mgasps=0.000 number=9192  hash=77aa75…c6ad3a cache=35.51kB
> WARN [06-08|01:59:33] Header broke chain ancestry              peer=83baf978ba22823b number=20662 hash=5f56ce…3fe2bf
INFO [06-08|01:59:33] Imported new chain segment               blocks=697 txs=0 mgas=0.000 elapsed=1.615s   mgasps=0.000 number=9889  hash=34bc5a…a09a54 cache=42.40kB
INFO [06-08|01:59:34] Imported new chain segment               blocks=2048 txs=4 mgas=2.025 elapsed=725.578ms mgasps=2.791 number=11937 hash=f5de6d…aaff22 cache=60.79kB
INFO [06-08|01:59:35] Imported new chain segment               blocks=2048 txs=0 mgas=0.000 elapsed=754.876ms mgasps=0.000 number=13985 hash=533f26…626077 cache=60.44kB
INFO [06-08|01:59:36] Imported new chain segment               blocks=2048 txs=0 mgas=0.000 elapsed=791.031ms mgasps=0.000 number=16033 hash=dc1052…30b66f cache=61.28kB
INFO [06-08|01:59:36] Imported new chain segment               blocks=2048 txs=0 mgas=0.000 elapsed=718.757ms mgasps=0.000 number=18081 hash=8770e44fc522 cache=60.82kB
INFO [06-08|01:59:37] Imported new chain segment               blocks=2048 txs=0 mgas=0.000 elapsed=699.193ms mgasps=0.000 number=20129 hash=270093…fe8df1 cache=59.98kB
WARN [06-08|01:59:37] Synchronisation failed, dropping peer    peer=83baf978ba22823b err="retrieved hash chain is invalid"
INFO [06-08|01:59:37] Starting mining operation
INFO [06-08|01:59:37] Commit new mining work                   number=20130 txs=0 uncles=0 elapsed=0s
INFO [06-08|01:59:37] ⑂ block  became a side fork              number=9085  hash=4793e041c54d
INFO [06-08|01:59:51] Successfully sealed new block            number=20130 hash=8f5a10…3f8ae2
INFO [06-08|01:59:51] ? mined potential block                  number=20130 hash=8f5a10…3f8ae2
INFO [06-08|01:59:51] Commit new mining work                   number=20131 txs=0 uncles=0 elapsed=0s
> exitINFO [06-08|02:00:01] Imported new chain segment               blocks=1    txs=0 mgas=0.000 elapsed=965.2µs   mgasps=0.000 number=20130 hash=dfb2fd…7ab1ee cache=60.23kB
WARN [06-08|02:00:01] Header broke chain ancestry              peer=83baf978ba22823b number=20663 hash=cfd10e…5f8922
INFO [06-08|02:00:02] Imported new chain segment               blocks=192  txs=0 mgas=0.000 elapsed=77.115ms  mgasps=0.000 number=20322 hash=356b9b…90db8b cache=59.75kB
ERROR[06-08|02:00:02] Failed to reset txpool state             err="missing trie node 5c6b21bf3d13c1d87b8c88ac43659a01873c01b3e6e21cdb2bfb9b813454b61c (path )"
INFO [06-08|02:00:02] Commit new mining work                   number=20323 txs=0 uncles=0 elapsed=27.382ms
INFO [06-08|02:00:02] ⑂ block  became a side fork              number=20130 hash=8f5a10…3f8ae2
INFO [06-08|02:00:02] Commit new mining work                   number=20450 txs=0 uncles=0 elapsed=0s
INFO [06-08|02:00:02] Imported new chain segment               blocks=192  txs=0 mgas=0.000 elapsed=62.523ms  mgasps=0.000 number=20514 hash=2ce26e…53b506 cache=58.95kB
INFO [06-08|02:00:02] Commit new mining work                   number=20515 txs=0 uncles=0 elapsed=0s
WARN [06-08|02:00:02] Synchronisation failed, dropping peer    peer=83baf978ba22823b err="retrieved hash chain is invalid"
WARN [06-08|02:00:31] Header broke chain ancestry              peer=83baf978ba22823b number=20664 hash=887ec9…81cecd
WARN [06-08|02:00:32] Synchronisation failed, dropping peer    peer=83baf978ba22823b err="retrieved hash chain is invalid"
INFO [06-08|02:00:35] Successfully sealed new block            number=20515 hash=9c41a2…451e7c
INFO [06-08|02:00:35] ? mined potential block                  number=20515 hash=9c41a2…451e7c
INFO [06-08|02:00:35] Commit new mining work                   number=20516 txs=0 uncles=0 elapsed=0s
WARN [06-08|02:01:01] Header broke chain ancestry              peer=83baf978ba22823b number=20664 hash=887ec9…81cecd
WARN [06-08|02:01:02] Synchronisation failed, dropping peer    peer=83baf978ba22823b err="retrieved hash chain is invalid"
INFO [06-08|02:01:18] Successfully sealed new block            number=20516 hash=443709486e0c
INFO [06-08|02:01:18] ? mined potential block                  number=20516 hash=443709486e0c
INFO [06-08|02:01:18] Commit new mining work                   number=20517 txs=0 uncles=0 elapsed=0s
WARN [06-08|02:01:41] Header broke chain ancestry              peer=83baf978ba22823b number=20665 hash=8cf5c6…12b743
WARN [06-08|02:01:42] Synchronisation failed, dropping peer    peer=83baf978ba22823b err="retrieved hash chain is invalid"
WARN [06-08|02:02:21] Header broke chain ancestry              peer=83baf978ba22823b number=20667 hash=4ca953…a03a69
WARN [06-08|02:02:22] Synchronisation failed, dropping peer    peer=83baf978ba22823b err="retrieved hash chain is invalid"
INFO [06-08|02:02:34] Successfully sealed new block            number=20517 hash=834204…c45702
INFO [06-08|02:02:34] ? mined potential block                  number=20517 hash=834204…c45702
INFO [06-08|02:02:34] Commit new mining work                   number=20518 txs=0 uncles=0 elapsed=0s
WARN [06-08|02:02:46] System clock seems off by -8h0m1.193354666s, which can prevent network connectivity
WARN [06-08|02:07:34] Please enable network time synchronisation in system settings.
WARN [06-08|02:02:51] Header broke chain ancestry              peer=83baf978ba22823b number=20667 hash=4ca953…a03a69
INFO [06-08|02:03:11] Successfully sealed new block            number=20518 hash=8fd86e…445907
INFO [06-08|02:07:34] ? mined potential block                  number=20518 hash=8fd86e…445907
INFO [06-08|02:07:34] Commit new mining work                   number=20519 txs=0 uncles=0 elapsed=0s

INFO [06-08|02:07:34] HTTP endpoint closed                     url=http://0.0.0.0:8545
INFO [06-08|02:07:34] IPC endpoint closed                      endpoint=\\\\.\\pipe\\geth.ipc
INFO [06-08|02:07:34] Writing cached state to disk             block=20518 hash=8fd86e…445907 root=e2a716…081e23
INFO [06-08|02:07:34] Persisted trie from memory database      nodes=19 size=9.54kB time=0s gcnodes=26003 gcsize=4.40mBgctime=49.5008ms livenodes=284 livesize=49.05kB
INFO [06-08|02:07:34] Writing cached state to disk             block=20517 hash=834204…c45702 root=55627c…6d298b
INFO [06-08|02:07:34] Persisted trie from memory database      nodes=2  size=360.00B time=0s gcnodes=0     gcsize=0.00B gctime=0s        livenodes=282 livesize=48.70kB
INFO [06-08|02:07:34] Writing cached state to disk             block=20391 hash=8f8393…63071d root=6175d7…d2fc92
INFO [06-08|02:07:34] Persisted trie from memory database      nodes=5  size=773.00B time=0s gcnodes=0     gcsize=0.00B gctime=0s        livenodes=277 livesize=47.92kB
INFO [06-08|02:07:34] Blockchain manager stopped
INFO [06-08|02:07:34] Stopping Ethereum protocol
WARN [06-08|02:07:34] Synchronisation failed, dropping peer    peer=83baf978ba22823b err="retrieved hash chain is invalid"
INFO [06-08|02:07:34] Ethereum protocol stopped
INFO [06-08|02:07:34] Transaction pool stopped
INFO [06-08|02:07:34] Database closed                          database="C:\\Program Files\\Geth\\chain\\geth\\chaindata"
PS C:\Users\Administrator>
PS C:\Users\Administrator>

geth、wallet等命令信息

Mist.exe –help信息

PS C:\Program Files\Mist> .\Mist.exe --help
PS C:\Program Files\Mist>
Usage: Mist.exe --help [Mist options] [Node options]

Mist options:
  --mode, -m              App UI mode: wallet, mist.  [string] [default: "mist"]
  --node                  Node to use: geth, eth        [string] [default: null]
  --network               Network to connect to: main, test
                                                        [string] [default: null]
  --rpc                   Path to node IPC socket file OR HTTP RPC hostport (if
                          IPC socket file then --node-ipcpath will be set with
                          this value).                                  [string]
  --swarmurl              URL serving the Swarm HTTP API. If null, Mist will
                          open a local node.
                                     [string] [default: "http://localhost:8500"]
  --gethpath              Path to Geth executable to use instead of default.
                                                                        [string]
  --ethpath               Path to Eth executable to use instead of default.
                                                                        [string]
  --ignore-gpu-blacklist  Ignores GPU blacklist (needed for some Linux
                          installations).                              [boolean]
  --reset-tabs            Reset Mist tabs to their default settings.   [boolean]
  --logfile               Logs will be written to this file in addition to the
                          console.                                      [string]
  --loglevel              Minimum logging threshold: info, debug, error, trace
                          (shows all logs, including possible passwords over
                          IPC!).                      [string] [default: "info"]
  --syncmode              Geth synchronization mode: [fast|light|full]  [string]
  --version, -v           Display Mist version.                        [boolean]
  --skiptimesynccheck     Disable checks for the presence of automatic time sync
                          on your OS.                                  [boolean]

Node options:
  -  To pass options to the underlying node (e.g. Geth) use the --node- prefix,
     e.g. --node-datadir

Options:
  -h, --help  Show help                                                [boolean]

Ethereum Wallet.exe –help信息

PS C:\Program Files\Ethereum-Wallet> .\Wallet.exe --help
PS C:\Program Files\Ethereum-Wallet>
Usage: Wallet.exe --help [Mist options] [Node options]

Mist options:
  --mode, -m              App UI mode: wallet, mist.[string] [default: "wallet"]
  --node                  Node to use: geth, eth        [string] [default: null]
  --network               Network to connect to: main, test
                                                        [string] [default: null]
  --rpc                   Path to node IPC socket file OR HTTP RPC hostport (if
                          IPC socket file then --node-ipcpath will be set with
                          this value).                                  [string]
  --swarmurl              URL serving the Swarm HTTP API. If null, Mist will
                          open a local node.
                                     [string] [default: "http://localhost:8500"]
  --gethpath              Path to Geth executable to use instead of default.
                                                                        [string]
  --ethpath               Path to Eth executable to use instead of default.
                                                                        [string]
  --ignore-gpu-blacklist  Ignores GPU blacklist (needed for some Linux
                          installations).                              [boolean]
  --reset-tabs            Reset Mist tabs to their default settings.   [boolean]
  --logfile               Logs will be written to this file in addition to the
                          console.                                      [string]
  --loglevel              Minimum logging threshold: info, debug, error, trace
                          (shows all logs, including possible passwords over
                          IPC!).                      [string] [default: "info"]
  --syncmode              Geth synchronization mode: [fast|light|full]  [string]
  --version, -v           Display Mist version.                        [boolean]
  --skiptimesynccheck     Disable checks for the presence of automatic time sync
                          on your OS.                                  [boolean]

Node options:
  -  To pass options to the underlying node (e.g. Geth) use the --node- prefix,
     e.g. --node-datadir

Options:
  -h, --help  Show help                                                [boolean]

geth –help信息

[root@host-10-72-77-171 ~]# geth --help 
NAME:
   geth - the go-ethereum command line interface

   Copyright 2013-2017 The go-ethereum Authors

USAGE:
   geth [options] command [command options] [arguments...]

VERSION:
   1.8.2-stable

COMMANDS:
   account     Manage accounts
   attach      Start an interactive JavaScript environment (connect to node)
   bug         opens a window to report a bug on the geth repo
   console     Start an interactive JavaScript environment
   copydb      Create a local chain from a target chaindata folder
   dump        Dump a specific block from storage
   dumpconfig  Show configuration values
   export      Export blockchain into file
   import      Import a blockchain file
   init        Bootstrap and initialize a new genesis block
   js          Execute the specified JavaScript files
   license     Display license information
   makecache   Generate ethash verification cache (for testing)
   makedag     Generate ethash mining DAG (for testing)
   monitor     Monitor and visualize node metrics
   removedb    Remove blockchain and state databases
   version     Print version numbers
   wallet      Manage Ethereum presale wallets
   help, h     Shows a list of commands or help for one command

ETHEREUM OPTIONS:
  --config value               TOML configuration file
  --datadir "/root/.ethereum"  Data directory for the databases and keystore
  --keystore                   Directory for the keystore (default = inside the datadir)
  --nousb                      Disables monitoring for and managing USB hardware wallets
  --networkid value            Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby) (default: 1)
  --testnet                    Ropsten network: pre-configured proof-of-work test network
  --rinkeby                    Rinkeby network: pre-configured proof-of-authority test network
  --syncmode "fast"            Blockchain sync mode ("fast", "full", or "light")
  --gcmode value               Blockchain garbage collection mode ("full", "archive") (default: "full")
  --ethstats value             Reporting URL of a ethstats service (nodename:secret@host:port)
  --identity value             Custom node name
  --lightserv value            Maximum percentage of time allowed for serving LES requests (0-90) (default: 0)
  --lightpeers value           Maximum number of LES client peers (default: 100)
  --lightkdf                   Reduce key-derivation RAM & CPU usage at some expense of KDF strength

DEVELOPER CHAIN OPTIONS:
  --dev               Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
  --dev.period value  Block period to use in developer mode (0 = mine only if transaction pending) (default: 0)

ETHASH OPTIONS:
  --ethash.cachedir                Directory to store the ethash verification caches (default = inside the datadir)
  --ethash.cachesinmem value       Number of recent ethash caches to keep in memory (16MB each) (default: 2)
  --ethash.cachesondisk value      Number of recent ethash caches to keep on disk (16MB each) (default: 3)
  --ethash.dagdir "/root/.ethash"  Directory to store the ethash mining DAGs (default = inside home folder)
  --ethash.dagsinmem value         Number of recent ethash mining DAGs to keep in memory (1+GB each) (default: 1)
  --ethash.dagsondisk value        Number of recent ethash mining DAGs to keep on disk (1+GB each) (default: 2)

TRANSACTION POOL OPTIONS:
  --txpool.nolocals            Disables price exemptions for locally submitted transactions
  --txpool.journal value       Disk journal for local transaction to survive node restarts (default: "transactions.rlp")
  --txpool.rejournal value     Time interval to regenerate the local transaction journal (default: 1h0m0s)
  --txpool.pricelimit value    Minimum gas price limit to enforce for acceptance into the pool (default: 1)
  --txpool.pricebump value     Price bump percentage to replace an already existing transaction (default: 10)
  --txpool.accountslots value  Minimum number of executable transaction slots guaranteed per account (default: 16)
  --txpool.globalslots value   Maximum number of executable transaction slots for all accounts (default: 4096)
  --txpool.accountqueue value  Maximum number of non-executable transaction slots permitted per account (default: 64)
  --txpool.globalqueue value   Maximum number of non-executable transaction slots for all accounts (default: 1024)
  --txpool.lifetime value      Maximum amount of time non-executable transaction are queued (default: 3h0m0s)

PERFORMANCE TUNING OPTIONS:
  --cache value            Megabytes of memory allocated to internal caching (default: 1024)
  --cache.database value   Percentage of cache memory allowance to use for database io (default: 75)
  --cache.gc value         Percentage of cache memory allowance to use for trie pruning (default: 25)
  --trie-cache-gens value  Number of trie node generations to keep in memory (default: 120)

ACCOUNT OPTIONS:
  --unlock value    Comma separated list of accounts to unlock
  --password value  Password file to use for non-interactive password input

API AND CONSOLE OPTIONS:
  --rpc                  Enable the HTTP-RPC server
  --rpcaddr value        HTTP-RPC server listening interface (default: "localhost")
  --rpcport value        HTTP-RPC server listening port (default: 8545)
  --rpcapi value         API's offered over the HTTP-RPC interface
  --ws                   Enable the WS-RPC server
  --wsaddr value         WS-RPC server listening interface (default: "localhost")
  --wsport value         WS-RPC server listening port (default: 8546)
  --wsapi value          API's offered over the WS-RPC interface
  --wsorigins value      Origins from which to accept websockets requests
  --ipcdisable           Disable the IPC-RPC server
  --ipcpath              Filename for IPC socket/pipe within the datadir (explicit paths escape it)
  --rpccorsdomain value  Comma separated list of domains from which to accept cross origin requests (browser enforced)
  --rpcvhosts value      Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: "localhost")
  --jspath loadScript    JavaScript root path for loadScript (default: ".")
  --exec value           Execute JavaScript statement
  --preload value        Comma separated list of JavaScript files to preload into the console

NETWORKING OPTIONS:
  --bootnodes value     Comma separated enode URLs for P2P discovery bootstrap (set v4+v5 instead for light servers)
  --bootnodesv4 value   Comma separated enode URLs for P2P v4 discovery bootstrap (light server, full nodes)
  --bootnodesv5 value   Comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes)
  --port value          Network listening port (default: 30303)
  --maxpeers value      Maximum number of network peers (network disabled if set to 0) (default: 25)
  --maxpendpeers value  Maximum number of pending connection attempts (defaults used if set to 0) (default: 0)
  --nat value           NAT port mapping mechanism (any|none|upnp|pmp|extip:) (default: "any")
  --nodiscover          Disables the peer discovery mechanism (manual peer addition)
  --v5disc              Enables the experimental RLPx V5 (Topic Discovery) mechanism
  --netrestrict value   Restricts network communication to the given IP networks (CIDR masks)
  --nodekey value       P2P node key file
  --nodekeyhex value    P2P node key as hex (for testing)

MINER OPTIONS:
  --mine                    Enable mining
  --minerthreads value      Number of CPU threads to use for mining (default: 2)
  --etherbase value         Public address for block mining rewards (default = first account created) (default: "0")
  --targetgaslimit value    Target gas limit sets the artificial target gas floor for the blocks to mine (default: 4712388)
  --gasprice "18000000000"  Minimal gas price to accept for mining a transactions
  --extradata value         Block extra data set by the miner (default = client version)

GAS PRICE ORACLE OPTIONS:
  --gpoblocks value      Number of recent blocks to check for gas prices (default: 20)
  --gpopercentile value  Suggested gas price is the given percentile of a set of recent transaction gas prices (default: 60)

VIRTUAL MACHINE OPTIONS:
  --vmdebug  Record information useful for VM and contract debugging

LOGGING AND DEBUGGING OPTIONS:
  --metrics                 Enable metrics collection and reporting
  --fakepow                 Disables proof-of-work verification
  --nocompaction            Disables db compaction after import
  --verbosity value         Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail (default: 3)
  --vmodule value           Per-module verbosity: comma-separated list of =<level> (e.g. eth/*=5,p2p=4)
  --backtrace value         Request a stack trace at a specific logging statement (e.g. "block.go:271")
  --debug                   Prepends log messages with call-site location (file and line number)
  --pprof                   Enable the pprof HTTP server
  --pprofaddr value         pprof HTTP server listening interface (default: "127.0.0.1")
  --pprofport value         pprof HTTP server listening port (default: 6060)
  --memprofilerate value    Turn on memory profiling with the given rate (default: 524288)
  --blockprofilerate value  Turn on block profiling with the given rate (default: 0)
  --cpuprofile value        Write CPU profile to the given file
  --trace value             Write execution trace to the given file

WHISPER (EXPERIMENTAL) OPTIONS:
  --shh                       Enable Whisper
  --shh.maxmessagesize value  Max message size accepted (default: 1048576)
  --shh.pow value             Minimum POW accepted (default: 0.2)

DEPRECATED OPTIONS:
  --fast   Enable fast syncing through state downloads
  --light  Enable light client mode

MISC OPTIONS:
  --help, -h  show help


COPYRIGHT:
   Copyright 2013-2017 The go-ethereum Authors

你可能感兴趣的:(区块链,以太坊Ethereum)