Posted By : Mohd
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.
To make a whale alert service you need to decide a few things before starting the development:
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`
);
}
}
});
November 23, 2024 at 12:57 am
Your comment is awaiting moderation.