npm package: @ordlibrary/create-x402
Description: Create and deploy your own X402 Solana AI agents
Latest version: 0.1.0

# Create X402 - Build & Deploy Solana AI Agents

<div align="center">
  <img src="https://elizaos.github.io/eliza-avatars/x402-logo.png" alt="X402" width="200" />

  **The easiest way to create, customize, and deploy Solana AI agents**

  [![npm version](https://badge.fury.io/js/@elizaos%2Fcreate-x402.svg)](https://www.npmjs.com/package/@elizaos/create-x402)
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
</div>

## 🚀 Quick Start

Create your first X402 agent in under 2 minutes:

```bash
bun create x402
```

Or with npm/npx:
```bash
npx @elizaos/create-x402
```

## 📦 What is X402?

X402 is a powerful framework for building Solana AI agents with:

- 🤖 **Multi-Provider AI** - Google Gemini, OpenAI, Anthropic, xAI Grok
- ⛓️ **Solana Integration** - Built-in Helius RPC, Jupiter DEX, Metaplex NFTs
- 🎨 **Content Creation** - AI image, video, 3D, and music generation
- 💬 **Social Platforms** - Twitter, Discord, Telegram automation
- 🚀 **One-Click Deploy** - Railway, Vercel, Render, Fly.io
- 📊 **Web Dashboard** - Manage agents from beautiful UI

## 🏗️ Agent Types

### 1. Trading Agent
Automated Solana trading with risk management
- Jupiter DEX integration
- Real-time market analysis
- Position management
- Risk controls

### 2. Content Creator
AI-powered media generation
- Images (FAL, Stability, Runway)
- Videos (Kling, Veo, Hunyuan)
- 3D models (Tripo3D, Trellis)
- Music & audio (ElevenLabs, MMAudio)

### 3. Social Media Agent
Autonomous social engagement
- Twitter posting & replies
- Discord community management
- Telegram bot interactions

### 4. Developer Agent
Code generation & deployment
- GitHub integration
- E2B sandboxing
- Vercel deployments
- Code reviews

### 5. Custom Agent
Full X402 capabilities - build anything!

## 🎯 Features

### Multi-Provider AI

// Automatically uses best provider
MODEL_PROVIDER=gemini  // or openai, anthropic, xai
GEMINI_MODEL=gemini-2.5-flash
GEMINI_THINKING_ENABLED=true
```

### Solana Integration

// Helius RPC with DAS API
HELIUS_API_KEY=your-key
HELIUS_RPC_URL=https://mainnet.helius-rpc.com/?api-key=${HELIUS_API_KEY}

// Built-in wallet
SOLANA_PRIVATE_KEY=your-private-key
```

### One-Command Deployment
```bash
# Deploy to Railway
create-x402 --deploy railway

# Deploy to Vercel
create-x402 --deploy vercel

# Deploy to Render
create-x402 --deploy render
```

## 📚 Usage

### Interactive CLI
```bash
bun create x402
```

Follow the prompts:
1. Choose agent name
2. Select agent type
3. Configure API keys
4. Choose deployment platform
5. Deploy! 🚀

### Programmatic API
```typescript
import { createX402Agent } from '@elizaos/create-x402';

await createX402Agent({
  name: 'my-trading-agent',
  type: 'trading',
  deployment: 'railway',
  apiKeys: {
    gemini: 'your-gemini-key',
    helius: 'your-helius-key',
  }
});
```

## 🔑 Required API Keys

### Essential (Free Tier Available)
- **Google Gemini** - https://aistudio.google.com/app/apikey
- **Helius** - https://helius.dev (Solana RPC)

### Optional Providers
- OpenAI - https://platform.openai.com/api-keys
- Anthropic - https://console.anthropic.com/
- xAI Grok - https://console.x.ai

### Agent-Specific
**Trading Agent:**
- Solana private key (for trading)

**Content Creator:**
- FAL AI - https://fal.ai
- Runway - https://runwayml.com
- Stability AI - https://platform.stability.ai

**Social Agent:**
- Twitter API - https://developer.twitter.com
- Discord Bot Token - https://discord.com/developers
- Telegram Bot Token - https://t.me/botfather

## 🏗️ Project Structure

```
my-x402-agent/
├── src/
│   ├── character.ts      # Agent personality & config
│   ├── index.ts          # Entry point
│   └── plugin.ts         # Custom plugins
├── .env                  # API keys & config
├── package.json
├── tsconfig.json
└── railway.toml          # Deployment config
```

## ⚙️ Configuration

### Environment Variables
```bash
# AI Provider
GEMINI_API_KEY=your-key
MODEL_PROVIDER=gemini

# Blockchain
HELIUS_API_KEY=your-key
SOLANA_PRIVATE_KEY=your-key

# Database (optional)
POSTGRES_URL=postgresql://...

# Logging
LOG_LEVEL=info
```

### Character Customization
Edit `src/character.ts`:

```typescript
export const character: Character = {
  name: 'YourAgent',
  plugins: [
    '@elizaos/plugin-sql',
    '@elizaos/plugin-google-genai',
    '@elizaos/plugin-solana-agent-kit',
  ],
  system: `You are a helpful AI agent...`,
  bio: ['Expert in Solana', 'AI-powered'],
};
```

## 🚀 Deployment

### Railway (Recommended)
```bash
cd my-x402-agent
railway login
railway up
```

### Vercel
```bash
cd my-x402-agent
vercel login
vercel
```

### Render
```bash
cd my-x402-agent
render login
render deploy
```

### Fly.io
```bash
cd my-x402-agent
flyctl auth login
flyctl deploy
```

## 📊 Web Dashboard

Access the X402 Dashboard to manage your agents:

```bash
bun x402 dashboard
```

Features:
- 📈 Agent analytics & metrics
- ⚙️ Configuration management
- 🔄 Real-time monitoring
- 💬 Message history
- 💰 Revenue tracking

## 🔧 Advanced Usage

### Custom Plugins
```typescript
// src/plugin.ts
import { Plugin } from '@elizaos/core';

export const myPlugin: Plugin = {
  name: 'my-custom-plugin',
  actions: [/* ... */],
  providers: [/* ... */],
  services: [/* ... */],
};
```

### Multi-Agent Setup
```typescript
// src/index.ts
export const project: Project = {
  agents: [
    { character: tradingAgent },
    { character: socialAgent },
    { character: contentAgent },
  ],
};
```

### Custom Deployment
```typescript
// deploy.ts
import { X402Deployer } from '@elizaos/create-x402';

const deployer = new X402Deployer({
  platform: 'railway',
  projectName: 'my-agent',
  envVars: { /* ... */ },
});

await deployer.deploy();
```

## 🛠️ Development

### Local Development
```bash
cd my-x402-agent
bun install
bun dev  # Start with hot reload
```

### Build
```bash
bun run build
```

### Test
```bash
bun test
```

## 📖 Examples

### Trading Bot
```bash
bun create x402 --template trading
```

### Content Creator
```bash
bun create x402 --template content
```

### Social Agent
```bash
bun create x402 --template social
```

## 🤝 Support

- 📚 [Documentation](https://docs.x402.ai)
- 💬 [Discord](https://discord.gg/x402)
- 🐦 [Twitter](https://twitter.com/x402ai)
- 🐛 [Issues](https://github.com/elizaos/eliza/issues)

## 📄 License

MIT License - see [LICENSE](LICENSE) file for details

## 🙏 Credits

Built with:
- [ElizaOS](https://github.com/elizaos/eliza) - AI agent framework
- [Google Gemini](https://ai.google.dev) - AI models
- [Helius](https://helius.dev) - Solana infrastructure
- [Jupiter](https://jup.ag) - Solana DEX aggregator

---

<div align="center">
  Made with ❤️ by the X402 Team

  [Website](https://x402.ai) • [Docs](https://docs.x402.ai) • [Discord](https://discord.gg/x402)
</div>