Skip to content

Repository files navigation

Event Hash

A sophisticated proof-of-concept demonstrating how AI agents can simplify complex blockchain operations while maintaining security and transparency through Hedera's enterprise-grade infrastructure.

This full-stack Next.js dApp combines natural language AI interactions with blockchain event management, featuring on-chain event creation, NFT ticket minting on Hedera, off-chain HBAR payment verification, and automated check-in with Hedera Consensus Service (HCS) audit logs.

πŸš€ Key Innovation

HashBot AI Agent - Interact with the Hedera blockchain using natural language commands. Create events, mint tickets, and manage blockchain operations through conversational AI powered by Groq LLM and the Hedera Agent Kit.

✨ Features

  • πŸ€– AI-Powered Blockchain Operations - Natural language interface for complex Hedera transactions
  • 🎨 Clean, Modern UI with Tailwind CSS and responsive design
  • πŸ” Transparent HashScan Integration for all on-chain activities
  • πŸ“Š Mirror Node Verification for payments and ownership validation
  • 🏒 Vendor Dashboard - Create events, deploy on-chain, mint NFT tickets
  • πŸŽͺ Public Events Marketplace - Browse and discover events
  • πŸ’³ Secure Ticket Purchase API with Mirror Node payment verification
  • βœ… Smart Check-In System with HCS logging and ownership validation
  • ⚑ Hedera SDK Integration - Enterprise-grade blockchain infrastructure

πŸ›  Tech Stack

  • Frontend: Next.js 15 (App Router), TypeScript, Tailwind CSS
  • Blockchain: Hedera JS SDK (@hashgraph/sdk), HCS Topics, NFT Collections
  • AI: LangChain, Groq LLM (llama-3.1-8b-instant), Hedera Agent Kit
  • Data: Hedera Mirror Node REST API, File-based storage (demo)
  • State Management: React Query, Zod validation

πŸš€ Quick Start

Install Dependencies

npm install
# or
yarn install

Configure Environment

Copy .env.example to .env and configure your Hedera credentials:

# Backend (server-only) - Never expose these!
HEDERA_NETWORK=testnet
HEDERA_ACCOUNT_ID=0.0.xxxxx
HEDERA_PRIVATE_KEY=302e02...
HEDERA_MIRROR_URL=https://testnet.mirrornode.hedera.com

# Frontend (client-available)
NEXT_PUBLIC_WALLET_CONNECT_ID=
NEXT_PUBLIC_RPC_URL=
NEXT_PUBLIC_HEDERA_NETWORK=testnet
NEXT_PUBLIC_BASE_URL=http://localhost:3000

# AI Integration
GROQ_API_KEY=

Run Development Server

npm run dev
# or
yarn dev

Open http://localhost:3000 and start creating events with AI assistance!

πŸ“ Architecture Overview

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ chat/route.ts                 # AI agent endpoint
β”‚   β”‚   └── events/
β”‚   β”‚       β”œβ”€β”€ route.ts                  # Event CRUD operations
β”‚   β”‚       β”œβ”€β”€ purchase/route.ts         # Payment verification + ticket minting
β”‚   β”‚       β”œβ”€β”€ checkin/route.ts          # Ownership validation + HCS logging
β”‚   β”‚       β”œβ”€β”€ deploy/route.ts           # Deploy event to HCS topic
β”‚   β”‚       β”œβ”€β”€ tickets/route.ts          # Create NFT ticket collections
β”‚   β”‚       └── extract/route.ts          # AI-powered event detail extraction
β”‚   β”œβ”€β”€ events/
β”‚   β”‚   β”œβ”€β”€ page.tsx                      # Events marketplace
β”‚   β”‚   └── [id]/page.tsx                 # Event details + purchase flow
β”‚   β”œβ”€β”€ checkin/page.tsx                  # Ticket validation interface
β”‚   β”œβ”€β”€ vendor/page.tsx                   # Event creation dashboard
β”‚   └── page.tsx                          # Landing page with AI chat
β”œβ”€β”€ components/
β”‚   └── chat-interface.tsx                # HashBot AI chat component
β”œβ”€β”€ server/
β”‚   β”œβ”€β”€ initialize-agent.ts               # AI agent configuration
β”‚   └── event-service-tools.ts            # Custom Hedera tools for AI
└── lib/
    └── hedera-event-service.ts           # Core Hedera operations wrapper

πŸ€– AI Agent Workflows

Natural Language Event Creation

User: "Create a tech conference on December 15th in San Francisco, $50 tickets, max 200 people"
HashBot: βœ… Created event with HCS topic 0.0.12345 and deployed NFT collection!

Intelligent Ticket Management

User: "Create 100 tickets for my event"
HashBot: βœ… Minted NFT collection with 100 tickets, ready for purchase!

Conversational Check-ins

User: "Check in ticket #42 for event 0.0.12345"
HashBot: βœ… Verified ownership and logged check-in to HCS audit trail!

πŸ” Security Architecture

Environment Variables

Server-only (never exposed to client)

  • HEDERA_ACCOUNT_ID - Your operator account
  • HEDERA_PRIVATE_KEY - Private key for blockchain operations
  • HEDERA_MIRROR_URL - Mirror node endpoint
  • GROQ_API_KEY - AI model access

Client-available (prefixed with NEXT_PUBLIC_)

  • NEXT_PUBLIC_HEDERA_NETWORK - Network identifier
  • NEXT_PUBLIC_BASE_URL - Application base URL

⚠️ Critical: Ensure network alignment across server and client configurations.

🎯 Core Workflows

1. AI-Assisted Event Creation

  1. Open HashBot chat or visit /vendor
  2. Describe your event in natural language
  3. AI extracts structured data and creates blockchain resources
  4. Get HCS Topic ID and HashScan links automatically

2. Blockchain Event Deployment

  1. AI agent creates HCS Topic for event audit trail
  2. Stores event metadata on-chain
  3. Returns Topic ID with HashScan verification link

3. NFT Ticket Collection Creation

  1. AI agent mints NFT collection for tickets
  2. Configures supply, metadata, and pricing
  3. Returns Token ID with HashScan verification

4. Secure Purchase Flow

  1. Buyer sends HBAR to vendor (off-chain)
  2. Submits payment transaction ID through UI
  3. Backend verifies payment via Mirror Node
  4. AI agent mints and transfers NFT ticket to buyer
  5. Logs purchase to event's HCS topic

5. Smart Check-in System

  1. Scan QR code or enter ticket details
  2. AI agent validates current ownership via Mirror Node
  3. Logs check-in event to HCS audit trail
  4. Returns verification with HashScan links

πŸ”— API Endpoints

AI Agent Interface

POST /api/chat
{
  "userAccountId": "0.0.buyer",
  "input": "Create a music festival next month",
  "history": [...] // Chat context
}

Event Management

POST /api/events/purchase
{
  "eventId": "0.0.topicId",
  "buyerAccountId": "0.0.buyer",
  "paymentTxId": "0.0.from@timestamp",
  "ticketTokenId": "0.0.tokenId"
}

Check-in Validation

POST /api/events/checkin
{
  "eventId": "0.0.topicId",
  "tokenId": "0.0.tokenId",
  "serialNumber": 1,
  "ownerAccountId": "0.0.owner" // Optional strict validation
}

🌐 HashScan Integration

All blockchain operations include transparent HashScan links:

  • Topics: https://hashscan.io/{network}/topic/{topicId}
  • Tokens: https://hashscan.io/{network}/token/{tokenId}
  • Transactions: https://hashscan.io/{network}/transaction/{txId}

πŸš€ Deployment

# Production build
npm run build

# Start production server
npm start

# Lint code
npm run lint

πŸ”§ Troubleshooting

AI Agent Issues

  • Verify GROQ_API_KEY is set correctly
  • Check Hedera network alignment in environment variables
  • Restart development server after .env changes

Blockchain Operations

  • Ensure sufficient HBAR balance in operator account
  • Verify payment transaction IDs are valid and confirmed
  • Check Mirror Node connectivity for payment verification

Network Configuration

  • HEDERA_NETWORK and NEXT_PUBLIC_HEDERA_NETWORK must match
  • Use correct Mirror Node URL for your network (testnet/mainnet)

πŸ›‘οΈ Security Best Practices

  • ❌ Never expose private keys to client-side code
  • βœ… All privileged operations happen server-side
  • βœ… Payment verification through Mirror Node
  • βœ… Ownership validation before check-ins

Production Recommendations

  • Replace file-based storage with enterprise database
  • Implement role-based access control (RBAC)
  • Add comprehensive rate limiting and monitoring
  • Set up proper audit logging and alerting
  • Use hardware security modules (HSM) for key management

πŸ—ΊοΈ Roadmap

  • Enhanced Wallet Integration - Seamless association and signing UX
  • QR Code Check-ins - Mobile-first ticket validation
  • Database Migration - PostgreSQL/MongoDB backend
  • Advanced RBAC - Multi-tenant vendor management
  • Ticket Marketplace - Secondary sales with royalties
  • Mobile App - React Native companion app
  • Analytics Dashboard - Event performance metrics
  • Multi-language Support - Global accessibility

🀝 Contributing

This proof-of-concept demonstrates the potential of AI-blockchain integration. Contributions welcome for:

  • Enhanced AI agent capabilities
  • Additional Hedera service integrations
  • UI/UX improvements
  • Security enhancements

πŸ“„ License

Unlicensed

Built with ❀️ using Hedera's enterprise blockchain infrastructure and cutting-edge AI technology.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages