我有一个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);
答案 0 :(得分:1)
首先:您需要资金。要发送以太币,您需要以太币。要发送0.05乙醚,您可能要花费0.06(0.05 + 0.01交易费用)。
第二:您需要在您的节点上将钱包解锁。
第三:检查eth.coinbase是否有资金,因为它是您试图从中获取以太币的钱包。我建议您检查eth.accounts [0]是否也有资金。
最后,我建议您在使用实际网络之前尝试在专用网络上进行操作。它更容易,更便宜。
答案 1 :(得分:0)
我在NodeJS中使用以下代码进行汇款,但获得了交易哈希+ 25确认,但没有汇款。
#!/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中,资金也没有转移。