How It Works

from solana.rpc.api import Client
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.cluster import KMeans
import smtplib
from email.mime.text import MIMEText

client = Client("https://api.mainnet-beta.solana.com")

def get_transactions(wallet_address, limit=100):
    response = client.get_confirmed_signature_for_address2(wallet_address, limit=limit)
    return response['result']

def analyze_emotions(df):
    df['timestamp'] = pd.to_datetime(df['blockTime'], unit='s')
    df['transaction_volume'] = df['meta']['preBalances'] - df['meta']['postBalances']
    df['transaction_speed'] = df['blockTime'].diff().fillna(0)
    features = df[['transaction_volume', 'transaction_speed']].values
    scaler = StandardScaler()
    scaled_features = scaler.fit_transform(features)
    kmeans = KMeans(n_clusters=3, random_state=0)
    df['emotion'] = kmeans.fit_predict(scaled_features)
    return df

def send_email_alert(subject, body, to_email):
    msg = MIMEText(body)
    msg['Subject'] = subject
    msg['From'] = "[email protected]"
    msg['To'] = to_email
    server = smtplib.SMTP('smtp.example.com', 587)
    server.starttls()
    server.login("[email protected]", "your_password")
    server.sendmail("[email protected]", to_email, msg.as_string())
    server.quit()

def check_for_alerts(df):
    if df['emotion'].iloc[-1] != df['emotion'].iloc[-2]:
        send_email_alert("Market Alert: Emotion-based trend change", 
                          f"New predicted market emotion: {df['emotion'].iloc[-1]}", 
                          "[email protected]")

wallet_address = "YourWalletAddress"
transactions = get_transactions(wallet_address)
df = pd.DataFrame(transactions)
df = analyze_emotions(df)
check_for_alerts(df)

About the Project

SOMNIA is the first platform that combines Emotional Intelligence (EI) and the Solana blockchain, transforming wallet behavior into actionable market signals for traders and investors.

In a world of extreme volatility, understanding the emotions behind market participants becomes the key to successful strategies. SOMNIA analyzes blockchain activity and behavioral patterns to help users make smarter, emotion-aware decisions.

See Beyond Numbers. Feel the Market.

SOMNIA

SOMNIA: Bridging Emotional Intelligence and Blockchain, Turning Wallet Insights into Smarter Decisions and Clearer Market Perspectives.

This code extracts transaction data from Solana, analyzes emotional trends based on transaction volume and speed, and sends an email alert if there's a significant change in emotion-based predictions.

Smart Signals
SOMNIA sends you real-time smart alerts when the market shows signs of panic, greed, or critical shifts.

Key Features

  • Real-Time Emotional Dashboard: Visualizing the emotional states across the network

  • Wallet Behavioral Scores: Rating the most impactful and volatile wallets

  • Smart Alerts: Automatic alerts on emotional trend changes

  • Predictive Models: AI-driven trend forecasting

  • Developer API: Integrate emotional insights into trading bots and DeFi apps

Wallet Emotion Analytics
We analyze transaction patterns, speed, volume, and wallet interactions to detect emotional states like fear, euphoria, panic, or patience.

Deep Solana Integration
Built to scale within Solana’s ultra-fast ecosystem, processing thousands of active wallets in real-time.

SOMNIA

AI Predictions
Behavioral machine learning models predict likely market movements based on collective emotional patterns.