The following link describes some of how the function web3.eth.filter(...) works:
https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethfilter
What I would like to do is get a list of the transaction objects of all transactions happening to one account. Currently I have the following code:
var options = {
fromBlock: "pending",
toBlock: "latest",
address: "0xab1323fe3234234234fa34324324234af3423432",
};
var filter = web3.eth.filter(options);
filter.watch(function(error, result){
if (!error)
console.log(result);
});
Question:
Is the previous code doing what I want? This is what I want it to do:
Whenever the App starts running, so does geth and all the blocks that are added to the blockchain start getting filtered, and when a match for the address in the
options
object is found, it saves that log. though I'm not sure if it's whenever that address is found either being sent to or if it's when it is the sender.I don't want any blocks to be skipped. But the previous javascript code then has to be applied to geth, and in order for that to happen, geth must be running before the filter is applied, so doesn't that mean some of the blocks are skipped before the filter is applied?
EDITED:
I went to the website https://etherscan.io/txs?block=4067373
and with that information choose the following address (third in line) to test on:
0x25f000254108a104A7127B5a5697cb3C12643e62
And the following code was tested:
var options = {
fromBlock: 4067373,
toBlock: 4067373,
address: "0x25f000254108a104A7127B5a5697cb3C12643e62",
};
var filter = web3.eth.filter(options);
filter.get(function(error, result){
if (!error)
console.log(JSON.stringify(result, null, 2));
});
I also did another test with the options object being:
var options = {
fromBlock: 4067372,
toBlock: 4067374,
address: "0x25f000254108a104A7127B5a5697cb3C12643e62",
};
In both cases, the result was an empty array:
[]
Question:
Is there anything being done wrong above? I expected to get some values in the result array and I don't know why it is empty.