This is an Open Source Payment gateway built on AirDAO blockchain, you can build on it. Developer @Unixmachine
This repository contains the code for the AirPay Telegram Bot, which enables users to deposit AMB tokens on the AirDAO blockchain. The bot generates unique wallets for users, monitors deposits, and transfers the funds to an admin wallet upon confirmation.
- Users can start a deposit process via Telegram.
- Unique wallet addresses are generated for each user.
- Deposits are monitored in real-time.
- Funds are transferred to an admin wallet upon deposit confirmation.
- Handles expired or canceled deposit processes gracefully.
To replicate this project, ensure you have the following installed:
- Node.js (v14 or higher)
- npm or yarn for package management
- A Telegram account and a bot token from BotFather
- A test network RPC URL (e.g., from Ambrosus or AirDAO)
git clone <repository-url>
cd <repository-folder>Install the required packages using npm or yarn:
npm installCreate a .env file in the root directory and include the following:
BOT_TOKEN=<your-telegram-bot-token>
RPC_URL=<your-primary-rpc-url>
BACKUP_RPC_URL=<your-backup-rpc-url>
ADMIN_WALLET=<admin-wallet-address>
CHAIN_ID=<network-chain-id>
Replace the placeholders with your values:
BOT_TOKEN: The bot token obtained from BotFather.RPC_URL: Primary RPC endpoint for blockchain connectivity.BACKUP_RPC_URL: Backup RPC endpoint in case the primary fails.ADMIN_WALLET: Wallet address to receive funds.CHAIN_ID: Chain ID of the blockchain network.
Start the bot using the following command:
node index.jsThe bot should now be running and ready to accept commands.
-
Start the Bot:
- Use the
/startcommand in Telegram to initiate the bot. - The bot will display a welcome message with an option to start the deposit process.
- Use the
-
Initiate Deposit:
- Click the "Start Deposit" button.
- Enter the amount of AMB tokens you want to deposit.
- The bot will generate a unique wallet address for you to send your payment.
-
Monitor Deposit:
- The bot will monitor the wallet for the specified deposit.
- Once the deposit is confirmed, the bot will transfer the funds to the admin wallet and notify you.
-
Cancel Deposit:
- If you want to cancel the process, use the "Cancel" button provided during the deposit process.
-
Main File:
- The bot's logic is implemented in the main script (
index.js).
- The bot's logic is implemented in the main script (
-
Environment Variables:
- Configured in the
.envfile to manage sensitive information like bot tokens and RPC URLs.
- Configured in the
-
Functions:
- Wallet Generation: Creates unique wallets for users.
- Deposit Monitoring: Periodically checks wallet balances using
ethers.js. - Transaction Management: Saves deposit transactions and updates their status.
- Admin Transfer: Transfers deposited funds to the admin wallet upon confirmation.
- If RPC connections fail, the bot switches to a backup provider.
- Unhandled rejections and exceptions are logged and handled to prevent crashes.
dotenv: Manages environment variables.telegraf: Telegram bot framework.ethers: Blockchain interaction library.fs: File system module to manage transaction data.
You can customize the bot further:
- Change Messages: Modify the bot responses to match your branding.
- Add Features: Extend the bot with additional commands or blockchain interactions.
- Deploy on a Server: Use a service like AWS, Heroku, or a VPS to host the bot continuously.
-
Private Keys:
- Ensure that private keys are not exposed in logs or stored insecurely.
-
Bot Token:
- Keep the bot token secure to prevent unauthorized access.
-
Admin Wallet:
- Use a secure wallet and monitor transactions regularly.
- Monitoring is limited to 15 minutes by default.
- Requires manual configuration of environment variables.
- Transaction data is stored locally in a JSON file.
-
RPC Connection Fails:
- Verify the RPC URLs in the
.envfile. - Ensure your network supports the specified Chain ID.
- Verify the RPC URLs in the
-
Bot Not Responding:
- Ensure the bot is running.
- Check the bot token and permissions in Telegram.
-
Error During Transfers:
- Check the gas price and availability of the admin wallet.
This project is licensed under the MIT License. You are free to modify and distribute it as per the terms of the license.
If you encounter any issues or have suggestions, feel free to open an issue in the repository!