常用的ETH命令

一、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()
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值