# Gaia AI configuration
GAIA_MODEL_BASE_URL=your_gaia_model_url
GAIA_API_KEY=your_gaia_api_key // not needed if you run your own node
```

5. Start the development server:

```bash
pnpm dev
```

6. Open [http://localhost:3000](http://localhost:3000) in your browser to see the application running.

## 📖 Project Structure

```
├── .next/             # Next.js build output
├── ai/                # AI-related utilities
│   └── tools.ts       # AI tools implementation
├── app/               # Next.js App Router 
│   ├── api/           # API routes
│   ├── globals.css    # Global styles
│   ├── layout.tsx     # Root layout component
│   └── page.tsx       # Home page component
├── components/        # Reusable UI components
│   ├── ui/            # Basic UI components
│   │   ├── badge.tsx  # Badge component
│   │   ├── button.tsx # Button component
│   │   ├── card.tsx   # Card component
│   │   └── input.tsx  # Input component
│   ├── Chat.tsx       # Chat interface component
│   ├── DelegationManager.tsx # Delegation management component
│   └── Message.tsx    # Message component
├── lib/               # Utility functions and libraries
├── services/          # API services
│   ├── account.ts     # Account-related services
│   ├── bundler.ts     # Bundler service implementation
│   └── utils.ts       # Service utilities
├── public/            # Static assets
│   ├── file.svg       # File icon
│   ├── globe.svg      # Globe icon
│   ├── next.svg       # Next.js logo
│   └── vercel.svg     # Vercel logo
├── node_modules/      # Dependencies
├── .env               # Environment variables
├── package.json       # Project dependencies
└── pnpm-lock.yaml    # pnpm lock file
```

## 🔧 Configuration

### ERC20 Factory Contract Setup

This project integrates with the [ERC20 Factory Contract](https://github.com/meowyx/erc20-factory) to enable token creation capabilities. Follow these steps to set up the integration:

1. Clone and deploy the ERC20 Factory contract:
   ```bash
   git clone https://github.com/meowyx/erc20-factory
   cd erc20-factory
   npm install
   npx hardhat compile
   npx hardhat ignition deploy ignition/modules/tokenFactory.ts --network linea-testnet
   ```

2. After deployment, update your `.env` file with the deployed contract address:
   ```
   NEXT_PUBLIC_FACTORY_CONTRACT_ADDRESS=0x...  # The deployed factory contract address
   NEXT_PUBLIC_CREATE_TOKEN_SELECTOR=0x...     # The function selector for createToken
   ```

3. Update the `constants.ts` file with the ERC20 Factory ABI:
   ```typescript
   // Add the ERC20 Factory ABI to your constants.ts file
   export const FACTORY_ABI = [
     // ... ABI contents from the compiled contract
     {
       "inputs": [
         {"internalType": "string", "name": "name", "type": "string"},
         {"internalType": "string", "name": "symbol", "type": "string"},
         {"internalType": "uint8", "name": "decimals", "type": "uint8"},
         {"internalType": "uint256", "name": "initialSupply", "type": "uint256"}
       ],
       "name": "createToken",
       "outputs": [{"internalType": "address", "name": "", "type": "address"}],
       "stateMutability": "nonpayable",
       "type": "function"
     }
     // ... other ABI entries
   ];
   ```

4. The factory contract allows you to create new ERC20 tokens with custom parameters such as name, symbol, decimals, and initial supply.

The ERC20 Factory project structure:
```
erc20-factory/
├── contracts/
│   ├── BaseERC20Token.sol   # Base token implementation
│   └── ERC20Factory.sol     # Factory for deploying tokens
├── test/
│   └── ERC20Factory.test.js # Test scripts
├── ignition/
│   └── modules/
│       └── tokenFactory.js  # Deployment configuration
├── hardhat.config.js        # Hardhat configuration
└── package.json             # Project dependencies
```

### MetaMask Setup

1. Install the [MetaMask extension](https://metamask.io/) in your browser
2. Create or import a wallet
3. Connect your dApp using the provided hooks in the starter

### Gaia Integration

1. Sign up for an API key over [here](https://gaianet.ai)
2. Add your API key to the `.env` file under `GAIA_API_KEY`
3. Set the model base URL in the `.env` file under `GAIA_MODEL_BASE_URL`
4. Use the pre-configured AI tools in `ai/tools.ts` to interact with GaiaNet features

### Bundler Service Configuration

1. Get an API key from [Pimlico](https://pimlico.io/) or your preferred bundler service
2. Add the bundler URL to the `.env` file under `NEXT_PUBLIC_BUNDLER_URL`
3. Set the correct chain ID in the `.env` file under `NEXT_PUBLIC_CHAIN_ID`

### Delegation System Setup

1. Configure the delegation storage API keys in the `.env` file
2. Use the `DelegationManager.tsx` component to manage delegations between users and AI agents

## 📚 Documentation

For more detailed information about the technologies used in this starter:

- [Next.js Documentation](https://nextjs.org/docs)
- [MetaMask Documentation](https://docs.metamask.io/)
- [Gaia Documentation](https://docs.gaianet.ai/)
- [pnpm Documentation](https://pnpm.io/documentation)

## 🙏 Acknowledgements

- [MetaMask Delegation Toolkit](https://docs.gator.metamask.io/) for their Delegation Toolkit.
- [Gaia](https://gaianet.ai/) for their AI platform
- [Next.js](https://nextjs.org/) for the React framework
- [Vercel AI SDK](https://sdk.vercel.ai/) for The AI Toolkit for TypeScript

---

## Natural Language Weather App