-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (27 loc) · 994 Bytes
/
index.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
const { ethers } = require("ethers");
(async () => {
const rpc = "https://matic-mumbai.chainstacklabs.com";
const provider = new ethers.providers.JsonRpcProvider(rpc);
while (true) {
try {
const lattestBlock = await provider.getBlock("latest");
lattestBlock.transactions.forEach(async (txHash) => {
const tx = await provider.getTransaction(txHash);
if (
!!tx.to &&
tx.to.toLowerCase() ===
"0x9702ddCD32d351A378639eA4e0F25Cf820c0BC7E".toLowerCase()
) {
console.log("transaction found!!!");
console.log({
hash: tx.hash,
from: tx.from,
value: ethers.utils.formatEther(tx.value),
});
}
});
} catch (error) {
console.log("error: ", error);
}
}
})();