I am trying to send ETH from one of my account to another with web3 from nodejs:
web3.eth.personal.unlockAccount(config.mainGethAccount, config.gethPassword, function () {
console.log("sendingTransaction: " + config.mainGethAccount);
let obj = {
from: config.mainGethAccount,
to: newAccountId,
value: web3.utils.toWei(.005, 'ether')
};
console.log("obj",obj);
web3.eth.sendTransaction(obj).then(function (receipt) {
done(newAccountId,config.userAccountGethPassword);
});
});
my web3 object is ok, it is able to create new account, but it crashes in .sendTransaction and ETH are actually never transferred:
sendingTransaction: 0x6c92C4201bBaFE97011C9EA9144c907Fd16F5089
[2017-08-01 03:21:46.240] [LOG] obj { from: '0x6c92C4201bBaFE97011C9EA9144c907Fd16F5089',
to: '0x2628fCe3675f25F94f06E1F0EE2c782be40fa6c8',
value: '5000000000000000' }
[2017-08-01 03:22:46.040] [WARN] Unhandled rejection Error: Transaction was not mined within 50 blocks, please make sure your transaction was properly send. Be aware that it might still be mined!
at C:\tmp\qqq\node_modules\web3\packages\web3-core-method\src\index.js:362:45
at tryCatcher (C:\tmp\qqq\node_modules\web3\packages\web3-core-promievent\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\tmp\qqq\node_modules\web3\packages\web3-core-promievent\node_modules\bluebird\js\release\promise.js:497:31)
at Promise._settlePromise (C:\tmp\qqq\node_modules\web3\packages\web3-core-promievent\node_modules\bluebird\js\release\promise.js:555:18)
at Promise._settlePromise0 (C:\tmp\qqq\node_modules\web3\packages\web3-core-promievent\node_modules\bluebird\js\release\promise.js:600:10)
at Promise._settlePromises (C:\tmp\qqq\node_modules\web3\packages\web3-core-promievent\node_modules\bluebird\js\release\promise.js:679:18)
at Async._drainQueue (C:\tmp\qqq\node_modules\web3\packages\web3-core-promievent\node_modules\bluebird\js\release\async.js:125:16)
at Async._drainQueues (C:\tmp\qqq\node_modules\web3\packages\web3-core-promievent\node_modules\bluebird\js\release\async.js:135:10)
at Immediate.Async.drainQueues (C:\tmp\qqq\node_modules\web3\packages\web3-core-promievent\node_modules\bluebird\js\release\async.js:16:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
The most interesting thing is that it works from time to time. But is it possible to fix it?
gasPrice
per transaction. – Ismael Aug 2 '17 at 2:38web3.eth.sendTransaction({ from: "0xSenderAddress", to: "0xRecipientAddress", value: "YourValue", gasPrice: gasPrice })
(the docs have each parameter github.com/ethereum/wiki/wiki/…). To get the default value call web3.eth.gasPrice like thisvar gasPrice = web3.eth.gasPrice;
. – Ismael Aug 3 '17 at 22:51