接上篇文章。

错误2 :运行此命令时,geth --identity "myetherum" --rpc --rpccorsdomain "*" --datadir "chain" --port "30303" --rpcapi "db,eth,net,web3,personal,miner" --networkid 10 console 2>1.txt

1)报错:Incorrect Usage: flag provided but not defined: -rpc

因为版本问题,现在已经不用 --rpc

改:

--rpc => --http

--rpcapi => --http.api

--rpccorsdomain => --http.corsdomain

2)改为:geth --identity "myetherum" --http --http.corsdomain "*" --datadir "chain" --port "30303" --http.api "db,eth,net,web3,personal,miner" --networkid 10 console 2>1.txt后,运行报错:Fatal: Failed to create the protocol stack: open /home/ub/source/dapp/chain/geth/LOCK: permission denied

进入chain文件夹后,试图使用命令chmod 777 geth,报错:chmod: changing permissions of 'geth': Operation not permitted

提升至超级用户即sudo chmod 777 geth,完成改变;

此时再次运行geth --identity "myetherum" --http --http.corsdomain "*" --datadir "chain" --port "30303" --http.api "db,eth,net,web3,personal,miner" --networkid 10 console 2>1.txt

成功!

提示:Welcome to the Geth JavaScript console!

instance: Geth/myetherum/v1.13.14-stable-2bd6bd01/linux-amd64/go1.21.6 at block: 0 (Thu Jan 01 1970 08:00:00 GMT+0800 (CST)) datadir: /home/ub/source/dapp/chain/chain modules: admin:1.0 debug:1.0 engine:1.0 eth:1.0 miner:1.0 net:1.0 rpc:1.0 txpool:1.0 web3:1.0

简单解释:

接下来,运行eth.blockNumber获取当前链的高度;运行eth.accounts;均为0/空,因为未开始挖矿。

下面解释此行代码geth --identity "myetherum" --http --http.corsdomain "*" --datadir "chain" --port "30303" --http.api "db,eth,net,web3,personal,miner" --networkid 10 console 2>1.txt

identity "myetherum" 自定义链名称;而后所有带有--http的为允许所有http连接(老教程中还在使用rpc相关命令);

--datadir "chain" --port "30303"目录名称及端口号;

--http.api "db,eth,net,web3,personal,miner"允许的api方式:如数据库、网络连接、挖矿操作等;

--networkid 10 json文件中对应的网络id

注:若发现id与本地json文件不服,则做出相应修改并重新使用init命令创建链,在运行上面的命令即可。

3)接下来创建账户:personal.newAccount("123")

此时报错:ReferenceError: personal is not defined

阅读相关资料(可以在GitHub上找低版本的geth说明),后得知是由于需要在运行链时加入

--rpc.enabledeprecatedpersonal 这个flag;

但若在随意的位置加入此命令,我们会得到错误:Incorrect Usage: flag provided but not defined: -http.enabledeprecatedpersonal;

在查阅一些资料后,笔者发现,需将--rpc.enabledeprecatedpersonal 这个flag加在

--networkid 10 后,即:

geth --identity "myetherum" --http --http.corsdomain "*" --datadir "chain" --port "30303" --http.api "db,eth,net,web3,personal,miner" --networkid 10 --rpc.enabledeprecatedpersonal console 2>1.txt

此时执行命令后,我们便可以使用personal的各个命令。

然后便是执行 personal.newAccount("123") (“”内名称任取 ) 命令创建新账户。

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐