一、ubuntu安装geth
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
二、通过geth启动ETH测试网络
geth --datadir /data/eth/.ethereum/ropsten --port 30301 --rpc --rpcaddr 0.0.0.0 --rpcport 8545 --http.api txpool,personal,eth,net,web3 --syncmode light --ropsten --allow-insecure-unlock
geth详细用法查看geth --help
三、连接节点
geth attach /data/eth/.ethereum/ropsten/geth.ipc
使用eth
可以查看节点基本信息
四、将已有钱包导入测试网络节点中
1、创建文档pk.txt,该文档用来保存需导入的钱包私钥
vim pk.txt
2、将私钥导入,并创建新的地址
geth account import ~/Desktop/pk.txt
3、帮助文档
ubuntu@10-8-153-40:~/.ethereum/keystore$ geth account import -h
import [command options] [arguments...]
geth account import <keyfile>
Imports an unencrypted private key from <keyfile> and creates a new account.
Prints the address.
The keyfile is assumed to contain an unencrypted private key in hexadecimal format.
The account is saved in encrypted format, you are prompted for a password.
You must remember this password to unlock your account in the future.
For non-interactive use the password can be specified with the -password flag:
geth account import [options] <keyfile>
Note:
As you can directly copy your encrypted accounts to another ethereum instance,
this import mechanism is not needed when you transfer an account between
nodes.
ACCOUNT OPTIONS:
--password value Password file to use for non-interactive password input
ETHEREUM OPTIONS:
--datadir value Data directory for the databases and keystore (default: "/home/ubuntu/.ethereum")
--keystore value Directory for the keystore (default = inside the datadir)
--lightkdf Reduce key-derivation RAM & CPU usage at some expense of KDF strength
五、钱包解锁
1、使用rpc连接节点(见三)
2、停止挖矿
> miner.stop()
3、验证是否停止挖矿
> eth.mining
false表示已经停止挖矿
4、查看所有的账号
> eth.accounts
5、解锁第一个用户
> personal.unlockAccount(eth.accounts[0])
6、如果需要继续挖矿执行
> miner.start()