A modern web application built with Next.js and Solana integration, featuring authentication via Turnkey and AI capabilities.

Demo

Features

Authentication

Secure user authentication powered by Turnkey’s embedded wallet solution

Solana Integration

Built with Solana Agent Kit for blockchain interactions and transactions

AI Capabilities

OpenAI integration for intelligent features and natural language interactions

Modern UI

Built with modern UI components and Tailwind CSS for a sleek user experience

Type Safety

Full TypeScript support throughout the application codebase

Tech Stack

CategoryTechnologies
FrameworkNext.js
AuthenticationTurnkey
BlockchainSolana Web3.js, Solana Agent Kit
StylingTailwind CSS
AIOpenAI SDK
DevelopmentTypeScript

Installation

1

Clone the repository

# Clone the starter template
npx gitpick sendaifun/solana-agent-kit/examples/turnkey-agent-starter -b v2
cd turnkey-agent-starter
2

Install dependencies

pnpm install
3

Set up environment variables

Create a .env.local file in the root directory with the following variables:

# Turnkey credentials
NEXT_PUBLIC_TURNKEY_API_BASE_URL=
NEXT_PUBLIC_TURNKEY_API_PUBLIC_KEY=
NEXT_PUBLIC_TURNKEY_ORGANIZATION_ID=
NEXT_PUBLIC_TURNKEY_API_PRIVATE_KEY=

# Solana configuration
NEXT_PUBLIC_RPC_URL=

# OpenAI API key
OPENAI_API_KEY=

Development

Start the development server:

pnpm dev

The application will be available at http://localhost:3000.

Project Structure

src/app
├── components/     # UI components
├── chat/           # /chat route
└── utils/          # Utility functions

Turnkey Integration

This starter uses Turnkey to provide a secure embedded wallet experience. Turnkey offers several advantages for Solana Agent Kit applications:

  • Enhanced Security: Private keys are stored in secure enclaves
  • Programmatic Control: Fine-grained control over wallet operations
  • Customizable Policies: Set rules and limits for transactions
  • Multi-user Support: Easily manage wallets for multiple users

Key Benefits

Secure Authentication Flow

With Turnkey, this starter provides a secure authentication flow that protects users’ private keys. Unlike traditional wallets, private keys are never exposed to the application or the user.

Fine-grained Transaction Control

The integration allows for fine-grained control over transactions, making it possible to:

  • Implement approval workflows
  • Set transaction limits
  • Create custom authorization rules
  • Apply spending controls

Seamless User Experience

Users can interact with the Solana blockchain through natural language, with the AI assistant handling the technical details. This creates a seamless experience for both blockchain beginners and experienced users.

AI Integration

The starter leverages the OpenAI API to process natural language requests and convert them into Solana Agent Kit actions. This allows users to:

  • Check balances
  • Transfer tokens
  • Swap tokens
  • Get token information
  • And much more…

This is a starter template and may not include all features or optimizations for production use (e.g the use of the OpenAI API key on the client). Please review and modify as necessary for your specific use case.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.