A command-line Node.js application designed to interface directly with Ethereum RPC nodes using Ethers.js. It monitors ERC-20 token transfer events (such as USDC) in real time, filtering transactions by threshold volumes and triggering local audio alerts (`sound-play`) along with automated email notifications.
// Code your whale tracker script here!
const { ethers, Contract } = require('ethers')
const sound = require('sound-play')
const path = require('path');
const filePath = path.join(__dirname, "register-chinging.mp3");
const rpcURL = 'https://cloudflare-eth.com/'
/*** rpcURL Binance, Polygon, ***/
const provider = new ethers.providers.JsonRpcProvider(rpcURL)
const CONTRACT_ADDRESS = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' // USDC
// Get Address from Etherscan under Profile Summary:
// https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
const CONTRACT_ABI = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]
let contract = new Contract(CONTRACT_ADDRESS, CONTRACT_ABI, provider);
// Note: USDC uses 6 decimal places
const TRANSFER_THRESHOLD = 100000000000 // wei
const main = async () => {
const name = await contract.name()
contract.on('Transfer', (from, to, amount, data) => {
if(amount.toNumber() >= TRANSFER_THRESHOLD) {
sound.play(filePath);
console.log(`Fat Banker ${name} moved ${amount} https://etherscan.io/tx/${data.transactionHash}`)
}
})
}
main()