我有一台geth服务器,我需要把一些电子邮件转移到其他钱包。我研究了geth的wiki页面,发现有一个名为sendTransaction的方法用于这项工作。
First:我使用下面的命令来转移资金,resault给了我一个事务散列,但是它没有把钱转移到想要的钱包。
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);发布于 2018-08-07 12:09:34
首先:你需要资金。要发送乙醚,你需要乙醚。要发送0.05以太,您可能会花费0.06 (0.05 + 0.01交易成本)。
第二:你需要在你的节点上打开钱包。
第三:检查eth.coinbase是否有资金,因为它是你试图从它那里得到的钱包。我建议你检查一下eth.accounts是否也有资金。
最后,我建议您在使用真正的网络之前,先在专用网络上尝试一下。更容易也更便宜。
发布于 2018-08-07 15:57:56
更多信息
我在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,资金也没有转移。
https://stackoverflow.com/questions/51721200
复制相似问题