I am new in ethereum, I just run simple node.js program and using web3 api, and I send some ether from my account to another in my private ethereum network, after mining my transactions mined. I still have some pending transactions, my problem is that when I want to get the number of pending transactions by following code it has the error:
Cannot read property 'length' of undefined
, howeverÙˆ I can query the pending transactions numbers via geth javascript console by this query: eth.pendingTransactions.length
console.log(web3.eth.pendingTransactions.length);
Also, I used getPendingTransactions function with call back but still it has the same error.
I checked for some other functions and variables it works fine I do not know what is the problem with array of pendingTransaction
and function getPendingTransactions
.
Here is my simple code:
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8000'));
console.log(web3.version.api);
var hashstring = web3.eth.sendTransaction({from: "X", to: "Y", value: web3.toWei(10, 'ether'),gas:30000});
console.log(hashstring);
console.log(web3.eth.pendingTransactions.length);
Best Answer
web3.eth.pendingTransactions
seems to be a Geth internal addition, I do not see it in the JSON-RPC or Web3 standard.You are probably better off using this: