When I started working on Ethereum even I was having issues similar to this and I learned the hard way. I will share what I learned from my mistakes and hope you don't end up doing the same.
Answer to your 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.
I think you got the wrong understanding of FILTER. You're using the topic filter API, which filters for events emitted by contracts; thus, only contracts are going to show up in that.
As, when I tried your code (on my TESTNET) for a random address:
var options = {
fromBlock: 1535000,
toBlock: 1535104,
address: "0x76e0bb92b6f8d431af2fe1bafd304eb832241619"
};
var filter = web3.eth.filter(options);
filter.get(function(error, result){
if (!error)
console.log(JSON.stringify(result, null, 2));
});
The result from this was:
[]
But when I replace the value of "address" key, with a contract address and add a from address (i.e. from which contract functions were invoked)
CODE:
var options = {
fromBlock: 1535000,
toBlock: 1535104,
address: "0x5c99dadde01ce61ab5b5536d566bf41ecd17e3a9", //CONTRACT ADDR
from: "0x76e0bb92b6f8d431af2fe1bafd304eb832241619" //WALLET ADDR
};
var filter = web3.eth.filter(options);
filter.get(function(error, result){
if (!error)
console.log(JSON.stringify(result, null, 2));
});
RESULT:
{
"address": "0x5c99dadde01ce61ab5b5536d566bf41ecd17e3a9",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x00000000000000000000000076e0bb92b6f8d431af2fe1bafd304eb832241619",
"0x0000000000000000000000002b3425ce986f9f0f599758f4fb33158ca671e83e"
],
"data": "0x0000000000000000000000000000000000000000000000000000000000000001",
"blockNumber": 1535088,
"transactionHash": "0xf523285b652163f50f1d19ca08951f38b4bfe099d721a6e6d80ff7fd03a171eb",
"transactionIndex": 4,
"blockHash": "0x27a29bf153b302a5e8f24415ed1f2fac1829e845746bed9f3098f0b40cd232a5",
"logIndex": 1,
"removed": false
}
{
"address": "0x5c99dadde01ce61ab5b5536d566bf41ecd17e3a9",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x00000000000000000000000076e0bb92b6f8d431af2fe1bafd304eb832241619",
"0x0000000000000000000000002b3425ce986f9f0f599758f4fb33158ca671e83e"
],
"data": "0x0000000000000000000000000000000000000000000000000000000000000001",
"blockNumber": 1535104,
"transactionHash": "0x14632d129a6aac7365483a3000470ece443a19a73f242cba1f1944f78889a677",
"transactionIndex": 7,
"blockHash": "0x34ee516310a59407712455ec87bd76046a1e68f5c631dc8e6b4bb903b8c92834",
"logIndex": 6,
"removed": false
}
The are all transactions done from that address (0x76e0bb92b6f8d431af2fe1bafd304eb832241619) on Contract (0x5c99dadde01ce61ab5b5536d566bf41ecd17e3a9) between blocks 1535000-1535104.
NOTE:
If you want to get non-contractual transactions from the blockchain, you need to examine each block for transactions which happened in that blog and then get a transaction details using web3 API. This Link (Common useful JavaScript snippets for geth) has this section Script To Find Transactions To/From An Account
The above link wont help you to know the internal transactions which happen inside a contract, here is the link to same .
Hopefully this helps you.