Solana Discord Ping
Watch a Solana wallet address and send a Discord ping on new transactions.
Requirements
- Python 3.8+
-
solanaanddiscord.pylibraries ### Usage - Install requirements:
pip install solana discord.py - Set
DISCORD_WEBHOOKandSOLANA_WALLETenvironment variables - Run the script:
python main.py
import os
import asyncio
from discord.webhook import DiscordWebhook
from solana.publickey import PublicKey
from solana.rpc.api import Client
async def watch_wallet(wallet_address, discord_webhook):
client = Client('https://api.mainnet-beta.solana.com')
while True:
response = client.get_transaction(wallet_address)
if response:
webhook = DiscordWebhook(url=discord_webhook, content='New transaction!')
webhook.execute()
await asyncio.sleep(60)
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
args = parser.parse_args()
wallet_address = os.environ['SOLANA_WALLET']
discord_webhook = os.environ['DISCORD_WEBHOOK']
asyncio.run(watch_wallet(wallet_address, discord_webhook))
Top comments (0)