{"id":25860063,"url":"https://github.com/btc415/solana-wallet-tracking-telegram-bot","last_synced_at":"2025-03-01T21:53:16.580Z","repository":{"id":280140421,"uuid":"940888145","full_name":"BTC415/Solana-Wallet-Tracking-Telegram-bot","owner":"BTC415","description":"Solana wallet tracking Telegram bot that monitors transactions and sends real-time notifications. It provides a comprehensive solution for tracking Solana wallet activities, including transaction signatures, token transfers, buy/sell operations, and amount changes.","archived":false,"fork":false,"pushed_at":"2025-03-01T13:52:30.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-01T14:35:16.311Z","etag":null,"topics":["helius","mongodb","nodejs","solana-web3","telegram-bot","telegram-bot-api","typescript"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BTC415.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-01T01:49:33.000Z","updated_at":"2025-03-01T13:56:03.000Z","dependencies_parsed_at":"2025-03-01T14:35:17.759Z","dependency_job_id":"2544028c-1ccd-49c9-9b0a-48eec567a2d7","html_url":"https://github.com/BTC415/Solana-Wallet-Tracking-Telegram-bot","commit_stats":null,"previous_names":["btc415/solana-wallet-tracking-telegram-bot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BTC415%2FSolana-Wallet-Tracking-Telegram-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BTC415%2FSolana-Wallet-Tracking-Telegram-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BTC415%2FSolana-Wallet-Tracking-Telegram-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BTC415%2FSolana-Wallet-Tracking-Telegram-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BTC415","download_url":"https://codeload.github.com/BTC415/Solana-Wallet-Tracking-Telegram-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241430317,"owners_count":19961635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["helius","mongodb","nodejs","solana-web3","telegram-bot","telegram-bot-api","typescript"],"created_at":"2025-03-01T21:53:15.900Z","updated_at":"2025-03-01T21:53:16.542Z","avatar_url":"https://github.com/BTC415.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Solana Wallet Tracking Telegram bot\n\nA comprehensive guide to building a professional Solana wallet tracking system that monitors transactions and delivers real-time notifications through Telegram.\n\n## Introduction\n\nIn the fast-moving world of Solana trading, staying informed about wallet activities is crucial. This guide will walk you through creating a sophisticated wallet tracking bot that monitors transactions and sends detailed notifications via Telegram.\n\n## System Architecture\n\nThe system consists of three main components:\n\n1. Helius RPC for transaction monitoring\n2. MongoDB for data storage\n3. Telegram Bot for notifications\n\n## Step-by-Step Guide\n\n### 1. Setting Up Your Telegram Bot\n\nFirst, we'll create and configure your Telegram bot for notifications.\n\n#### Creating your own Telegram bot\n\n1. Open Telegram and search for the @BotFather.\n2. Send `/newbot` command\n3. Name your bot (Example: \"super_wallet_tracking_bot\")\n4. Save your bot token\n\n#### Configuring Chat IDs\nNow we named our bot and get bot token, we need to get our chat ID.\n\nTo get your chat ID:\n\n1. Add your bot to your channel\n2. Send a message\n3. Access: https://api.telegram.org/bot\u003cYOUR_TOKEN\u003e/getUpdates\n4. Extract the chat_id from the response\n\nOr you can use this script to get your chat ID:\n\n``` bash\nimport TelegramBot from \"node-telegram-bot-api\";\nimport dotenv from \"dotenv\";\n\ndotenv.config();\n\nconst TELEGRAM_BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN!;\n\nconst bot = new TelegramBot(TELEGRAM_BOT_TOKEN, { polling: true });\n\nbot.on(\"message\", (msg) =\u003e {\n  console.log(\"New chat ID:\", msg.chat.id);\n\n  TELEGRAM_CHAT_ID = msg.chat.id.toString();\n});\n```\n\n#### Environment Configuration\n\nAdd these to your .env file:\n\n``` bash\nTELEGRAM_BOT_NAME = \"super_wallet_tracking_bot\"\nTELEGRAM_BOT_TOKEN = \"YOUR_BOT_TOKEN\"\nTELEGRAM_CHAT_ID = \"YOUR_CHAT_ID\"\n```\n\nOnce we set environment variables, create a `telegram.ts` file and write the following code to send messsages to Telegram:\n\n``` bash\nimport TelegramBot from \"node-telegram-bot-api\";\nimport dotenv from \"dotenv\";\n\ndotenv.config();\n\nconst TELEGRAM_CHAT_ID = process.env.TELEGRAM_CHAT_ID!;\n\nconst bot = new TelegramBot(TELEGRAM_BOT_TOKEN, { polling: false });\n\nexport const sendTelegramMessage = async (message: string) =\u003e {\n  try {\n    await bot.sendMessage(TELEGRAM_CHAT_ID, message, {\n      parse_mode: \"HTML\",\n      disable_web_page_preview: true,\n    });\n  } catch (error) {\n    console.error(\"Failed to send Telegram message:\", error);\n  }\n};\n```\n\n### 2.Integrating Helius RPC\n\nHelius provides reliable RPC endpoints for Solana transaction monitoring.\n\nSetup Steps:\n\n1. Get your Helius API key from [Helius Dashboard](https://dashboard.helius.dev/)\n2. Configure RPC endpoints in .env:\n\n``` bash\nRPC_URL = \"https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY\"\nWSS_URL = \"wss://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY\"\n```\n\n### 3. Database Configuration and connection to MongoDB\nWe use  MongoDB for storing transaction history and analysis.\n\nConfiguration:\n\n``` bash\nMONGODB_URI = \"mongodb://localhost:27017/solana_wallet_tracking\"\n```\n\nCreate `db.ts` file, and write the following code:\n``` bash\nimport mongoose from \"mongoose\";\n\nexport const connectDB = async (mongodb_url: string) =\u003e {\n  await mongoose.connect(mongodb_url);\n  console.log(\"📦 MongoDB Connected\");\n};\n```\n\n### 4. Wallet Monitoring\n\nConfigure the wallet address you want to monitor:\n\n``` bash\nWALLET_ADDRESS = \"YOUR_WALLET_ADDRESS\"\n```\n\n### 5. Solana Connection Setup with Helius RPC\n\nWe need to establish communication with the Solana blockchain through Helius RPC endpoints.\n\nCreate `connection.ts` file, and write the following code:\n\n``` bash\nimport { Connection } from \"@solana/web3.js\";\nimport dotenv from \"dotenv\";\n\ndotenv.config();\n\nconst RPC_URL = process.env.RPC_URL!;\nconst WSS_URL = process.env.WSS_URL!;\n\nif (!RPC_URL || !WSS_URL) {\n  throw new Error(\n    \"RPC_URL and WSS_URL must be defined in environment variables\"\n  );\n}\n\nexport const connection = new Connection(RPC_URL, { wsEndpoint: WSS_URL });\n```\n\nThis creates a Connection instance that provides:\n\n- HTTP-based RPC calls for transaction queries\n- WebSocket connection for real-time transaction monitoring\n- Automatic reconnection handling\n- Connection state management\n\n### 6. Transaction Analysis\n\nThe system monitors:\n\n- Transaction signatures\n- Token transfers\n- Buy/Sell operations\n- Amount changes\n- Timestamps\n\nWe need to get transaction data from Helius RPC and processes this data and analyze signature in detail :\n\nCreate `trading.ts` file, and write the following code:\n\n``` bash\nimport { NATIVE_MINT } from \"@solana/spl-token\";\nimport { LAMPORTS_PER_SOL, PublicKey } from \"@solana/web3.js\";\n\nimport { sendTelegramMessage } from \"./telegram.js\";\nimport { Trading } from \"./models/Trading.js\";\nimport { formatCryptoAddress } from \"./lib/format.js\";\n\nimport { connection } from \"./config.js\";\n\nconst explorerUrl = \"https://solscan.io/tx/\";\nconst walletUrl = `https://solscan.io/account/`;\n\nexport const subscribeTrading = (key: string) =\u003e {\n    const anaylzeSignature = async (log: any) =\u003e {\n      txn = await connection.getParsedTransaction(signature, {\n             maxSupportedTransactionVersion: 0,\n            commitment: \"confirmed\",\n          });\n      \n      if (!txn) {\n        console.log(`Failed to fetch transaction after ${attempt} attempts`);\n        return;\n      }\n\n      // process transaction to get relevant information\n  \n      console.log(\"preTokenBalances\", preTokenBalances);\n      console.log(\"postTokenBalances\", postTokenBalances);\n      console.log(\"loaced addresses\", innerInstructions);\n\n      const message = `\n        🔔 \u003cb\u003eNew Transaction Detected!\u003c/b\u003e\n\n        👛 \u003cb\u003eWallet:\u003c/b\u003e \u003ca href=\"${walletUrl + signer}\"\u003e${formatCryptoAddress(signer)}\u003c/a\u003e\n\n        💰 \u003cb\u003eSol Amount:\u003c/b\u003e ${solAmount \u003e 0 ? \"📥 SELL\" : \"📤 BUY\"} ${Math.abs(solAmount).(3)} SOL\n\n        💸 \u003cb\u003ePNL for this Token:\u003c/b\u003e ${totalPNL.toFixed(3)} SOL\n\n        🚀 \u003cb\u003eToken:\u003c/b\u003e \u003ca href=\"${walletUrl + tokenAddress}\"\u003e${tokenInfo}\u003c/a\u003e\n\n        🔗 \u003ca href=\"${explorerUrl + signature}\"\u003eView Transaction\u003c/a\u003e\n\n        ⏰ ${new Date().toLocaleString()}\n        `;\n\n      await sendTelegramMessage(message); \n    }\n\n  return connection.onLogs(new PublicKey(key), anaylzeSignature, \"processed\");\n}\n```\n\n## Conclusion\n\nThis Solana wallet tracking bot provides a robust solution for monitoring wallet activities with real-time Telegram notifications. By following this guide and implementing the provided configurations, you can create a powerful tool for tracking Solana transactions and maintaining awareness of your wallet activities.\n\nThe system's modular architecture allows for easy maintenance and future enhancements while providing reliable transaction monitoring and notification delivery.\n\nRemember to regularly monitor your API usage and maintain your database to ensure optimal performance of your tracking system.\n\n## License\nThis project is licensed under the [MIT License](./LICENSE).\n\n## Contact Information\n\n- Gmail: [marksantiago0929@gmail.com](mailto:marksantiago0929@gmail.com)\n- GitHub: [MARK](https://github.com/BTC415)\n- LinkedIn: [Mark Santiago](https://www.linkedin.com/in/mark-santiago-373172339/)\n- Telegram: [@marksantiago02](https://t.me/marksantiago02)\n- Twitter: [@MarkSantiago02](https://twitter.com/MarkSantiago02)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtc415%2Fsolana-wallet-tracking-telegram-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbtc415%2Fsolana-wallet-tracking-telegram-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtc415%2Fsolana-wallet-tracking-telegram-bot/lists"}