> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendai.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# Crossmint Solana Agent

> Modern web application with Crossmint wallet integration for Solana Agent Kit

<div className="flex items-center justify-center mb-8">
  <img src="https://github.com/samridhi2003/solana-agent-kit-crossmint/raw/main/public/banner.png" alt="Crossmint Solana Agent Banner" className="rounded-md max-w-full" />
</div>

A modern web application built with TanStack Router, React, and Solana integration, featuring authentication via Crossmint and AI capabilities.

## Features

<CardGroup cols={2}>
  <Card title="Authentication" icon="key">
    Secure wallet authentication powered by Crossmint's embedded wallet solution
  </Card>

  <Card title="Solana Integration" icon="blockchain">
    Built with Solana Agent Kit for blockchain interactions and transactions
  </Card>

  <Card title="AI Capabilities" icon="robot">
    OpenAI integration for intelligent features and natural language interactions
  </Card>

  <Card title="Modern UI" icon="paintbrush">
    Built with Radix UI components and Tailwind CSS for a sleek user experience
  </Card>

  <Card title="Type Safety" icon="shield-check">
    Full TypeScript support throughout the application codebase
  </Card>

  <Card title="Database Integration" icon="database">
    PostgreSQL with Drizzle ORM for efficient data management
  </Card>
</CardGroup>

## Tech Stack

### Frontend

* React 19
* TanStack Router for type-safe routing
* Radix UI components
* Tailwind CSS for styling

### Authentication

* Crossmint embedded wallet

### Blockchain

* Solana Web3.js
* Solana Agent Kit

### Backend & Data

* PostgreSQL
* Drizzle ORM

### AI Integration

* OpenAI SDK

### Development Tools

* TypeScript
* Biome for linting and formatting
* Vinxi

## Installation

<Steps>
  <Step title="Clone the repository">
    ```bash theme={"system"}
    npx gitpick sendaifun/solana-agent-kit/examples/embedded-wallets/crossmint-sak-v2
    cd crossmint-sak-v2
    ```
  </Step>

  <Step title="Install dependencies">
    ```bash theme={"system"}
    pnpm install
    ```
  </Step>

  <Step title="Set up environment variables">
    Create a `.env` file in the root directory with the following variables:

    ```
    VITE_CROSSMINT_SECRET=your_crossmint_secret
    VITE_RPC_URL=your_solana_rpc_url
    ```
  </Step>

  <Step title="Run database migrations">
    ```bash theme={"system"}
    pnpm db:generate
    pnpm db:migrate
    ```
  </Step>
</Steps>

## Development

Start the development server:

```bash theme={"system"}
pnpm dev
```

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

## Database Management

| Command            | Description          |
| ------------------ | -------------------- |
| `pnpm db:generate` | Generate migrations  |
| `pnpm db:migrate`  | Run migrations       |
| `pnpm db:studio`   | Open database studio |
| `pnpm db:push`     | Push schema changes  |
| `pnpm db:pull`     | Pull schema changes  |
| `pnpm db:check`    | Check schema         |
| `pnpm db:up`       | Update schema        |

## Project Structure

```
src/
├── components/     # React components
├── functions/     # Server-side functions
├── hooks/         # Custom React hooks
├── lib/           # Library code and utilities
├── routes/        # Application routes
├── styles/        # Global styles
└── utils/         # Utility functions
```

## Crossmint Integration

The application uses Crossmint to provide a seamless embedded wallet experience for users. This integration allows users to:

* Create wallets without leaving the application
* Sign transactions securely
* Manage their Solana assets
* Interact with the Solana blockchain through Agent Kit

<Accordion title="Crossmint Integration Code Example">
  ```tsx theme={"system"}
  import { useCrossmintWallet } from '@/hooks/useCrossmintWallet';
  import { SolanaAgentKit, createVercelAITools } from 'solana-agent-kit';
  import TokenPlugin from '@solana-agent-kit/plugin-token';
  import { PublicKey } from '@solana/web3.js';

  // Custom hook to use Solana Agent Kit with Crossmint
  export function useSolanaAgent() {
    const { wallet, connected } = useCrossmintWallet();
    
    // Create Solana Agent Kit instance when wallet is connected
    const agent = useMemo(() => {
      if (!connected || !wallet) return null;
      
      // Initialize with the Crossmint wallet
      return new SolanaAgentKit(
        {
          publicKey: new PublicKey(wallet.publicKey),
          signTransaction: async (tx) => await wallet.signTransaction(tx),
          signMessage: async (msg) => await wallet.signMessage(msg),
          sendTransaction: async (tx) => {
            return await wallet.sendTransaction(tx);
          },
        },
        process.env.VITE_RPC_URL,
        {}
      ).use(TokenPlugin);
    }, [wallet, connected]);
    
    // Create AI tools for the agent
    const tools = useMemo(() => {
      if (!agent) return null;
      return createVercelAITools(agent, agent.actions);
    }, [agent]);
    
    return { agent, tools, connected };
  }
  ```
</Accordion>

## Key Features

### Secure Authentication

The Crossmint integration provides a secure authentication flow that doesn't require users to manage private keys directly.

### Wallet Creation

Users can create a new Solana wallet through Crossmint's embedded wallet solution with just a few clicks.

### Transaction Signing

The application handles transaction signing through Crossmint's secure interface, providing a seamless experience.

### AI-Powered Assistance

The integration of OpenAI with Solana Agent Kit allows for natural language interactions with the blockchain.

## 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.

## Credits

* [Samridhi](https://github.com/samridhi2003)
