MVP AskNebula is an AI-powered blockchain data service that provides detailed information about blockchain transactions, addresses, ENS names, and more. The project consists of two main components:
- AskNebula Core Service - A backend service that uses LangChain and ThirdWeb to query blockchain data
- Twitter Bot - A Twitter (X) bot that answers blockchain-related questions asked by users through mentions
-
Blockchain Data Retrieval: Get detailed information about:
- ENS name resolution
- Wallet balances
- Transaction details
- Contract interactions
- Suspicious activity detection
- Cross-chain data
-
Intelligent Response Formatting:
- Complex answers are automatically formatted as Twitter threads
- Simple answers are provided as single tweets
- Off-topic questions receive clever responses
-
Continuous Monitoring:
- The Twitter bot continuously monitors for mentions
- Processes new questions as they arrive
- Respects Twitter API rate limits
The project is organized into three main Python modules:
- askNebula.py - Core blockchain data service using ThirdWeb and LangChain
- thread_creator.py - Content formatting service for Twitter
- twiiter_bot.py - Twitter API integration for monitoring and responding to mentions
- Python 3.7+
- Twitter API credentials (API Key/Secret, Access Token/Secret, and Bearer Token)
- ThirdWeb API key for AskNebula service
- OpenAI API key
-
Clone the repository
-
Install dependencies using
uv
:uv pip install tweepy python-dotenv langchain langchain-openai thirdweb-ai pydantic
-
Create a
.env
file with your API credentials (see.env.example
for required variables)
To use the AskNebula service directly:
from askNebula import NebulaAgent
# Initialize the agent
agent = NebulaAgent()
# Run a query
response = agent.run("What's the address for vitalik.eth?")
print(response)
To start the bot, simply run:
python twiiter_bot.py
The bot will:
- Authenticate with Twitter
- Find the most recent mention and store its ID (without responding to it or any older mentions)
- Check for new mentions approximately every 90 seconds (respecting Twitter API Basic tier rate limits)
- Process any new mentions (created after the bot started) and reply with blockchain data
- Track the last processed mention to avoid duplicate responses
The NebulaAgent
class in askNebula.py
provides blockchain data by:
- Using ThirdWeb's Nebula service to access on-chain data
- Leveraging LangChain for agent-based interaction
- Using specialized tools for different types of blockchain queries:
- Balance queries
- ENS resolution
- Transaction details
- Off-topic handling
The ContentCreator
class in thread_creator.py
:
- Processes the user's blockchain query
- Gets data from the AskNebula service
- Determines the best format for the response:
- Thread (3 tweets) for complex data
- Single post for simple responses
- Clever responses for off-topic queries
- Formats the content according to Twitter's character limits and best practices
The Twitter bot in twiiter_bot.py
:
- Monitors for new mentions
- Extracts the blockchain query from the tweet text
- Sends the query to the thread_creator module
- Posts the formatted response as a reply to the original mention
- Tracks processed mentions to avoid duplicate responses
The bot is designed to work within Twitter's Basic API tier limitations:
- The mentions endpoint allows 10 requests per 15 minutes
- The tweet creation endpoint allows 100 requests per 24 hours
- The bot sleeps for 90 seconds between mention checks to stay under rate limits
Check twitter_bot.log
for detailed information about the bot's operation and any errors encountered.
- Rate limits: If you encounter rate limit errors, the bot will automatically wait before trying again
- Authentication issues: Ensure your API keys and tokens are correct in the
.env
file - Missing dependencies: Make sure all required packages are installed with
uv
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.