firebase-streams-monitor
This project is a Wallet ERC20 Monitor. Using Moralis Streams it will be notified whenever you receive an ERC20 token in one of your wallets. Then it will notify you on Telegram about it. Also, it will add Moralis Stream Triggers to enrich the data received with the full balance of both sender and receiver wallets.
Required services:
- Firebase Cloud Functions. Only in the Blaze plan, check the pricing, for personal usage will likely not exceed free tier quota.
- Firebase Firestore
- Moralis Streams. Free quota should be enough for personal usage, check the pricing.
- Telegram Bots. You will need Telegram app in, at least, one device.
🚀 How to Start​
- Create your Moralis account
- Copy your Moralis API Key in
.env
file
- Copy your Moralis API Key in
- Setup a firebase project with functions and firestore database
- Install Firebase CLI globally:
yarn global add firebase-tools
- Login to your account:
firebase login
- Get list of your projects:
firebase projects:list
. If this list is empty you should add a new project. You can do it by the Firebase Console. - Set your project ID:
firebase use <PROJECT_ID>
- Make sure to have a firestore database in your project
- Install Firebase CLI globally:
- Create a telegram bot
- Using Telegram, write "/start" to @BotFather to start a conversation and see available commands
- Send "/newbot" to @BotFather
- Choose a name for your bot
- Choose a username for your bot
- Copy the token provided by @BotFather in
.env
file
- Deploy the project by running
firebase deploy
. This will create your functions and give you the URL to access them. - Link your bot webhook in telegram, so it can receive messages with the following request
- POST https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/setWebhook?url=<FIREBASE_botWebhook_URL>
- Add your wallets to the bot monitor list with the "/add WALLET" command. The first time doing this, it will create a stream automatically
- Whenever any of those wallets is included in a transaction, bot will send you a message containing its info
- You can remove an address with the "/remove WALLET" command
🔌 Run Locally​
- Install Java on your computer. Functions Emulator requires Java.
- Run ngrok to forward requests from an internet address to your localhost:
ngrok http 5001
(if you are using the default port)
- Edit
index.ts
file and replace<NGROK_URL>
inSTREAM_CONFIG
with the URL provided by ngrok - Run emulators:
firebase emulators:start
- Link bot webhook to your local URL with the following request
- POST https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/setWebhook?url=<FIREBASE_botWebhook_URL>
- Follow from step 6 in the previous section