forked from mempirate/eth-transaction-checker
-
Notifications
You must be signed in to change notification settings - Fork 2
/
transactionChecker.js
38 lines (34 loc) · 1.59 KB
/
transactionChecker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
module.exports = web3 => {
const account = 'YOUR_ETH_ADDRESS'.toLowerCase();
return {
async checkLastBlock() => {
let block = await web3.eth.getBlock('latest');
console.log(`[*] Searching block ${ block.number }...`);
if (block && block.transactions) {
for (let tx of block.transactions) {
let transaction = await web3.eth.getTransaction(tx);
if (account === transaction.to.toLowerCase()) {
console.log(`[+] Transaction found on block ${ lastBlockNumber }`);
console.log({ address: transaction.from, value: web3.utils.fromWei(transaction.value, 'ether'), timestamp: new Date() });
}
}
}
},
async checkBlocks(start, end) => {
for (let i = start; i < end; i++) {
let block = await web3.eth.getBlock(i)
console.log(`[*] Searching block ${ i }`);
if (block && block.transactions) {
for (let tx of block.transactions) {
let transaction = await web3.eth.getTransaction(tx);
if (account === transaction.to.toLowerCase()) {
console.log(`[+] Transaction found on block ${ lastBlockNumber }`);
console.log({ address: transaction.from, value: web3.utils.fromWei(transaction.value, 'ether'), timestamp: new Date() });
}
}
}
}
}
}
}