Skip to content

OkeyAmy/PromptHash

Repository files navigation

AI Prompt Marketplace

PromptHash Dashboard

PromptHash

PromptHash is a dynamic, AI-powered marketplace connecting prompt creators with users seeking inspiration, productivity, and cutting-edge solutions. Leveraging the high-throughput, low-latency Hedera Hashgraph network for core marketplace operations and privacy-focused tooling for AI integration, our platform enables users to explore, create, buy, and sell high-quality AI prompts across various categories.


πŸš€ Vision

Our vision is to become the go-to resource where creators and users convergeβ€”leveraging advanced AI models, enterprise-grade Hedera Hashgraph infrastructure, and intuitive designβ€”to spark transformative ideas across industries.


πŸ”‘ Key Features

  • πŸ” Browse & Discover: Explore curated collections of AI prompts from top creators.
  • πŸ’° Buy & Sell Prompts: Monetize your expertise or find the perfect prompt, with all transactions settled via HBAR on Hedera.
  • πŸ€– Advanced AI Integration: Powered by cutting-edge AI models (e.g., DeepSeek R1, Llama 3.2 Vision) through our privacy-preserving AI gateway.
  • πŸ”— Hedera Smart Contracts: On-chain prompt registry and payment escrow flows executed on Hedera using Solidity-compatible smart contracts.
  • πŸ”’ Blockchain Security: Built on Hedera’s asynchronous Byzantine Fault Tolerance (aBFT) infrastructure for enterprise-grade safety.
  • πŸ’¬ Conversational AI: Maintain context-aware chat sessions to refine or generate prompts in real time.
  • πŸ›οΈ Governance: Community-driven platform development and on-chain governance proposals via Hedera governance service.
  • ✨ Prompt Engineering Tools: Interactive utilities to analyze, optimize, and refactor AI prompts.
  • πŸ‘¨β€πŸ’» Creator Profiles: Dedicated spaces for top prompt creators, with on-chain reputation badges.
  • πŸ–ΌοΈ Multi-Format Support: Generate images, text, and code with ease.
  • πŸ“š Comprehensive Documentation: Detailed API documentation available via Swagger UI and ReDoc.

βš™οΈ Features & Overview

Discover & Explore

Browse a curated collection of AI prompts across categories like Coding, Marketing, Creative Writing, and Business.

Sell & Share

List and monetize your top AI prompts with instant HBAR settlements. Smart contract escrow ensures prompt delivery before funds release.

Interactive Chat

Use our AI chatbox to get prompt recommendations and marketplace insights, with seamless on-chain logging of session metadata.

Responsive UI

Built with Next.js, React, and Tailwind CSS for a seamless, mobile-first experience.

API Integration

Easy integration with your applications via our RESTful and GraphQL API endpoints, complete with Hedera transaction whitelisting.


πŸ› οΈ Categories

  • πŸ“Έ Image Prompts: For visual content generation.
  • πŸ“ Text & Writing: Creative writing, copywriting, and content creation.
  • πŸ“Š Marketing Copy: Advertising, emails, and conversion-focused content.
  • πŸ’‘ Creative Ideas: Brainstorming and concept development.
  • πŸš€ Productivity Boosters: Efficiency and workflow optimization.
  • πŸ’» Code Generation: Programming assistance and development.

πŸ—οΈ Tech Stack

  • Frontend: Next.js, React, Tailwind CSS
  • Backend: FastAPI for AI services; Node.js/Express for blockchain gateway
  • AI Integration: Private inference through Secret Network AI API
  • Blockchain Integration: Hedera Hashgraph via Hedera JavaScript SDK / hethers.js
  • Smart Contracts: Solidity (v0.8.17) deployed on Hedera Testnet/Mainnet
  • Authentication: Wallet Connect & Hedera DID for user login
  • Server: Uvicorn (ASGI) and Node.js processes managed with PM2
  • Icons & UI: Lucide for icon components

πŸ”— Hedera Integration Details

To seamlessly integrate Hedera’s enterprise-grade services, PromptHash leverages four core Hedera offeringsβ€”JavaScript SDK client setup, the Smart Contract Service (HSCS), the Token Service (HTS), and the Consensus Service (HCS). Each component is provisioned and configured via environment variables, code snippets, and CLI workflows outlined below.

1. Client & SDK Setup

Prerequisites

  • Node.js v18+ and npm

  • Hedera Testnet Operator ID & Private Key

  • .env configured in project root:

    OPERATOR_ACCOUNT_ID=0.0.xxxxx
    OPERATOR_ACCOUNT_PRIVATE_KEY=302e020100300...
    HEDERA_NETWORK=testnet

Initialization (JavaScript)

import { Client } from "@hashgraph/sdk";

// Load from .env
const operatorId = process.env.OPERATOR_ACCOUNT_ID;
const operatorKey = process.env.OPERATOR_ACCOUNT_PRIVATE_KEY;

// Configure client for testnet
const client = Client.forName(process.env.HEDERA_NETWORK);
client.setOperator(operatorId, operatorKey);

export default client;

2. Smart Contract Service (HSCS)

Compilation & Packaging

# Install Solidity compiler
npm install solc

# Compile contract
solcjs contracts/PromptHash.sol --bin --abi --output-dir build

Artifacts generated:

  • build/PromptHash.bin (bytecode)
  • build/PromptHash.abi (ABI)

Deployment (ethers.js)

import { JsonRpcProvider } from "@ethersproject/providers";
import { Wallet, ContractFactory } from "@ethersproject/ethers";
import fs from "fs";

const provider = new JsonRpcProvider(process.env.HEDERA_RPC_URL);
const wallet = new Wallet(process.env.OPERATOR_ACCOUNT_PRIVATE_KEY, provider);

const bytecode = fs.readFileSync("build/PromptHash.bin");
const abi = JSON.parse(fs.readFileSync("build/PromptHash.abi"));

const factory = new ContractFactory(abi, bytecode, wallet);
(async () => {
  const contract = await factory.deploy();
  await contract.deployed();
  console.log("Contract Address:", contract.address);
})();

3. Tokenization with Hedera Token Service (HTS)

Token Creation

import { TokenCreateTransaction } from "@hashgraph/sdk";

const transaction = new TokenCreateTransaction()
  .setTokenName("PromptToken")
  .setTokenSymbol("PRMPT")
  .setDecimals(0)
  .setInitialSupply(1000)
  .setTreasuryAccountId(operatorId);

const response = await transaction.execute(client);
const receipt = await response.getReceipt(client);
console.log("HTS Token ID:", receipt.tokenId.toString());

Minting & Transfer

import { TokenMintTransaction, TransferTransaction } from "@hashgraph/sdk";

await new TokenMintTransaction()
  .setTokenId(receipt.tokenId)
  .setSupply(500)
  .execute(client);

await new TransferTransaction()
  .addTokenTransfer(receipt.tokenId, operatorId, "0.0.xxxxx")
  .execute(client);

4. Consensus Logging via Hedera Consensus Service (HCS)

Topic Creation & Messaging

import { TopicCreateTransaction, TopicMessageSubmitTransaction } from "@hashgraph/sdk";

// Create HCS topic
const topicResponse = await new TopicCreateTransaction().execute(client);
const topicId = (await topicResponse.getReceipt(client)).topicId;

// Publish a message
await new TopicMessageSubmitTransaction({ topicId })
  .setMessage("User 0.0.12345 bought prompt #6789")
  .execute(client);

Subscribing (Mirror Node)

import { MirrorClient } from "@hashgraph/sdk";

const mirrorClient = new MirrorClient("https://testnet.mirrornode.hedera.com");
mirrorClient.subscribe(
  { topicId },
  (message) => console.log("Received message:", message)
);

πŸ“‹ Prerequisites

  • Node.js v18+ and npm
  • Python 3.12.0
  • Hedera Testnet Account (Operator ID & Private Key)
  • HBAR in your testnet wallet for gas and escrow
  • Secret AI API Key (for AI-powered features)
  • Web browser with wallet extension (supporting Hedera DID)

πŸ”§ Installation

  1. Clone the Repository

    git clone https://github.com/OkeyAmy/PromptHash.git
    cd PromptHash
  2. Backend Setup (Python)

    python -m venv venv
    source venv/bin/activate    # Linux/Mac
    venv\Scripts\activate     # Windows
    pip install -r requirements.txt
  3. Blockchain Gateway & Frontend

    cd hbara-gateway
    npm install
    cd ../frontend
    npm install
  4. Configure Environment Variables Create a .env file in project root with:

    # Hedera
    OPERATOR_ACCOUNT_ID=0.0.xxxxx
    OPERATOR_ACCOUNT_PRIVATE_KEY=302e020100300...
    HEDERA_NETWORK=testnet
    
    # AI
    SECRET_AI_API_KEY=your_secret_ai_key
    
    # Frontend
    NEXT_PUBLIC_API_URL=http://localhost:8000

▢️ Running the Services

  1. Start Python AI API

    uvicorn app.main:app --reload --port 8000
  2. Start Blockchain Gateway

    cd hbara-gateway
    npm run dev
  3. Start Frontend

    cd frontend
    npm run dev

πŸ“„ API Documentation

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

πŸ“œ API Endpoints

Models

  • GET /api/models – Retrieve available AI models.

Chat

  • GET /api/chat – Chat with AI model.

    • Parameters: prompt (string), model (optional)

Prompt Improvement

  • POST /api/improve-prompt – Analyze and improve a prompt.

    • Body: { "prompt": "..." }

Health Check

  • GET /api/health – Check API health status.

πŸ§‘β€πŸ’» Hedera Smart Contract Deployment

Prerequisites

  • Hedera testnet account funded with HBAR
  • OPERATOR_ACCOUNT_ID & OPERATOR_ACCOUNT_PRIVATE_KEY set in .env

Compile Contract

cd contracts
solcjs PromptHash.sol --bin --abi --output-dir build

Generates PromptHash.bin and PromptHash.abi in build/

Deploy Contract (deployScript.js)

node deployScript.js
  • Logs deployment address and transaction fee.

Verify on HashScan

  1. Visit https://hashscan.io/testnet
  2. Search contract address.
  3. Click β€œVerify Contract” and upload PromptHash.sol, build/PromptHash_abi.json, build/PromptHash_metadata.json.

πŸ—‚οΈ Project Structure

PromptHash/
β”œβ”€β”€ contracts/           # Solidity smart contracts
β”œβ”€β”€ hbara-gateway/       # Node.js blockchain gateway
β”œβ”€β”€ frontend/            # Next.js/React application
β”œβ”€β”€ app/                 # FastAPI AI services
β”‚   β”œβ”€β”€ config.py
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ models.py
β”‚   └── routers/
β”œβ”€β”€ requirements.txt     # Python dependencies
β”œβ”€β”€ package.json         # Gateway & Frontend dependencies
└── README.md            # Project documentation

πŸ“¦ Dependencies

  • FastAPI, Pydantic, Uvicorn
  • Hedera JavaScript SDK, ethers.js
  • Secret AI SDK
  • Next.js, React, Tailwind CSS, Lucide

πŸŽ₯ Watch Demo: PromptHash Consensus Service

❀️ Contributing

We welcome contributions! Please read CONTRIBUTING.md for guidelines on setting up your development environment, coding standards, and submitting pull requests.


About

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors