AgentiPy Python Toolkit

repository·main·Indexed 42 days ago

https://github.com/niceberginc/agentipy

A Python toolkit (v1.3.5) for building AI agents that interact with blockchain applications on Solana and Base. It provides tools for token trading, NFT management, DeFi interactions, and integrations with the Allora Network for price predictions, Elfa AI for blockchain data analysis, and OpenAI for image generation.

Tokens
15.8K
Snippets
42
Records
62
Agent score
53%

What's inside AgentiPy

  1. Overview of AgentiPy features

    main

    AgentiPy provides a suite of tools for AI-driven blockchain interactions, specifically targeting Solana and Base.

    Key Capabilities:

    • Broad Protocol Support: Built-in tools for various Solana protocols (Jupiter, PumpFun, Raydium, etc.).
    • Asynchronous Operations: Uses async programming for efficient blockchain communication.
    • Model Context Protocol (MCP) Support: Includes a built-in MCP server module and supports integration with dedicated MCP servers (like agentipy-mcp for Claude Desktop) for standardized AI interaction.
    • Comprehensive Toolset: Includes utilities for token trading, NFT management, DeFi interactions, price fetching, and balance checks.
    • Coingecko Integration: Tools to explore trending tokens, prices, and new pools.
  2. Community and Support for AgentiPy

    main

    You can engage with the AgentiPy ecosystem through the following channels:

    • Contributions: Fork the repository at github.com/niceberginc/agentipy/, submit pull requests, or report issues via GitHub Issues.
    • Support: Contact support@agentipy.com for assistance.
    • Updates: Follow @AgentiPy on X.
    • Community: Join the official Discord community.
  3. How SolanaAgentKit and Elfa AI tools work together

    main

    Agentipy uses a structured approach to manage blockchain and AI API interactions:

    • SolanaAgentKit: The core class used to initialize the agent. It manages authentication and connections using the provided Solana private key and Elfa AI API key.
    • Elfa AI Tools: Agentipy provides pre-built tools that wrap Elfa AI API endpoints. These tools are subclasses of Langchain's BaseTool and are designed for asynchronous execution via the _arun method.
    • get_elfaai_tools(): A function located in agentipy.langchain.elfaai that returns a list of these pre-configured, ready-to-use tools.
    • Asynchronous Execution: The library utilizes asyncio to handle API calls efficiently, allowing for high-performance data retrieval.
  4. Best practices for Pyth Oracle integration

    main

    To ensure reliability and performance when using Pyth feeds within Agentipy, follow these best practices:

    1. Check Status: Always verify data['status'] == 'TRADING' before consuming price data.
    2. Monitor Confidence: Check the returned confidence intervals for data quality and potential anomalies.
    3. Cache Results: Implement caching to reduce the frequency of RPC calls.
    4. Handle Reconnections: Implement graceful reconnection logic to manage network failures.
  5. Use Model Context Protocol (MCP) to expose blockchain actions

    main

    Agentipy includes a built-in MCP module (agentipy/mcp) that allows you to expose on-chain actions as standardized tools for AI agents. The ALL_ACTIONS dictionary aggregates actions from Solana, Allora, and Jupiter.

    To start an MCP server that exposes these tools, use start_mcp_server(agent).

    from agentipy.agent import SolanaAgentKit
    from agentipy.mcp.mcp_server import start_mcp_server
    
    agent = SolanaAgentKit(private_key="<KEY>", rpc_url="<RPC_URL>")
    start_mcp_server(agent)  # Exposes all Solana, Allora, and Jupiter actions
  6. Install the RugCheck CLI Tool

    main

    To use the RugCheck CLI tool, you need Python 3.7 or higher and an API key from RugCheck.

    Follow these steps to set up the environment:

    1. Clone the repository.
    2. Install the required aiohttp dependency.
    3. Configure your API key by replacing the YOUR_API_KEY placeholder in the rugcheck_cli.py script.
    git clone https://github.com/yourusername/rugcheck-cli.git
    cd rugcheck-cli
    pip install aiohttp
  7. Setup the Crypto Market Dashboard example

    main

    To run the Crypto Market Dashboard example, follow these steps to clone the repository, install dependencies, and configure the environment.

    1. Clone the Repository

    git clone https://github.com/niceberginc/agentipy.git
    cd agentipy/examples/CryptoMarketDashboard

    2. Install Dependencies

    Ensure you have Python 3.8+ installed, then run:

    pip install -r requirements.txt
    git clone https://github.com/niceberginc/agentipy.git
    cd agentipy/examples/CryptoMarketDashboard
    pip install -r requirements.txt
  8. Install Agentipy MCP Server & Discord Bot

    main

    You can install the project using a quick install method by cloning the repository and using a virtual environment, or via a manual setup by installing specific dependencies.

    Quick Install:

    1. Clone the repository.
    2. Create and activate a Python virtual environment.
    3. Install dependencies via pip install -r requirements.txt.

    Manual Setup Dependencies: If installing manually, ensure you install the following packages: agentipy>=2.0.8, cryptography>=3.4.7, python-dotenv>=0.17.1, web3>=7.8.0, allora_sdk>=0.2.0, mcp>=1.4.0, discord.py>=2.3.2, and aiohttp>=3.8.4.

    # Quick Install
    git clone https://github.com/niceberginc/agentipy-mcp
    cd agentipy-mcp
    
    python -m venv .venv
    source .venv/bin/activate  # On Windows, use `.venv\Scripts\activate`
    
    pip install -r requirements.txt
  9. Run the Agentipy CoinGecko Explorer

    main

    The CoinGecko Explorer is an asynchronous tool that uses LangGraph to orchestrate multiple data-fetching tasks and OpenAI's GPT-3.5-turbo for analysis.

    When executed, the tool performs the following workflow:

    1. Fetch Trending Tokens: Retrieves trending tokens from CoinGecko.
    2. Fetch Price Data: Extracts current price data for the top 5 tokens.
    3. Token Information: Fetches detailed token info (includes fallback logic for invalid addresses).
    4. Top Gainers: Retrieves tokens with the highest 24h gains.
    5. LLM Analysis: Uses GPT-3.5-turbo to analyze the gathered token information.
    6. Logging: Maintains a state memory log of all workflow steps for debugging.

    To run the tool, execute the script directly:

    python coingecko_explorer.py
  10. Install the Agentipy Pyth Oracle Tool

    main

    To use the Pyth Network integration, install the core agentipy package. If you intend to use the advanced LangChain integration (as seen in main2.py), you must also install the LangChain and OpenAI dependencies.

    Requirements:

    • Python 3.8+
    • pip
    # Core installation
    pip install agentipy
    
    # Optional: For LangChain/OpenAI integration
    pip install langchain-openai langchain-core langchain-community python-dotenv
  11. Security Best Practices for AgentiPy

    main

    When building blockchain applications with AgentiPy, follow these security guidelines to protect your assets:

    • Secure Private Keys: Never hardcode private keys directly into your source code, especially when interacting with Mainnet.
    • Use Environment Variables: Store sensitive data like private keys and API credentials in environment variables.
    • Test on Devnet/Testnet: Always validate your agent's logic and transaction flows on a development or test network before deploying to Mainnet.