Geth eth.sendTransaction 不起作用

Geth eth.sendTransaction does not work

我正在学习以太坊并尝试使用 Geth 1.7.3-stable 的私有网络。

Accounts[0] 在私有网络中有 105 个 eth,我尝试像下面那样发送 eth。

但 eth.sendTransaction 命令仅 returns “0xaf571929f95ddeaab8761d719dba3c852f5d4f9895968a905c275561eaf57ae6”。

并且账户[1]没有收到任何eth。

> eth.getBalance(eth.accounts[0])
105000000000000000000
> personal.unlockAccount(eth.accounts[0])
Unlock account 0x24636f1423f131f5441fbee83323c53c59af247d
Passphrase: 
true
>  eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(2, 'ether')})
"0xaf571929f95ddeaab8761d719dba3c852f5d4f9895968a905c275561eaf57ae6"
> 
> eth.getBalance(eth.accounts[1])
0

有人知道如何解决这个问题吗?

首先,检查并确保交易到达您的区块链。使用

设置侦听器
web3.eth.filter("pending").watch(
    function(error,result){
        if (!error) {
            console.log('Tx Hash: ' + result);
        }
    }
)

设置监听器后,再次 运行 您的 sendTransaction 并确认您正在获取日志语句。如果是这样,那么您提交的交易是正确的。

如评论中所述,下一步是确保交易被开采。有几种方法可以做到这一点:

  1. 你可以在geth控制台中挖矿。如果您没有在控制台模式下启动 geth,则需要重新启动它,或者在另一个终端中通过 geth attach 附加到它。在geth控制台中,您可以使用miner.start()开始挖矿。它将 return 为空,但你应该在你的 geth 输出中看到 activity 表明挖矿已经开始。要停止挖矿,请输入 miner.stop().
  2. 您可以下载单独的挖矿应用程序,例如 ethminer。只需在 geth 仍然 运行ning 时下载并启动它。

应提取任何待处理的交易。