An open-source AI agent framework for building intelligent assistants into Solana dApps. Powered by Next.js and OpenAI.
Lexicon allows you to easily integrate an AI assistant into your Solana dApp that can:
- Execute on-chain transactions
- Swap tokens using Jupiter
- Check wallet balances and portfolios
- Provide custom functionality through configurable functions
- Set up environment variables by creating a
.env
file in the root directory:
# Required: OpenAI API key for the AI functionality
OPENAI_API_KEY=your_openai_api_key
# Required: OpenAI model to use (e.g., gpt-4, gpt-3.5-turbo)
NEXT_PUBLIC_AI_MODEL=gpt-4o
# Optional: MongoDB connection for token mappings (if you want to use token mappings, and save addresses = tickers)
MONGODB_URI=your_mongodb_uri
MONGODB_DB=your_database_name
# Required: Your app's URL
NEXT_PUBLIC_APP_URL=http://localhost:3000
# Optional: Helius endpoint for DAS APIs
NEXT_PUBLIC_HELIUS_API_KEY=your_helius_api_key
- Install the dependencies:
npm install
# or
yarn install
# or
pnpm install
- Run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
- Open http://localhost:3000 to see the demo app.
Add your custom functions in the app/configs
directory:
// app/configs/your-config/functionDefs.ts
export const tools = [
{
name: "your_function_name",
description: "Description of what your function does",
parameters: {
// OpenAI function calling parameters
},
},
];
// app/configs/your-config/functions.ts
export const functionHandlers = {
your_function_name: async (args, wallet) => {
// Function implementation
},
};
// app/configs/your-config/systemPrompt.ts
export const systemPrompt = `Your AI assistant's personality and instructions`;
Add the Lexicon iframe widget to your app after hosting it at the desired location.
<script
src="/lexicon-embed.js"
data-config-id="default"
async
defer
></script>
The component is built with Tailwind CSS and is fully customizable. Override styles through:
- Custom className props
- Tailwind CSS classes
- CSS modules
- Styled-components
- 🤖 AI-powered chat interface
- 💱 Built-in Solana transaction capabilities
- 🔄 Jupiter DEX integration
- 👛 Wallet connection handling
- ⚙️ Configurable function framework
- 🎨 Customizable UI/UX
- 📱 Responsive design
- ⚡️ Real-time updates
This project is licensed under the MIT License - see the LICENSE file for details.