【发布时间】:2019-05-21 03:08:04
【问题描述】:
我想在一个网络中的不同计算机上建立一个私有以太坊测试网。
我有一个连接到 Ganachi 测试网的带有工作 web3.py 实现的私人计算机。我可以在我的程序中使用带有 solc 编译器的 python 编写的程序部署智能合约。
现在我想在 VM 和树莓派上设置两个不同的其他以太坊节点。我在 VM 上安装了 geth,但我不明白如何将 VM 与在我的计算机上运行的 Ganache 连接。
设置如下:
RPC-Server Ganachi:http://127.0.0.1:7545
网络 ID = 5777
我尝试使用此命令将 geth 节点与 ganache 连接起来:
geth --port 5000 --networkid 5777 --rpc --rpcport 7545 --rpcaddr 127.0.0.1 --rpccorsdomain '*' --rpcapi'eth,net,web3,personal' --testnet
它开始运行并写出这些信息
...启动点对点节点
...分配的 chache 和文件句柄
...内存数据库中的持久性特里
...初始化链配置
...初始化以太坊协议
...新建本地节点记录
...IPC 端点已打开
...HTTP 端点已打开
...开始 P2P 网络
...新建本地节点记录
当我启动我的程序时,VM 上没有显示任何内容,当我想向我在 VM 上创建的帐户发送交易时,我看不到其他余额。
这是我在本地计算机上的交易代码:
w3.eth.sendTransaction({'from': '0xC4AEe6dBE1BF2461776f48a4Ca0E06E39dE08bB6', 'value': wei_value, 'to': w3.toChecksumAddress('0xbdb3c3a7a0949b0aab9346e858f85fa8e3764733')}}
交易完成,以太币从 ganache GUI 的账户中提取。
但是当我用这段代码在虚拟机上测试账户时:
geth --port 5000 --networkid 5777 --rpc --rpcport 7545 --rpcaddr 127.0.0.1 --testnet 控制台
eth.getBalance(w3.toChecksumAddress('0xbdb3c3a7a0949b0aab9346e858f85fa8e3764733')})
输出为 0 !!!
有人可以帮助我将 VM geth 与我的计算机 Ganache 连接起来吗?
虚拟机和我的电脑通过 VPN 连接。例如,当我将 Ganachi 中的设置更改为 http://0.0.0.0:7545 时,当我更改行时,我的 python 代码中出现错误:
provider = HTTPProvider('http://127.0.0.1:7545')
到
provider = HTTPProvider('http://0.0.0.0:7545')
出现此错误:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=7545): Max retries exceeded with url: / (Caused by NewConnectionError(': 无法建立新连接: [WinError 10049] Die angeforderte Adresse ist in diesem Kontext ungültig',))
我完全不知道该怎么办!需要帮助请:)
【问题讨论】:
标签: python blockchain web3 go-ethereum geth