0

我有一个 geth 服务器,我需要将一些以太坊转移到其他钱包。我研究了 geth 的 wiki 页面,发现这项工作有一个名为 sendTransaction 的方法。

首先:我使用以下命令转账,结果给了我一个交易哈希,但它没有把钱转账到所需的钱包。

eth.sendTransaction({from:eth.coinbase, to:"WALLET-Address", value: web3.toWei(0.05, "ether")});
response: 0x....

第二:我使用了一些gas和gasPrice参数的组合来进行交易,但结果是一样的。像这个:

eth.sendTransaction({from:eth.coinbase, to:"WALLET-Address", value: web3.toWei(0.05, "ether"), gas: 100000, gasPrice: web3.toWei(14000,'gwei')})
response: 0x...

重要的是我必须提到,该交易没有出现在 etherscan.io 中。

请帮我解决这个问题。谢谢。

已编辑 这不是我自己的专用网络。这是一个项目,我正在为其他人编码

我这是我的JS代码,请告诉我是什么问题

#!/usr/bin/nodejs

var loadedWeb3 = require('web3');
var web3 = new loadedWeb3();

const URL = 'http://<IP>:8545';

web3.setProvider(new web3.providers.HttpProvider(URL));

var req = {
    to:"My-Wallet",
    from: "SourceWallet",
    value: web3.utils.toWei('1', 'ether'),
    gasLimit : 21000,
    gasPrice : 20000000000
};

web3.eth.getTransactionCount(req.from).then(console.log);

web3.eth.sendTransaction(req)
    .on('transactionHash', function(hash){
        console.log("TxHash: " + hash);
        web3.eth.getTransaction(hash).then(console.log);
    })
    .on('receipt', function(receipt){
        console.log("Receipt: " + receipt);
        console.log(receipt);
    })
    .on('confirmation', function(confirmationNumber, receipt){
        console.log("confirmed -> " + confirmationNumber);
        console.log(confirmationNumber);
        console.log("Receipt -> " + receipt);
        console.log(receipt);
    })
    .on('error', console.error);
4

2 回答 2

1

第一:你需要资金。要发送以太币,你需要以太币。要发送 0.05 个以太币,您可能会花费 0.06(0.05 + 0.01 交易成本)。

第二:你需要在你的节点上解锁钱包。

第三:检查 eth.coinbase 是否有资金,因为它是您试图从中获取以太币的钱包。我建议您检查 eth.accounts[0] 是否也有资金。

最后,我建议您在使用真实网络之前先在专用网络上尝试。它更容易,更便宜。

于 2018-08-07T12:09:34.577 回答
0

附加信息

我在 NodeJS 中使用以下代码进行汇款我得到了 Transaction Hash + 25 Confirmations 但没有汇款。

#!/usr/bin/nodejs

var loadedWeb3 = require('web3');
var web3 = new loadedWeb3();

const URL = 'http://<IP>:8545';

web3.setProvider(new web3.providers.HttpProvider(URL));

var req = {
    to:"Destination Wallet",
    from: "Source Wallet",
    value: web3.utils.toWei('1', 'ether')
};

web3.eth.sendTransaction(req)
    .on('transactionHash', function(hash){
        web3.eth.getTransaction(hash).then(function(trans) {
            var line = "====================================";
            console.log(line + " Transaction " + line);
            console.log("      From: " + trans.from);
            console.log("        To: " + trans.to);
            console.log("Trans Hash: " + trans.hash);
            console.log("  Ethereum: " + web3.utils.fromWei(trans.value.toString(), 'ether'));
            console.log(" Gas Limit: " + trans.gas);
            console.log(" Gas Price: " + web3.utils.fromWei(trans.gasPrice.toString(), 'Gwei'));
        });
    })
    .on('receipt', function(receipt){
        var line = "======================================";
        console.log(line + " Receipt " + line);
        console.log("Block Hash: " + receipt.blockHash);
        console.log("Block Code: " + receipt.blockNumber);
        console.log("  Used Gas: " + receipt.gasUsed);
        console.log(line + "=========" + line);
    })
    .on('confirmation', function(confirmationNumber, receipt){
        console.log("Confirm Code: " + confirmationNumber);
    })
    .on('error', console.error);

并出现以下响应:

==================================== Transaction ====================================
      From: 0x1234400000000000000000000000000000000000
        To: 0x1234500000000000000000000000000000000000
Trans Hash: 0xeaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
 Gas Limit: 90000
 Gas Price: 0.00009
Confirm Code: 0
====================================== Receipt ======================================
Block Hash: 0x8bcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
Block Code: 41962
  Used Gas: 21000
=====================================================================================
Confirm Code: 1
Confirm Code: 2
Confirm Code: 3
Confirm Code: 4
Confirm Code: 5
Confirm Code: 6
Confirm Code: 7
Confirm Code: 8
Confirm Code: 9
Confirm Code: 10
Confirm Code: 11
Confirm Code: 12
Confirm Code: 13
Confirm Code: 14
Confirm Code: 15
Confirm Code: 16
Confirm Code: 17
Confirm Code: 18
Confirm Code: 19
Confirm Code: 20
Confirm Code: 21
Confirm Code: 22
Confirm Code: 23
Confirm Code: 24

但交易不在https://etherscan.io中,并且资金没有转移。

于 2018-08-07T15:57:56.297 回答