【问题标题】:Geth eth.sendTransaction does not workGeth eth.sendTransaction 不起作用
【发布时间】:2018-06-19 05:57:19
【问题描述】:

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

Accounts[0] 在专用网络中有 105 个 eth,我尝试如下发送 eth。

但是 eth.sendTransaction 命令只返回 “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

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

【问题讨论】:

  • 根据您的描述,您似乎正在运行您的节点(常量函数正确返回),但没有挖掘任何交易。
  • 是的,我制作了 genesis 文件并创建了私有网络。我之前试过start mining,但返回null。这是原因吗?接下来我该怎么办?
  • 我意识到我错了。之前实际上并未开始采矿。现在我得到正确的结果。但是miner.start() 仍然响应为空。

标签: ethereum geth


【解决方案1】:

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

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

设置好监听器后,再次运行sendTransaction 并确认您收到了日志语句。如果是这样,您就正确地提交了交易。

正如评论中提到的,接下来的事情是确保交易被挖掘。有几种方法可以做到这一点:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-04
    • 2018-05-15
    • 1970-01-01
    • 2018-04-30
    • 1970-01-01
    • 2019-01-03
    相关资源
    最近更新 更多