以太坊几个主流钱包的使用方式

以太坊主流钱包主要有官方的geth、第三方的Parity及Parity的后续版本openethereum.

geth

/path/to/geth -syncmode "full" --maxpeers "16" --cache "2048" -datadir "/geth_data" --http --http.port "15301" --http.addr "0.0.0.0"  --http.corsdomain "*" --http.api "eth,net,web3,personal" > /dev/null 2>&1 &

killall -QUIT geth

用JSON-RPC的开启在新版本中用的是 http,子选项后面带.,老版本是 rpc,后面不带.。上面的命令中是把控制台输出重定向到空设备,即不保存日志,可将其重定向到指定的文件以便日后查看。

注意要用full同步模式,如果用默认的fast模式可能永远追不上最快区块!

Linux版geth相对稳定的多,不是Windows版可比的,但近期不太稳定,同步一段时间后老崩溃,貌似问题出在Go语言的协程上。

Parity

Parity config.toml

允许所有ip访问版

# This config should be placed in following path:
#   %AppData%\Parity\Ethereum\config.toml

[rpc]
# JSON-RPC over HTTP will be accessible on port 15501.
port = 15501
#  JSON-RPC will be listening for connections on IP 0.0.0.0.
interface = "0.0.0.0"
# Allows Cross-Origin Requests from domain '*'.
cors = ["*"]
# Allow connections only using specified addresses.
hosts = ["*"]
# Only selected APIs will be exposed over this interface.
apis = ["web3", "eth", "pubsub", "net", "parity", "parity_pubsub", "traces", "rpc", "shh", "shh_pubsub", "personal", "parity_accounts", "parity_set"]

[mining]
# Account address to receive reward when block is mined.
# author = ""

只允许本机访问版

其中172.17.0.2是parity所在的docker容器的ip。

# This config should be placed in following path:
#   %AppData%\Parity\Ethereum\config.toml

[rpc]
# JSON-RPC over HTTP will be accessible on port 36512.
port = 15501
#  JSON-RPC will be listening for connections on IP 0.0.0.0.
interface = "172.17.0.2"
# Allows Cross-Origin Requests from domain '*'.
cors = ["*"]
# Allow connections only using specified addresses.
hosts = ["172.17.0.1","127.0.0.1"]
# Only selected APIs will be exposed over this interface.
apis = ["web3", "eth", "pubsub", "net", "parity", "parity_pubsub", "traces", "rpc", "shh", "shh_pubsub", "personal", "parity_accounts", "parity_set"]

# [mining]
# Account address to receive reward when block is mined.
#author = ""

Parity Docker方式启动

docker run -d -p 15501:15501 -p 30303:30303 -p 30303:30303/udp --name myparity --restart=always -v /parity/:/home/parity/.local/share/io.parity.ethereum/ parity/parity:stable --base-path /home/parity/.local/share/io.parity.ethereum/ --config /home/parity/.local/share/io.parity.ethereum/config.toml

openethereum

Parity的新版本叫openethereum,创建命令和配置文件略有不同,主要是移除了几个API,文件位置也有变化。

# This config should be placed in following path:
#   %AppData%\Parity\Ethereum\config.toml

[rpc]
#JSON-RPC over HTTP will be accessible on port 15501.
port = 15501
#  JSON-RPC will be listening for connections on IP 0.0.0.0.
interface = "0.0.0.0"
# Allows Cross-Origin Requests from domain '*'.
cors = ["*"]
# Allow connections only using specified addresses.
hosts = ["*"]
# Allow all APIs will be exposed over this interface.

apis = ["all"]

[mining]
# Account address to receive reward when block is mined.
# author = ""

Docker创建命令

docker run -d -p 15301:15301 -p 30303:30303 -p 30303:30303/udp --name openeth1 --restart=always -v /parity/:/home/openethereum/.local/share/io.parity.ethereum/ openethereum/openethereum:v3.0.1 --base-path /home/openethereum/.local/share/io.parity.ethereum/ --config /home/openethereum/.local/share/io.parity.ethereum/config.toml

也可以使用openethereum的独立客户端,从而避免因Docker产生的一些问题,如Docker网络故障,日志访问等。

命令行参数方式参考Docker方式,配置文件是通用的。

/path/to/openethereum --base-path /data --config /data/config.toml

Leave a Comment

豫ICP备19001387号-1