diff --git a/src/blockchain.ts b/src/blockchain.ts index 37744a4..2dcbb4e 100644 --- a/src/blockchain.ts +++ b/src/blockchain.ts @@ -5,7 +5,14 @@ import Web3 from 'web3'; const rpcUrl = process.env.RPC_URL || 'ws://localhost:8545'; // Create a new web3 instance -const web3 = new Web3(rpcUrl); +const web3 = new Web3(new Web3.providers.WebsocketProvider(rpcUrl, { + reconnect: { + auto: true, + delay: 5000, + maxAttempts: 5, + onTimeout: false + } +})); // Get the current gas price in gwei async function getGasPrice() { diff --git a/src/gasPriceChecker.ts b/src/gasPriceChecker.ts index 3fc65f9..a25fb7f 100644 --- a/src/gasPriceChecker.ts +++ b/src/gasPriceChecker.ts @@ -1,10 +1,11 @@ -import { Client, EmbedBuilder, TextChannel } from 'discord.js'; +import { EmbedBuilder, TextChannel } from 'discord.js'; import { getGasPricesInGwei } from './blockchain'; import redisClient from './redis'; +import { DiscordClient } from './discordClient'; import { GasAlert } from '../types/gasAlert'; -const createGasPriceChecker = (client: Client) => { +const createGasPriceChecker = (client: DiscordClient) => { setInterval(async () => { try { const gasPrices = await getGasPricesInGwei();