一、建立下载环境
在CentOS上可以直接用yum
在Ubuntu上可以直接用apt-get
打开mac需要安装Brew自动化安装工具,打开命令行终端
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装以太坊软件仓库
#Mac
$brew tap ethereum/ethereum //for Mac
#ubuntu
$ 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$yum //for CentOS
二、安装以太坊客户端go-ethereum和钱包工具ethereum-wallet
安装以太坊客户端
$brew install ethereum //for Mac
$apt-get install ethereum //for Ubuntu
$yum install ethereum //for CentOS
$geth --help //能成功显示输出帮助,则表示已经成功安装
$brew install caskroom/cask/ethereum-wallet //for Mac
安装成功,会在桌面看到
钱包应用图标三、环境测试
$geth --help //能运行此命令,代表以太坊环境已经安装成功
四、交互式命令行测试
$ geth --dev console //交互式命令行
INFO [03-13|00:00:57] Maximum peer count ETH=25 LES=0 total=25 INFO [03-13|00:00:59] Using developer account address=0xa978AE0300fcf8cBF9833810dEb9ff805D4F19D5 ////使用开发账号,address就是开发账号的标识
INFO [03-13|00:00:59] Starting peer-to-peer node instance=Geth/v1.8.2-stable/darwin-amd64/go1.10
INFO [03-13|00:00:59] Writing custom genesis block
INFO [03-13|00:00:59] Persisted trie from memory database nodes=11 size=2.17kB time=220.63µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [03-13|00:00:59] Initialised chain configuration config="{ChainID: 1337 Homestead: 0 DAO: DAOSupport: false EIP150: 0 EIP155: 0 EIP158: 0 Byzantium: 0 Constantinople: Engine: clique}"
INFO [03-13|00:00:59] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [03-13|00:00:59] Loaded most recent local header number=0 hash=796210…45d82f td=1
INFO [03-13|00:00:59] Loaded most recent local full block number=0 hash=796210…45d82f td=1
INFO [03-13|00:00:59] Loaded most recent local fast block number=0 hash=796210…45d82f td=1
INFO [03-13|00:00:59] Starting P2P networking //启动p2p网络
INFO [03-13|00:00:59] started whisper v.5.0
INFO [03-13|00:00:59] RLPx listener up self="enode://2655e79a2ed63f66c44bf2ff830cf8c5a6872586cf795489b4854f9143829dc2d5287003a8c0147a5b6cb9796a85c31b14c780e003324450ae9a6355a5f95c2c@[::]:54491?discport=0"
INFO [03-13|00:00:59] IPC endpoint opened url=/var/folders/q0/kd8_qrb93db7qqglhwmp5qt00000gn/T/geth.ipc
INFO [03-13|00:00:59] Transaction pool price threshold updated price=18000000000
INFO [03-13|00:00:59] Etherbase automatically configured address=0xa978AE0300fcf8cBF9833810dEb9ff805D4F19D5 //自动设置测试账号为基础账号
INFO [03-13|00:00:59] Starting mining operation //开始挖矿
INFO [03-13|00:00:59] Commit new mining work number=1 txs=0 uncles=0 elapsed=285.07µs
WARN [03-13|00:00:59] Block sealing failed err="waiting for transactions"Welcome to the Geth JavaScript console!
instance: Geth/v1.8.2-stable/darwin-amd64/go1.10
coinbase: 0xa978ae0300fcf8cbf9833810deb9ff805d4f19d5 //旷工账号,挖矿的奖励自动打入此账号,也是启动时建立的开发账号
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: //没有指定datadir目录,因此启动仅为测试交互,内存临时存储
modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0 //以太坊环境的所有支持模块>INFO [03-13|00:00:59] Mapped network port proto=tcp extport=54491 intport=54491 interface=NAT-PMP(192.168.2.1)
>
· eth:包含一些跟操作区块链相关的方法
· net:包含以下查看p2p网络状态的方法
· admin:包含一些与管理节点相关的方法
· miner:包含启动&停止挖矿的一些方法
· personal:主要包含一些管理账户的方法
· txpool:包含一些查看交易内存池的方法
· web3:包含了以上对象,还包含一些单位换算的方法
到此,交互式命令行已经启动,来个简单的测试,查看当前私链上有几个用户
>eth.accounts // 查看当前用户,返回的是个数组
["0xa978ae0300fcf8cbf9833810deb9ff805d4f19d5"]
网友评论