How to Create Your Own Whale Alert

Posted By : Mohd

May 16, 2023

What is a Whale Alert?

 

A whale alert is a notification system that notifies the user whenever a large amount of cryptocurrency is moved or traded. Whale alerts keep track of the blockchain transactions and/or wallets that have a large number of cryptocurrencies and have the ability to influence the market with their actions.

 

To detect large transactions, whale alert services use different algorithms to analyze the blockchain and identify transactions that meet certain criteria, such as transactions that involve a large amount of cryptocurrency or transactions that involve specific wallets or addresses known to belong to whales.

 

You may also like to explore | Cryptocurrency Development Services

 

Once a large transaction is detected, the whale alert service sends out an alert through various channels, such as social media, email, or mobile notifications. The alert typically includes information about the transaction, such as the amount of cryptocurrency involved, the sender and recipient addresses, and the time and date of the transaction.

 

In this guide, we will create our whale alert using NodeJs and web3.js library.

 

Creating your own Whale Alert

 

To make a whale alert service you need to decide a few things before starting the development:

 

  1. First, you need to decide which blockchain to target- we will use the Ethereum blockchain for our whale alert.
  2. Setup a blockchain node- we will use the web3.js library to connect to an Ethereum node.
  3. Keep track and analyze the transactions- we will listen to the blockchain transactions using web3.js and alert if the value of any transaction is greater than a specified value.
  4. Create an alert- Decide how you want to give alerts to users, some possible options are sending emails or making a tweet, etc. To keep things simple we will just log the details of the transaction in the console.

 

Below is the code for our custom whale alert - We are keeping track of the transactions of each block and if the value of any transaction is greater than the threshold value, then the code will print an alert in the console with the details of the transaction.

 

The threshold value set in our example is 0.5 ethers, you can change the value on line 8 and use the whale alert according to your requirements.

 

const { ethers } = require('ethers');

const INFURA_URL = '';

// Connect to Blockchain node

const provider = new ethers.JsonRpcProvider(INFURA_URL);

 

// Threshold value

const THRESHOLD = ethers.parseEther('0.5');

 

console.log('Welcome to our Custom Whale Alert!\n');

 

// Whenever a new block is created,

// the callback function is called with the blockNumber

provider.on('block', async (blockNumber) => {

 console.log(`Watching ${blockNumber} Block\n`);

 // Getting the block details

 const block = await provider.getBlock(blockNumber);

 const transactions = block.transactions;

 // Looping over the transactions of the block

 for (const transactionHash of transactions) {

   const transaction = await provider.getTransaction(transactionHash);

   // Check if the 'value' of the current transaction

   // is greater than the THRESHOLD value

   if (transaction.value > THRESHOLD) {

     // Create an alert

     console.log(

       'WHALE ALERT\n',

       `Transaction Hash: ${transaction.hash}\n`,

       `Sender's Address: ${transaction.from}\n`,

       `Reciever's Address: ${transaction.to}\n`

     );

   }

 }

});

Leave a

Comment

Name is required

Invalid Name

Comment is required

Recaptcha is required.

blog-detail

November 23, 2024 at 12:57 am

Your comment is awaiting moderation.

By using this site, you allow our use of cookies. For more information on the cookies we use and how to delete or block them, please read our cookie notice.

Chat with Us
Telegram Button
Youtube Button

Contact Us

Oodles | Blockchain Development Company

Name is required

Please enter a valid Name

Please enter a valid Phone Number

Please remove URL from text