Solana Discord Notifier
Overview
Watches a Solana wallet address and sends a Discord ping on new transactions.
Usage
- Set up a Discord webhook
- Install required libraries:
pip install solana discord.py - Configure the script with your Solana wallet address and Discord webhook URL ## Configuration
- Set
SOLANA_WALLET_ADDRESSenvironment variable to your Solana wallet address - Set
DISCORD_WEBHOOK_URLenvironment variable to your Discord webhook URL
import os
import json
import requests
import time
from solana.rpc.api import Client
import discord
from discord.webhook import AsyncWebhookAdapter
import aiohttp
import asyncio
SOLANA_WALLET_ADDRESS = os.environ['SOLANA_WALLET_ADDRESS']
DISCORD_WEBHOOK_URL = os.environ['DISCORD_WEBHOOK_URL']
async def send_notification(transaction):
async with aiohttp.ClientSession() as session:
webhook = AsyncWebhookAdapter(session)
embed = discord.Embed(title='New Transaction', description=transaction)
await webhook.send_webhook(url=DISCORD_WEBHOOK_URL, embed=embed)
async def main():
client = Client('https://api.devnet.solana.com')
last_transaction = None
while True:
transactions = client.get_confirmed_transactions_for_address(SOLANA_WALLET_ADDRESS)
if transactions and transactions[0] != last_transaction:
await send_notification(transactions[0])
last_transaction = transactions[0]
await asyncio.sleep(60)
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description='Solana Discord Notifier')
args = parser.parse_args()
asyncio.run(main())
Top comments (0)