geth - the go-ethereum command line interface 以太坊命令行接口
格式:
geth [options] command [command options] [arguments...]
支持的命令:
account 管理账户
attach 启动交互式JavaScript环境(连接到节点)
bug 上报bug Issues
console 启动交互式JavaScript环境
copydb 从目标chaindata文件夹创建本地链
dump Dump(分析)一个特定的块存储
dumpconfig 显示配置值
export 导出区块链到文件
import 导入一个区块链文件
init 启动并初始化一个新的创世纪块
js 执行指定的JavaScript文件(多个)
license 显示许可信息
makecache 生成ethash验证缓存(用于测试)
makedag 生成ethash 挖矿DAG(用于测试)
monitor 监控和可视化节点指标
removedb 删除区块链和状态数据库
version 打印版本号
wallet 管理Ethereum预售钱包
help,h 显示一个命令或帮助一个命令列表
geth命令说明:
1.account
管理账户,列举所有已存在的账户信息,导入一个私钥来生成一个新账户,创建新账户或更新存在的账户
它支持交互模式(即当提示输入密码时)和非交互模式(通过给定密码文件提供密码。非交互模式仅用于在测试网络或已知的安全环境中进行脚本化使用。
确保您在创建新帐户(使用新帐户或导入帐户)时记住您给出的密码。没有它,你就不能解锁你的账户。
注意,不支持以未加密格式导出密钥。
密钥存储在/keystore下。通过简单的复制,在ethereum节点之间传输整个目录或其中的单个键是安全的。
确保你定期备份你的钥匙。
userdeMacBook-Pro:~ user$ geth account -h
NAME:
geth account - USAGE:
geth account command [command options] [arguments...] COMMANDS:
list Print summary of existing accounts 打印现有账户摘要
new Create a new account 创建新账户
update Update an existing account 更新现有账户
import Import a private key into a new account 将私钥导入生成新帐户 OPTIONS:
--help, -h show help
1> list
格式:
list [command options] [arguments...]
选项:
userdeMacBook-Pro:~ user$ geth account list -h ETHEREUM OPTIONS:
--datadir "/Users/user/Library/Ethereum" Data directory for the databases and keystore 指明数据库和密钥存储文件的数据目录
--keystore Directory for the keystore (default = inside the datadir) 密钥存储文件的数据目录(默认在--datadir参数指定的目录下)
打印所有帐户的简短摘要
举例:
userdeMacBook-Pro:~ user$ geth account list --datadir './today2/data0'
INFO [12-29|17:49:51] Maximum peer count ETH=25 LES=0 total=25
Account #0: {3b896fb3e31fc9b91921d19b8c7271d1c3af5b35} keystore:///Users/user/today2/data0/keystore/UTC--2018-07-12T06-48-20.253726408Z--3b896fb3e31fc9b91921d19b8c7271d1c3af5b35
Account #1: {39f03934f1d9afbff39a395364416e71eae375cd} keystore:///Users/user/today2/data0/keystore/UTC--2018-09-25T09-15-10.502888824Z--39f03934f1d9afbff39a395364416e71eae375cd
打印的是部署在./today2/data0目录下的所有账户信息
2> new
格式:
geth account new [command options] [arguments...]
选项:
userdeMacBook-Pro:~ user$ geth account new -h ETHEREUM OPTIONS: 以太坊选项
--datadir "/Users/user/Library/Ethereum" Data directory for the databases and keystore 指明数据库和密钥存储文件的数据目录
--keystore Directory for the keystore (default = inside the datadir) 密钥存储文件的数据目录(默认在--datadir参数指定的目录下)
--lightkdf Reduce key-derivation RAM & CPU usage at some expense of KDF strength
以牺牲KDF的强度为代价,减少键派生中RAM和CPU的使用 ACCOUNT OPTIONS:账户选项
--password value Password file to use for non-interactive password input 非交互式密码输入中使用的密码文件
创建一个新帐户并打印地址,帐户将以加密格式(即得到个UTC文件)保存,提示您输入密码。你必须记住这个密码才能在将来解锁你的账户。
对于非交互式使用,可以使用--password标记直接指定密码:
⚠️注意,这仅用于测试,将密码保存为文件或以任何其他方式公开是一个坏主意。
举例:
一开始在本地环境中有两个账户,如图:
然后现在我们使用上面的命令生成一个新的账户:
userdeMBP:today2 user$ geth account new --datadir ./data0 --password ./password
INFO [01-10|16:09:36] Maximum peer count ETH=25 LES=0 total=25
Address: {d3f19f6c7cb02787c06792456351851f242a935b}
--datadir指定你是通过连接当前目录下的/data0/geth.ipc来连接这个geth客户端的,--password指定你密码存储的文件
然后可见成功生成了一个新的账户:
3>import
格式:
geth account import [options] <keyfile>
选项:
userdeMacBook-Pro:~ user$ geth account import -h ETHEREUM OPTIONS: 以太坊选项
--datadir "/Users/user/Library/Ethereum" Data directory for the databases and keystore 指明数据库和密钥存储文件的数据目录
--keystore Directory for the keystore (default = inside the datadir) 密钥存储文件的数据目录(默认在--datadir参数指定的目录下)
--lightkdf Reduce key-derivation RAM & CPU usage at some expense of KDF strength
以牺牲KDF的强度为代价,减少键派生中RAM和CPU的使用 ACCOUNT OPTIONS:账户选项
--password value Password file to use for non-interactive password input 非交互式密码输入中使用的密码文件
导入一个未加密的私钥,并创建一个新帐户,并打印的地址。
假设<keyfile>密钥文件包含十六进制格式的未加密私钥。得到的帐户将以加密格式(即得到个UTC文件)保存,提示你输入密码。
⚠️你必须记住这个密码才能在将来解锁你的账户。
举例说明:
geth account import --datadir '/Users/geth-environment/data0/' --password '/Users/geth-environment/password' /Users/user/geth-environment/coinbase.key
该命令的意思就是导入并生成一个账户的UTC文件到--datadir参数指定的geth客户端的目录的/keystore中,其密码从--password参数指定的文件夹中读取,/Users/user/geth-environment/coinbase.key文件中记录着该账户的私钥,然后你就能看见在/Users/geth-environment/data0/keystore文件夹中生成了对应的一个UTC文件
也可以不使用--password参数,然后他就会进行进入交互模式,终端提示输入密码
4>update
格式:
update [command options] [arguments...] geth account update <address>
选项:
ETHEREUM OPTIONS: 以太坊选项
--datadir "/Users/user/Library/Ethereum" Data directory for the databases and keystore 指明数据库和密钥存储文件的数据目录
--keystore Directory for the keystore (default = inside the datadir) 密钥存储文件的数据目录(默认在--datadir参数指定的目录下)
--lightkdf Reduce key-derivation RAM & CPU usage at some expense of KDF strength
以牺牲KDF的强度为代价,减少键派生中RAM和CPU的使用
更新现有帐户。
该帐户以加密格式保存在最新版本中,提示您输入一个密码来解锁该帐户,另一个密码来保存更新后的文件。
因此,可以使用相同的命令将弃用的格式的帐户迁移到最新的格式或更改帐户的密码。
对于非交互式使用,可以使用--password标志指定密码:
geth account update [options] <address>
由于只能给出一个密码,因此只能执行格式更新,因此只能交互式地更改密码。所以update不使用--password参数
举例:
更改上面生成的新账户:
userdeMBP:today2 user$ geth account update --datadir ./data0 d3f19f6c7cb02787c06792456351851f242a935b
INFO [01-10|16:27:31] Maximum peer count ETH=25 LES=0 total=25
Unlocking account d3f19f6c7cb02787c06792456351851f242a935b | Attempt 1/3
Passphrase: //旧的密码
INFO [01-10|16:27:38] Unlocked account address=0xd3F19F6C7cB02787C06792456351851f242a935B
Please give a new password. Do not forget this password.
Passphrase: //新的设置的密码
Repeat passphrase:
2.attach
格式:
geth attach [command options] [arguments...]
选项:
ETHEREUM OPTIONS:
--datadir "/Users/user/Library/Ethereum" 数据库和keystore的数据目录 API AND CONSOLE OPTIONS:
--jspath loadScript loadScript命令调用的JavaScript根路径 (默认为: ".")
--exec value 要执行JavaScript语句
--preload value 要预加载到控制台的JavaScript文件的逗号分隔列表
该命令允许在运行的geth节点上打开控制台
Geth控制台是一个在JavaScript运行环境中的交互式shell,用于暴露节点管理界面以及Ðapp JavaScript API。
详情见https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console。
首先你要已经将geth运行起来了,geth.toml中的配置可见从头到尾使用Geth的说明-3-geth参数说明和环境配置:
userdeMBP:today2 user$ geth --config geth.toml >>geth.log
然后查看日志信息:
userdeMBP:today2 user$ tail -f geth.log
INFO [-|::] Regenerated local transaction journal transactions= accounts=
WARN [-|::] Blockchain not empty, fast sync disabled
INFO [-|::] Starting P2P networking
INFO [-|::] UDP listener up self=enode://14a6c2c3c78951126326bbaa11f1c863347567f66273ffe663d1b351ebb96f2b315d4603f4ce13cc664a5ace0b290909c0e69c394114018a64b040ff2f4cdb10@10.240.100.98:61911
INFO [-|::] RLPx listener up self=enode://14a6c2c3c78951126326bbaa11f1c863347567f66273ffe663d1b351ebb96f2b315d4603f4ce13cc664a5ace0b290909c0e69c394114018a64b040ff2f4cdb10@10.240.100.98:61911
INFO [-|::] IPC endpoint opened url=/Users/user/today2/data0/geth.ipc
INFO [-|::] HTTP endpoint opened url=http://127.0.0.1:8202 cors=* vhosts=localhost
INFO [-|::] WebSocket endpoint opened url=ws://127.0.0.1:8546
INFO [-|::] Mapped network port proto=udp extport= intport= interface=NAT-PMP(192.168.199.1)
INFO [-|::] Mapped network port proto=tcp extport= intport= interface=NAT-PMP(192.168.199.1)
可见已经成功启动,然后就能够使用attach来连接这个geth客户端了
1)geth attach有http\ws\ipc三种方式连接,看你配置geth.toml开启了哪种方式,如:
$ geth attach ipc:/some/custom/path
$ geth attach http://191.168.1.1:8545
$ geth attach ws://191.168.1.1:8546
下面使用ipc连接:
userdeMBP:today2 user$ geth attach --datadir ./data0
Welcome to the Geth JavaScript console! instance: Geth/v1.8.3-stable/darwin-amd64/go1.10.1
coinbase: 0x3b896fb3e31fc9b91921d19b8c7271d1c3af5b35
at block: (Thu, Jan :: CST)
datadir: /Users/user/today2/data0
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 >
--datadir指明geth所在目录,将会自动连接当前目录的/data0/geth.ipc,然后进入控制台
2)如果你只是想要执行某个命令,并不想要进入控制台的话,可以使用--exec:
userdeMBP:today2 user$ geth attach --datadir ./data0 --exec "eth.accounts"
["0x3b896fb3e31fc9b91921d19b8c7271d1c3af5b35", "0x39f03934f1d9afbff39a395364416e71eae375cd", "0xd3f19f6c7cb02787c06792456351851f242a935b"]
可见上面的例子得到了所有账户address的信息
3)--preload用于将定制的JavaScript文件下载到控制台中,它可以将经常使用的函数下载进去,用于建立合约等,如:
geth --preload "/my/scripts/folder/utils.js,/my/scripts/folder/contracts.js" console
然后你就能够在geth控制台调用文件的函数了
或者你也可以使用--jspath
和--exec
结合实现类似上面的功能,如:
$ geth --jspath "/tmp" --exec 'loadScript("checkbalances.js")' attach http://123.123.123.123:8545
--jspath指定文件所在的目录,--exec执行loadScript("js脚本文件"),然后该文件就下载到了geth客户端
或者:
geth --exec “personal.newAccount(‘password’)“ attach rpc:http://127.0.0.1:61911
该命令的意思就是attach通过rpc接口连接某个正在打开的区块链,并在区块链中运行语句personal.newAccount(‘password’)
3.bug
格式:
geth bug [arguments...]
上报bug
举例:
在终端运行:
userdeMBP:today2 user$ geth bug
然后就会在浏览器中弹出下面的界面,用于填写你遇见的bug,并发布:
4.copydb
格式:
geth copydb [command options] [arguments...]
选项:
ETHEREUM OPTIONS:
--datadir "/Users/user/Library/Ethereum" 数据库和keystore的数据目录
--syncmode "fast" 区块链同步模式 ("fast", "full", or "light")
--testnet 说明连接的是Ropsten network: 预配置的工作量证明的测试网络
--rinkeby 说明连接的是Rinkeby network: 预配置的股权证明的测试网络 PERFORMANCE TUNING OPTIONS:性能调优选项
--cache value 分配给内部缓存的内存的兆字节 (默认值为: ) LOGGING AND DEBUGGING OPTIONS:日志记录和调试选项
--fakepow 禁用工作量证明验证
第一个参数必须是包含要从其中下载的区块链的目录,如我本地的geth区块链目录
举例:
首先再建一个要将复制得到的数据存放的新区块链目录:
userdeMBP:~ user$ mkdir testCopy
userdeMBP:~ user$ cd testCopy/
userdeMBP:testCopy user$ mkdir data0
要先初始化创世区块:
userdeMBP:testCopy user$ geth --datadir ./data0 init genesis.json
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/chaindata cache= handles=
INFO [-|::] Writing custom genesis block
INFO [-|::] Persisted trie from memory database nodes= size=.00B time=.482µs gcnodes= gcsize=.00B gctime=0s livenodes= livesize=.00B
INFO [-|::] Successfully wrote genesis state database=chaindata hash=a0e580…a5e82e
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/lightchaindata cache= handles=
INFO [-|::] Writing custom genesis block
INFO [-|::] Persisted trie from memory database nodes= size=.00B time=.893µs gcnodes= gcsize=.00B gctime=0s livenodes= livesize=.00B
INFO [-|::] Successfully wrote genesis state database=lightchaindata hash=a0e580…a5e82e
然后复制today1的数据:
userdeMBP:testCopy user$ geth --datadir ./data0 copydb /Users/user/geth/data0/
会得到下面的错误:
Genesis not found in chain
这是因为复制的区块链目录写错了,应该改成:
userdeMBP:testCopy user$ geth --datadir ./data0 copydb /Users/user/geth/data0/geth/chaindata
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/chaindata cache= handles=
INFO [-|::] Disk storage enabled for ethash caches dir=/Users/user/testCopy/data0/geth/ethash count=
INFO [-|::] Disk storage enabled for ethash DAGs dir=/Users/user/.ethash count=
INFO [-|::] Loaded most recent local header number= hash=a0e580…a5e82e td=
INFO [-|::] Loaded most recent local full block number= hash=a0e580…a5e82e td=
INFO [-|::] Loaded most recent local fast block number= hash=a0e580…a5e82e td=
INFO [-|::] Allocated cache and file handles database=/Users/user/today1/data0/geth/chaindata cache= handles=
INFO [-|::] Block synchronisation started
INFO [-|::] Imported new chain segment blocks= txs= mgas=0.000 elapsed=.055s mgasps=0.000 number= hash=5462f1…94d464 cache=.09kB
INFO [-|::] Imported new chain segment blocks= txs= mgas=50.173 elapsed=.808s mgasps=27.745 number= hash=6af9a8…27f4f1 cache=.71kB
Database copy done in .989308101s
Compacting entire database...
Compaction done in .029904ms.
然后就能够看见geth下的data0/geth/chaindata数据下载到了/Users/user/testCopy/data0/目录下:
然后去两边的控制台中查看可见两边的数据已经成功同步,eth.blockNumber的数量都为3,详细比较eth.getBlock(1)等区块中的数据也是相同的:
⚠️这个过程并不是直接复制过去的,而是通过 downloader
模块里的 NewFakePeer
创建一个虚拟对等节点,然后再进行数据同步完成的。
中间还有这样的错误:
resource temporarily unavailable
这可能是因为你要复制的区块链还在运行,记得停止运行,否则不能复制它的数据
还有这样的错误:
ERROR[-|::]
########## BAD BLOCK #########
Chain config: {ChainID: Homestead: DAO: DAOSupport: true EIP150: EIP155: EIP158: Byzantium: Constantinople: <nil> Engine: ethash} Number:
Hash: 0xb1c860c895da7d1e912bba497d163e8f5e775362588520c1d6054b67dcfafd94 Error: unknown ancestor
############################## WARN [-|::] Synchronisation failed, dropping peer peer=local err="retrieved hash chain is invalid"
WARN [-|::] Downloader wants to drop peer, but peerdrop-function is not set peer=local
retrieved hash chain is invalid
这是因为你必须先初始化你自己的创世区块,然后再去复制别人的chaindata
5.dump
格式:
geth dump [<blockHash> | <blockNum>]
选项:
ETHEREUM OPTIONS:
--datadir "/Users/user/Library/Ethereum" 指明数据库和密钥存储文件的数据目录 PERFORMANCE TUNING OPTIONS: 性能调优选项
--cache value 分配给内部缓存的内存的兆字节 (默认值为: )
参数被解释为块号或块hash。
使用“ethereum dump 0”来得到genesis创世块。输出区块的信息
举例:
有一个本地环境如下:
userdeMBP:testCopy user$ geth --datadir ./data0 console >>geth.log
Welcome to the Geth JavaScript console! instance: Geth/v1.8.3-stable/darwin-amd64/go1.10.1
coinbase: 0xe4029d8e973c6e61ece8f9ce03abb002fe4f29ba
at block: (Fri, Jan :: CST)
datadir: /Users/user/testCopy/data0
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 > eth.blockNumber > exit
输出第二个区块的信息:
userdeMBP:testCopy user$ geth --datadir ./data0 dump
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/chaindata cache= handles=
INFO [-|::] Disk storage enabled for ethash caches dir=/Users/user/testCopy/data0/geth/ethash count=
INFO [-|::] Disk storage enabled for ethash DAGs dir=/Users/user/.ethash count=
INFO [-|::] Loaded most recent local header number= hash=84d34d…36d579 td=
INFO [-|::] Loaded most recent local full block number= hash=84d34d…36d579 td=
INFO [-|::] Loaded most recent local fast block number= hash=84d34d…36d579 td=
{
"root": "09eaf04aa8f7683f10f6e936300a60ef9c18b0fbd80319a9e99e872c64f3682e",
"accounts": {
"e4029d8e973c6e61ece8f9ce03abb002fe4f29ba": {
"balance": "",
"nonce": ,
"root": "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"codeHash": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"code": "",
"storage": {}
}
}
}
INFO [-|::] Database closed database=/Users/user/testCopy/data0/geth/chaindata
如果是一个不存在的区块,会报错:
userdeMBP:testCopy user$ geth --datadir ./data0 dump
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/chaindata cache= handles=
INFO [-|::] Disk storage enabled for ethash caches dir=/Users/user/testCopy/data0/geth/ethash count=
INFO [-|::] Disk storage enabled for ethash DAGs dir=/Users/user/.ethash count=
INFO [-|::] Loaded most recent local header number= hash=fdf89d…d6af3b td=
INFO [-|::] Loaded most recent local full block number= hash=6af9a8…27f4f1 td=
INFO [-|::] Loaded most recent local fast block number= hash=fdf89d…d6af3b td=
{}
Fatal: block not found
但是中间有报另一个错:
userdeMBP:testCopy user$ geth --datadir ./data0 dump
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/chaindata cache= handles=
INFO [-|::] Disk storage enabled for ethash caches dir=/Users/user/testCopy/data0/geth/ethash count=
INFO [-|::] Disk storage enabled for ethash DAGs dir=/Users/user/.ethash count=
INFO [-|::] Loaded most recent local header number= hash=84d34d…36d579 td=
INFO [-|::] Loaded most recent local full block number= hash=84d34d…36d579 td=
INFO [-|::] Loaded most recent local fast block number= hash=84d34d…36d579 td=
Fatal: could not create new state: missing trie node af696276bd40988db6e69cb43231b378a6e802ff4230c8f79ed56e98ef94bc73 (path )
这个的对应代码是:
state, err := state.New(block.Root(), state.NewDatabase(chainDb))
if err != nil {
utils.Fatalf("could not create new state: %v", err)
好像是在区块验证过程中出现了错误
6.dumpconfig
格式:
geth dumpconfig [command options] [arguments...]
显示配置信息
选项:基本就是geth的所有选项,这些选项可以改变配置的对应值的信息
举例:
得到所有的配置信息
userdeMBP:testCopy user$ geth --datadir ./data0 dumpconfig
INFO [-|::] Maximum peer count ETH= LES= total=
[Eth]
NetworkId =
SyncMode = "fast"
LightPeers =
DatabaseCache =
GasPrice =
EnablePreimageRecording = false [Eth.Ethash]
CacheDir = "ethash"
CachesInMem =
CachesOnDisk =
DatasetDir = "/Users/user/.ethash"
DatasetsInMem =
DatasetsOnDisk =
PowMode = [Eth.TxPool]
NoLocals = false
Journal = "transactions.rlp"
Rejournal =
PriceLimit =
PriceBump =
AccountSlots =
GlobalSlots =
AccountQueue =
GlobalQueue =
Lifetime = [Eth.GPO]
Blocks =
Percentile = [Shh]
MaxMessageSize =
MinimumAcceptedPOW = 2e- [Node]
DataDir = "data0"
IPCPath = "geth.ipc"
HTTPPort =
HTTPVirtualHosts = ["localhost"]
HTTPModules = ["net", "web3", "eth", "shh"]
WSPort =
WSModules = ["net", "web3", "eth", "shh"] [Node.P2P]
MaxPeers =
NoDiscovery = false
BootstrapNodes = ["enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303", "enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99@13.93.211.84:30303", "enode://78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d@191.235.84.50:30303", "enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6@13.75.154.138:30303", "enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303", "enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"]
BootstrapNodesV5 = ["enode://06051a5573c81934c9554ef2898eb13b33a34b94cf36b202b69fde139ca17a85051979867720d4bdae4323d4943ddf9aeeb6643633aa656e0be843659795007a@35.177.226.168:30303", "enode://0cc5f5ffb5d9098c8b8c62325f3797f56509bff942704687b6530992ac706e2cb946b90a34f1f19548cd3c7baccbcaea354531e5983c7d1bc0dee16ce4b6440b@40.118.3.223:30304", "enode://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469a85fad36f2473c9a80eb043ae60936df905fa28f1ff614c3e5dc34f15dcd2dc@40.118.3.223:30306", "enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247d2c75c45c6b4a60335060d072d7f5b35dd1d4c45f76941f62a4f83b6e75daaf@40.118.3.223:30307"]
StaticNodes = []
TrustedNodes = []
ListenAddr = ":30303"
EnableMsgEvents = false [Dashboard]
Host = "localhost"
Port =
Refresh =
比如使用了--networkid 1500,对应的配置信息也会变化:
userdeMBP:testCopy user$ geth --datadir ./data0 --networkid dumpconfig
INFO [-|::] Maximum peer count ETH= LES= total=
[Eth]
NetworkId =
SyncMode = "fast"
7.export
格式:
geth export [command options] [arguments...]
选项:
ETHEREUM OPTIONS:
--datadir "/Users/user/Library/Ethereum" 数据库和keystore的数据目录 PERFORMANCE TUNING OPTIONS:性能调优选项
--cache value 分配给内部缓存的内存的兆字节 (默认值为: ) DEPRECATED OPTIONS:弃用选项
--light 启用轻客户模式
用来导出一个区块链文件,即所有区块数据
举例:
userdeMBP:testCopy user$ geth --datadir ./data0 export
Fatal: This command requires an argument. //后面要有参数,我猜测是导出文件的名字,这里命名为exportFile1
userdeMBP:testCopy user$ geth --datadir ./data0 export exportFile1
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/chaindata cache= handles=
INFO [-|::] Disk storage enabled for ethash caches dir=/Users/user/testCopy/data0/geth/ethash count=
INFO [-|::] Disk storage enabled for ethash DAGs dir=/Users/user/.ethash count=
INFO [-|::] Loaded most recent local header number= hash=84d34d…36d579 td=
INFO [-|::] Loaded most recent local full block number= hash=84d34d…36d579 td=
INFO [-|::] Loaded most recent local fast block number= hash=84d34d…36d579 td=
INFO [-|::] Exporting blockchain file=exportFile1
INFO [-|::] Exporting batch of blocks count=
INFO [-|::] Exported blockchain file=exportFile1
Export done in .624µs
然后就能在当前目录中看见生成了一个exportFile1可执行文件,里面内容为:
f901 f9f9 01f4 a000 00a0 1dcc 4de8 dec7 5d7a
ab85 b567 b6cc d41a d312 451b 948a
f0a1 42fd 40d4
00a0 56e8
1f17 1bcc 55a6 ff83 45e6 92c0 f86e 5b48
e01b 996c adc0 2fb5 e363 b421 a056
e81f 171b cc55 a6ff e692 c0f8 6e5b
48e0 1b99 6cad c001 622f b5e3 63b4 21a0
56e8 1f17 1bcc 55a6 ff83 45e6 92c0 f86e
5b48 e01b 996c adc0 2fb5 e363 b421
b901 ...
8.export-preimages
格式:
export-preimages [command options] [arguments...]
选项:
ETHEREUM OPTIONS:
--datadir "/Users/user/Library/Ethereum" 数据库和keystore的数据目录 PERFORMANCE TUNING OPTIONS:性能调优选项
--cache value 分配给内部缓存的内存的兆字节 (默认值为: ) DEPRECATED OPTIONS:弃用选项
--light 启用轻客户模式
将hash预镜像导出到RLP编码的流
举例:
userdeMBP:testCopy user$ geth --datadir ./data0 export-preimages exportPreImage
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/chaindata cache= handles=
INFO [-|::] Exporting preimages file=exportPreImage
INFO [-|::] Exported preimages file=exportPreImage
Export done in .128379ms
然后就能在当前目录中看见生成了一个exportPreImage可执行文件,里面内容为:
”䎗<naìèùΫ°þO)º
9.import
格式:
geth import [command options] [arguments...]
选项:
ETHEREUM OPTIONS:
--datadir "/Users/user/Library/Ethereum" 数据库和keystore的数据目录
--gcmode value 区块链垃圾收集模式 ("full", "archive") (default: "full") PERFORMANCE TUNING OPTIONS:性能调优选项
--cache value 分配给内部缓存的内存的兆字节 (默认值为: )
--cache.database value 用于数据库io的缓存内存预留百分比 (default: )
--cache.gc value 用于trie修剪的缓存内存预留百分比 (default: ) DEPRECATED OPTIONS:弃用选项
--light 启用轻客户模式
import命令从rlp编码的表单导入块。表单可以是一个包含几个rlp编码块的文件,也可以使用多个文件。
如果只使用一个文件,导入错误将导致失败。如果使用多个文件,即使出现单独的rlp文件导入失败,处理也将继续。
用来导入一个区块链文件,基本上相当于同步操作
举例,导入刚刚导出的数据:
userdeMBP:testCopy user$ geth --datadir ./data0 import exportFile1
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/chaindata cache= handles=
INFO [-|::] Disk storage enabled for ethash caches dir=/Users/user/testCopy/data0/geth/ethash count=
INFO [-|::] Disk storage enabled for ethash DAGs dir=/Users/user/.ethash count=
INFO [-|::] Loaded most recent local header number= hash=84d34d…36d579 td=
INFO [-|::] Loaded most recent local full block number= hash=84d34d…36d579 td=
INFO [-|::] Loaded most recent local fast block number= hash=84d34d…36d579 td=
INFO [-|::] Importing blockchain file=exportFile1
INFO [-|::] Skipping batch as all blocks present batch= first=309fc9…1b7bde last=84d34d…36d579
INFO [-|::] Writing cached state to disk block= hash=84d34d…36d579 root=09eaf0…f3682e
INFO [-|::] Persisted trie from memory database nodes= size=.00B time=.291µs gcnodes= gcsize=.00B gctime=0s livenodes= livesize=.00B
INFO [-|::] Writing cached state to disk block= hash=309fc9…1b7bde root=a5122d…57851e
INFO [-|::] Persisted trie from memory database nodes= size=.00B time=.068µs gcnodes= gcsize=.00B gctime=0s livenodes= livesize=.00B
INFO [-|::] Blockchain manager stopped
Import done in .233µs. Compactions
Level | Tables | Size(MB) | Time(sec) | Read(MB) | Write(MB)
-------+------------+---------------+---------------+---------------+---------------
| | 0.00108 | 0.00000 | 0.00000 | 0.00000
| | 0.61511 | 0.00000 | 0.00000 | 0.00000 Read(MB):0.15649 Write(MB):0.10170
Trie cache misses:
Trie cache unloads: Object memory: 194.334 MB current, 194.111 MB peak
System memory: 405.694 MB current, 405.444 MB peak
Allocations: 0.017 million
GC pause: .935µs Compacting entire database...
Compaction done in .183203ms. Compactions
Level | Tables | Size(MB) | Time(sec) | Read(MB) | Write(MB)
-------+------------+---------------+---------------+---------------+---------------
| | 0.00000 | 0.00119 | 0.00000 | 0.00021
| | 0.61511 | 0.15276 | 1.23150 | 1.23021 Read(MB):1.23723 Write(MB):1.23117
INFO [-|::] Database closed database=/Users/user/testCopy/data0/geth/chaindata
10.import-preimages
格式:
geth import-preimages [command options] [arguments...]
选项:
ETHEREUM OPTIONS:
--datadir "/Users/user/Library/Ethereum" 数据库和keystore的数据目录 PERFORMANCE TUNING OPTIONS:性能调优选项
--cache value 分配给内部缓存的内存的兆字节 (默认值为: ) DEPRECATED OPTIONS:弃用选项
--light 启用轻客户模式
从RLP编码的流导入hash预镜像
结合
import和export其实是结合起来使用的用于同步两个区块的数据
比如一开始我的testCopy目录中的数据只同步了2个区块,today1目录下的区块有1491个区块,同步两边区块的方法就是使用export导出today1下的区块链文件,然后将该区块链文件导入testCopy中,同步就完成了,执行如下:
1)首先export出today1的区块链文件:
userdeMBP:~ user$ cd today1
userdeMBP:today1 user$ geth --datadir ./data0 export exportFile
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/today1/data0/geth/chaindata cache= handles=
INFO [-|::] Disk storage enabled for ethash caches dir=/Users/user/today1/data0/geth/ethash count=
INFO [-|::] Disk storage enabled for ethash DAGs dir=/Users/user/.ethash count=
INFO [-|::] Loaded most recent local header number= hash=6af9a8…27f4f1 td=
INFO [-|::] Loaded most recent local full block number= hash=6af9a8…27f4f1 td=
INFO [-|::] Loaded most recent local fast block number= hash=6af9a8…27f4f1 td=
INFO [-|::] Exporting blockchain file=exportFile
INFO [-|::] Exporting batch of blocks count=
INFO [-|::] Exported blockchain file=exportFile
Export done in .88291ms
2)然后将导出的exportFile文件放到testCopy目录下,然后import:
userdeMBP:today1 user$ cd ..
userdeMBP:~ user$ cd testCopy/
userdeMBP:testCopy user$ geth --datadir ./data0 import exportFile
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/chaindata cache= handles=
INFO [-|::] Disk storage enabled for ethash caches dir=/Users/user/testCopy/data0/geth/ethash count=
INFO [-|::] Disk storage enabled for ethash DAGs dir=/Users/user/.ethash count=
INFO [-|::] Loaded most recent local header number= hash=84d34d…36d579 td=
INFO [-|::] Loaded most recent local full block number= hash=84d34d…36d579 td=
INFO [-|::] Loaded most recent local fast block number= hash=84d34d…36d579 td=
INFO [-|::] Importing blockchain file=exportFile
INFO [-|::] Imported new chain segment blocks= txs= mgas=0.000 elapsed=.528ms mgasps=0.000 number= hash=b1c860…fafd94 cache=.00B
INFO [-|::] Imported new chain segment blocks= txs= mgas=50.173 elapsed=.983ms mgasps=101.362 number= hash=6af9a8…27f4f1 cache=.71kB
INFO [-|::] Writing cached state to disk block= hash=6af9a8…27f4f1 root=ff8472…04736e
INFO [-|::] Persisted trie from memory database nodes= size=.91kB time=.697075ms gcnodes= gcsize=.44kB gctime=.321206ms livenodes= livesize=.81kB
INFO [-|::] Writing cached state to disk block= hash=ea103c…e25dda root=036ca7…ab9892
INFO [-|::] Persisted trie from memory database nodes= size=.00B time=.975µs gcnodes= gcsize=.00B gctime=0s livenodes= livesize=.04kB
INFO [-|::] Writing cached state to disk block= hash=2a246d…f79e6c root=86c771…0d678a
INFO [-|::] Persisted trie from memory database nodes= size=.73kB time=.8µs gcnodes= gcsize=.00B gctime=0s livenodes= livesize=.31kB
INFO [-|::] Blockchain manager stopped
Import done in .917879ms. Compactions
Level | Tables | Size(MB) | Time(sec) | Read(MB) | Write(MB)
-------+------------+---------------+---------------+---------------+---------------
| | 0.00023 | 0.00000 | 0.00000 | 0.00000
| | 0.61511 | 0.00000 | 0.00000 | 0.00000 Read(MB):0.47825 Write(MB):1.77525
Trie cache misses:
Trie cache unloads: Object memory: 205.098 MB current, 194.027 MB peak
System memory: 408.772 MB current, 404.944 MB peak
Allocations: 1.389 million
GC pause: .634µs Compacting entire database...
Compaction done in .568772ms. Compactions
Level | Tables | Size(MB) | Time(sec) | Read(MB) | Write(MB)
-------+------------+---------------+---------------+---------------+---------------
| | 0.00000 | 0.01313 | 0.00000 | 0.77336
| | 0.70644 | 0.01905 | 1.38869 | 0.70644 Read(MB):1.37347 Write(MB):3.25529
INFO [-|::] Database closed database=/Users/user/testCopy/data0/geth/chaindata
3)这个时候去查看testCopy控制台的区块数,果然变成了:
> eth.blockNumber
4)这时候再导出testCopy的区块链文件,可以发现和today1的区块链文件的值是相同的L:
userdeMBP:testCopy user$ geth --datadir ./data0 export exportFile2
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/chaindata cache= handles=
INFO [-|::] Disk storage enabled for ethash caches dir=/Users/user/testCopy/data0/geth/ethash count=
INFO [-|::] Disk storage enabled for ethash DAGs dir=/Users/user/.ethash count=
INFO [-|::] Loaded most recent local header number= hash=fdf89d…d6af3b td=
INFO [-|::] Loaded most recent local full block number= hash=6af9a8…27f4f1 td=
INFO [-|::] Loaded most recent local fast block number= hash=fdf89d…d6af3b td=
INFO [-|::] Exporting blockchain file=exportFile2
INFO [-|::] Exporting batch of blocks count=
INFO [-|::] Exported blockchain file=exportFile2
Export done in .764885ms
⚠️import和export运行的比较慢,因为区块上的所有交易都会被检查
11.init
格式:
geth init [command options] [arguments...]
选项:
ETHEREUM OPTIONS:
--datadir "/Users/user/Library/Ethereum" 数据库和keystore的数据目录 DEPRECATED OPTIONS:弃用选项
--light 启用轻客户模式
init命令初始化网络的新genesis块和定义。
这是一个破坏性的行为,会改变你所参与的网络。
它希望将genesis.json文件作为参数。
举例:
userdeMBP:testCopy user$ geth --datadir ./data0 init genesis.json
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/chaindata cache= handles=
INFO [-|::] Writing custom genesis block
INFO [-|::] Persisted trie from memory database nodes= size=.00B time=.482µs gcnodes= gcsize=.00B gctime=0s livenodes= livesize=.00B
INFO [-|::] Successfully wrote genesis state database=chaindata hash=a0e580…a5e82e
INFO [-|::] Allocated cache and file handles database=/Users/user/testCopy/data0/geth/lightchaindata cache= handles=
INFO [-|::] Writing custom genesis block
INFO [-|::] Persisted trie from memory database nodes= size=.00B time=.893µs gcnodes= gcsize=.00B gctime=0s livenodes= livesize=.00B
INFO [-|::] Successfully wrote genesis state database=lightchaindata hash=a0e580…a5e82e
genesis.json类似:
{
"config": {
"chainId": ,
"homesteadBlock": ,
"eip155Block": ,
"eip158Block": ,
"ByzantiumBlock":
},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x40000",
"extraData" : "",
"gasLimit" : "0xffffffff",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"alloc": {}
}
12.js
格式:
geth js <jsfile> [jsfile...]
选项:基本就是geth的所有选项
JavaScript VM暴露节点管理界面以及Ðapp JavaScript API。参见https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console
执行指定的JavaScript文件(可以为多个文件)
举例:
生成一个test.js文件:
console.log("hello")
然后运行:
userdeMBP:today2 user$ geth js test.js
INFO [-|::] Maximum peer count ETH= LES= total=
INFO [-|::] Starting peer-to-peer node instance=Geth/v1.8.3-stable/darwin-amd64/go1.10.1
INFO [-|::] Allocated cache and file handles database=/Users/user/Library/Ethereum/geth/chaindata cache= handles=
INFO [-|::] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [-|::] Disk storage enabled for ethash caches dir=/Users/user/Library/Ethereum/geth/ethash count=
INFO [-|::] Disk storage enabled for ethash DAGs dir=/Users/user/.ethash count=
INFO [-|::] Initialising Ethereum protocol versions="[63 62]" network=
INFO [-|::] Loaded most recent local header number= hash=410ec3…d5895e td=
INFO [-|::] Loaded most recent local full block number= hash=d4e567…cb8fa3 td=
INFO [-|::] Loaded most recent local fast block number= hash=18a7ea…21dbcf td=
INFO [-|::] Loaded local transaction journal transactions= dropped=
INFO [-|::] Regenerated local transaction journal transactions= accounts=
INFO [-|::] Starting P2P networking
INFO [-|::] UDP listener up self=enode://0a6a3338224c1e12308ca3084b99f2661ef94f8ad228ce8d82879feb6eadb0fbc1d0fc8ca909342f3a68d66c94879888546bbdb638a51b0f9526e36b40333914@10.240.100.98:30303
INFO [-|::] RLPx listener up self=enode://0a6a3338224c1e12308ca3084b99f2661ef94f8ad228ce8d82879feb6eadb0fbc1d0fc8ca909342f3a68d66c94879888546bbdb638a51b0f9526e36b40333914@10.240.100.98:30303
INFO [-|::] IPC endpoint opened url=/Users/user/Library/Ethereum/geth.ipc
hello
INFO [-|::] IPC endpoint closed endpoint=/Users/user/Library/Ethereum/geth.ipc
INFO [-|::] Blockchain manager stopped
INFO [-|::] Stopping Ethereum protocol
INFO [-|::] Ethereum protocol stopped
INFO [-|::] Transaction pool stopped
INFO [-|::] Database closed database=/Users/user/Library/Ethereum/geth/chaindata
INFO [-|::] Mapped network port proto=udp extport= intport= interface=NAT-PMP(192.168.199.1)
INFO [-|::] Mapped network port proto=tcp extport= intport= interface=NAT-PMP(192.168.199.1)
目的是为了干啥??????
如果运行复杂一点的内容:
var ethers = require('ethers');
var customHttpProvider = new ethers.providers.JsonRpcProvider("http://localhost:8202");
console.log(customHttpProvider.getBalance("0x39f03934f1d9afbff39a395364416e71eae375cd"));
会报错:
Fatal: Failed to execute test.js: Error: Cannot find module 'ethers'
但是这个模块命名安装在today2目录里面,不懂??????
13.license
格式:
geth license
举例:
userdeMBP:~ user$ geth license
Geth is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version of the License, or
(at your option) any later version. Geth is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. You should have received a copy of the GNU General Public License
along with geth. If not, see <http://www.gnu.org/licenses/>.
14.makecache
格式:
geth makecache <block number> <outputdir>
makecache命令在中生成一个ethash验证缓存。
此命令用于在<outputDir>支持系统测试项目。
普通用户不需要执行它。
举例,对区块1生成ethash缓存:
userdeMBP:testCopy user$ geth --datadir data0 makecache .
结果就是在当前目录下生成了一个如下图所示的cache-R23-0000000000000000文件:
15.makedag
格式:
geth makedag <block number> <outputdir>
makedag命令在<outputDir>中生成挖矿需要的 DAG 数据集。
此命令用于支持系统测试项目。
普通用户不需要执行它。
⚠️Ethash是PoW系统,它需要一个大约1GB的数据集,它就是DAG。这通常需要几个小时才能生成,所以我们倾向于在硬盘中存储它
举例:
userdeMBP:testCopy user$ geth --datadir data0 makedag .
INFO [-|::] Generating DAG in progress epoch= percentage= elapsed=.322s
INFO [-|::] Generating DAG in progress epoch= percentage= elapsed=.422s
INFO [-|::] Generating DAG in progress epoch= percentage= elapsed=.490s
INFO [-|::] Generating DAG in progress epoch= percentage= elapsed=.554s
INFO [-|::] Generating DAG in progress epoch= percentage= elapsed=.692s
INFO [-|::] Generating DAG in progress epoch= percentage= elapsed=.718s
INFO [-|::] Generating DAG in progress epoch= percentage= elapsed=.752s
...
INFO [-|::] Generating DAG in progress epoch= percentage= elapsed=2m4.000s
INFO [-|::] Generating DAG in progress epoch= percentage= elapsed=2m5.783s
INFO [-|::] Generated ethash verification cache epoch= elapsed=2m5.786s
然后会在当前目录下生成full-R23-0000000000000000文件
⚠️一般我们在新生成一个私有网络时,当我们运行miner.start()要开始挖矿之前,都会先生成挖矿需要使用的DAG数据集,它是用于以太坊工作量证明PoW算法的数据集
16.monitor
格式:
geth monitor [command options] [arguments...]
选项:
MISC OPTIONS:
--attach value 连接的API端点(default: "/Users/user/Library/Ethereum/geth.ipc")
--rows value 图表网格中的最大行数(default: )
--refresh value 刷新间隔(秒)(default: )
Geth monitor是一种工具,用于收集和可视化节点收集的各种内部指标,支持不同的图表类型以及同时显示多个指标的能力。
举例:
userdeMBP:today2 user$ geth --datadir data0 monitor --attach=/Users/user/today2/data0/geth.ipc
Fatal: Unable to attach to geth node: dial unix /Users/user/today2/data0/geth.ipc: connect: connection refused
错误因为没有打开today2控制台
userdeMBP:today2 user$ geth --datadir data0 monitor --attach=/Users/user/today2/data0/geth.ipc
Fatal: No metrics specified. Available:
- chain/inserts/AvgRate01Min
- chain/inserts/AvgRate05Min
- chain/inserts/AvgRate15Min
- chain/inserts/MeanRate
...
- txpool/queued/discard/Overall
- txpool/queued/nofunds/Overall
- txpool/queued/ratelimit/Overall
- txpool/queued/replace/Overall
- txpool/underpriced/Overall
有错:
Fatal: No metrics specified.
并不懂,可能是需要什么参数??????
17.removedb
格式:
geth removedb
选项:
ETHEREUM OPTIONS:
--datadir "/Users/user/Library/Ethereum" 数据库和keystore的数据目录 DEPRECATED OPTIONS:弃用选项
--light 启用轻客户模式
移除区块链和状态数据库,其实就是把"chaindata", "lightchaindata"两个文件夹中的数据删除
userdeMBP:testCopy user$ geth --datadir data0 removedb
INFO [-|::] Maximum peer count ETH= LES= total=
/Users/user/testCopy/data0/geth/chaindata
Remove this database? [y/N] y
Remove this database? [y/N] y
INFO [-|::] Database successfully deleted database=chaindata elapsed=.990ms
/Users/user/testCopy/data0/geth/lightchaindata
Remove this database? [y/N] y
Remove this database? [y/N] y
INFO [-|::] Database successfully deleted database=lightchaindata elapsed=.6µs
userdeMBP:testCopy user$
然后就可以看见对应目录下的这两个文件就没了:
18.version
举例:
userdeMBP:today2 user$ geth version
Geth
Version: 1.8.-stable
Architecture: amd64
Protocol Versions: [ ]
Network Id:
Go Version: go1.10.1
Operating System: darwin
GOPATH=/Users/user/go
GOROOT=/usr/local/opt/go/libexec
这个命令的输出应该是机器可读的
19.wallet
举例:
geth wallet import /path/to/my/presale.wallet
将提示您的密码,并导入您的以太预售帐户。
它可以与--password选项非交互式地使用,该选项将passwordfile作为参数,其中包含明文形式的钱包密码。
20.console
Geth控制台是一个交互式shell的JavaScript运行时环境暴露节点管理界面以及Ðapp JavaScript API。
见https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console。
//将配置信息写入geth.toml文件中
userdeMBP:today2 user$geth --datadir data0 --networkid --port --rpc --rpcapi 'eth,net,web3,admin,personal,miner,debug' --rpccorsdomain '*' --rpcport dumpconfig > ./geth.toml //然后使用--config指向配置文件来运行控制台,并将日志写到geth.log文件中
userdeMBP:today2 user$ geth --config geth.toml console >>geth.log
Welcome to the Geth JavaScript console! instance: Geth/v1.8.3-stable/darwin-amd64/go1.10.1
coinbase: 0x3b896fb3e31fc9b91921d19b8c7271d1c3af5b35
at block: (Thu, Jan :: CST)
datadir: /Users/user/today2/data0
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 >