Last active
July 13, 2022 04:04
-
-
Save 0xAnon101/080020fcccae8eb3336d1261d3b2355b to your computer and use it in GitHub Desktop.
subscribe function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| subscribe(topic) { | |
| this.web3.on(topic, async (txnHash) => { | |
| setTimeout(async () => { | |
| try { | |
| const txn = await this.web3.getTransaction(txnHash); | |
| if (txn !== null && txn.to !== null) { | |
| if (this.accounts === txn.from.toLowerCase()) { | |
| // dumps the data onto the CLI | |
| console.log({ | |
| address: txn.from, | |
| value: ethers.utils.formatEther(txn.value), | |
| timestamp: new Date(), | |
| txnHash: txn.hash, | |
| }); | |
| } | |
| } | |
| } catch (err) { | |
| console.error(err); | |
| } | |
| }, 60000); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment