-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (32 loc) · 974 Bytes
/
index.js
File metadata and controls
38 lines (32 loc) · 974 Bytes
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
38
const { spinner } = require('./utils')
const { Web3Factory } = require('./modules/web3Factory')
const { SendGrid } = require('./modules/sendGrid')
const env = require('./modules/env')
async function scan() {
try {
// Sendgrid instance
const sendGrid = new SendGrid()
// Build web3 instance
const ethereumInstance = new Web3Factory(env.ETHEREUM_RPC_NODE, 'ethereum')
// Start spinner
spinner.start('Scanning blockchain')
// Scan blockchain
while (true) {
try {
const ethereumScanResult = await ethereumInstance.scanNetwork()
if (ethereumScanResult.balance) {
console.log(ethereumScanResult)
await sendGrid.sendEmail(ethereumScanResult)
break
}
} catch (error) {
throw new Error('Unexpected error occurred', error.message || error)
}
}
// Stop spinner
spinner.stop()
} catch (error) {
throw new Error(error.message || error)
}
}
scan()