Back

[**] 以太坊钱包的安装方式. ubuntu下. 以及基本用法 . geth linux

发布时间: 2018-01-17 02:32:00

参考:   https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu

非常完整的文档:    https://ethereum.gitbooks.io/frontier-guide/content/listing_accounts.html

步骤很简单;

注意: 硬件要求机器的内存在20G以上.  否则很容易出现 死循环的情况( 下载不完全, 一直在sync ,  一直sync不下来. 使用这个命令可以查看是否下载完全: 

(运行下面的命令的前提,是 geth的启动时要加上 --rpc这样的参数, 例如:    
$ geth --rpc --rpcapi "db,eth,net,web3,personal" --fast --datadir /opt/geth/     )

$ curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBalance","params": ["0x8f5ae589fd2467396c8b25559637dbf5c4401464", "latest"],"id":1}' 127.0.0.1:8545
我在  google cloud上, 用一台 16G的机器, 下载10个小时, 总是卡在99.99%上 (总体block是 570000, 我的就会卡在 569988 这样的位置.跟最新的block总是差几十个)

1. 安装

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum

2. 建立账号:

siwei@siwei-linux:/workspace$ geth account new
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase: 
Repeat passphrase: 
Address: {8f5ae589fd2467396c8b25559637dbf5c4401464}

3. 运行:  $ geth 

如果是第一次运行的话,就会发现所有的数据都会被下载到home目录下.  截止 2018.1.17,  数据超过了6G.  

所以需要耗时, 耗费CPU 

4. 进入到  console:   $  geth console   ( 当第一次的数据没有被同步下来的时候,是无法打开的.) 

5. 查看余额:   看上面的链接. TODO

6. 记得,如果你的keystore 目录不在默认的 HOME目录下,需要每次敲命令的时候,都加上:  --datadir 参数,例如:

$ geth account list --datadir /workspace/.ethereum/
Account #0: {8f5ae589fd2467396c8b25559637dbf5c44  } keystore:///workspace/.ethereum/keystore/UTC-- ... 

7. 如果是跟 peatio结合,需要做 json-rpc的话, 需要在启动的时候增加参数; 

geth --rpc --rpcapi "db,eth,net,web3,personal" --fast --datadir /opt/geth/

 json-rpc 的方式访问geth:  

$ curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "method": "personal_newAccount", "params": ["666666"], "id": 6}' localhost:8545

就可以了. 

返回: 

{"jsonrpc":"2.0","id":6,"result":"0x9a1fbabf0707b1df4f3c306b8adb29842ea622d5"}

Back