Stacks DeFi AI Agent
An AI-powered assistant for interacting with the Stacks blockchain and its DeFi ecosystem. Built with Next.js, Vercel AI SDK, and OpenAI.
Features
- Wallet Information: Get wallet address, balances, and transaction history
- Velar Protocol: View available tokens and pools
- AlexGo Protocol: Check fee rates, available tokens, and token prices
- sBTC Incentives: Manage enrollment, check rewards, and view cycle information
- Natural Language Interface: Interact with blockchain protocols through conversation
Architecture
This project uses a modern agent-based architecture:
- Tools Layer: Functions for interacting with blockchain protocols
- Agent Layer: AI assistant with tools for completing tasks
- API Layer: Next.js API routes for handling requests
- UI Layer: Chat interface for user interaction
Protocol Support
The agent currently supports interaction with these Stacks protocols:
- Basic Wallet Functions: STX balance, token balances, transactions
- Velar Protocol: DEX info, token information, pools
- AlexGo Protocol: Token swapping rates, available tokens, prices
- sBTC: Incentives program enrollment and rewards
Getting Started
Prerequisites
- Node.js 18+ installed
- OpenAI API key
- Stacks wallet mnemonic phrase
Usage Examples
You can ask the agent questions like:
- "What's my wallet address?"
- "Show my STX balance"
- "What tokens do I have?"
- "Show my recent transactions"
- "Tell me about Velar protocol"
- "What tokens are available on AlexGo?"
- "Check if I'm enrolled in sBTC incentives"
Extending the Agent
The agent is designed to be extensible:
- Add new blockchain functions in the
lib/blockchain/directory - Create new tools in
lib/agents/tools.ts - Update the system prompt in
app/api/chat/route.ts
Credits
This project builds upon concepts from the repository, adapting them to a modern web interface using the AI SDK.
Technologies Used
- Next.js: React framework for web UI and API routes
- Vercel AI SDK: For defining AI agents, tools, and streaming
- OpenAI GPT-4o: Powers the assistant with natural language understanding
- Stacks.js: Libraries for Stacks blockchain interaction
- TypeScript: Type-safe code
- Tailwind CSS: Styling
Built With
- alex
- sbtc
- stacks
- velar

Log in or sign up for Devpost to join the conversation.