Quickstart
Checklist:
This section helps developers quickly set up the essential components of the PromptHub protocol. It includes building the smart contract layer, initializing SDKs, and launching a local web interface for testing and development.
Prerequisites
Before you begin, ensure your development environment meets these requirements:
# Required system dependencies
$ node -v # Required: v16.0.0 or higher
$ npm -v # Required: v8.0.0 or higher
$ solana --version # Required: v1.14.0 or higher
$ anchor --version # Required: v0.26.0 or higher
# Set up Solana development environment if needed
$ sh -c "$(curl -sSfL https://release.solana.com/v1.14.2/install)"
$ solana-keygen new # Generate a new keypair if you don't have one
1. Core Protocol Setup
# Clone and initialize the core protocol repository
$ git clone https://github.com/PromptHubLabs/prompthub-protocol.git
$ cd prompthub-protocol
$ npm install
# Configure your development environment
$ cp .env.example .env
$ nano .env # Edit with your Solana keypair path and RPC provider
# Build Solana smart contracts
$ anchor build
$ anchor keys sync # Sync program IDs with declaration file
# Start local validator (optional for testnet)
$ solana-test-validator
# Deploy contracts to localnet/devnet
$ anchor deploy --provider.cluster devnet # For devnet deployment
# OR
$ anchor deploy # For local development (default)
# Verify deployment
$ solana program show --output json <PROGRAM_ID>
2. SDK Integration
# Clone the SDK repository
$ git clone https://github.com/PromptHubLabs/prompthub-sdk.git
$ cd prompthub-sdk
$ npm install
# Configure SDK to point to your deployment
$ cp config.example.json config.json
$ nano config.json # Update with your deployed program IDs
# Run sample agent interactions
$ node examples/registerPrompt.js
$ node examples/callPrompt.js
# Example output:
# > Prompt registered with ID: my_summarizer_v1
# > Transaction signature: 5K3QC9Vj2aUh2Aig6...
The SDK exposes the following core interfaces:
// Main client class
const client = new PromptHubClient({
cluster: "devnet", // or "mainnet-beta", "localnet"
wallet: new NodeWallet(yourKeypair), // or web-based wallet adapter
promptVaultProgramId: "abc123...", // Your deployed program ID
});
// Register a new prompt
const promptId = await client.registerPrompt({
name: "Text Summarizer",
description: "Summarizes long text into concise points",
inputs: {
"text": { type: "string", required: true },
"length": { type: "number", default: 3 }
},
template: "Summarize this text in {{length}} bullet points: {{text}}",
// ... other fields
});
// Execute a prompt
const result = await client.executePrompt("text_summarizer_v1", {
text: "This is a long document that needs summarization...",
length: 5
});
console.log(result.output); // The summarized text
console.log(result.signature); // PromptSig verification hash
3. Frontend Application
# Clone and run the frontend application
$ git clone https://github.com/PromptHubLabs/prompthub-app.git
$ cd prompthub-app
$ npm install
# Configure app environment
$ cp .env.local.example .env.local
$ nano .env.local # Add your RPC URL and program IDs
# Start local development server
$ npm run dev # Starts at http://localhost:3000
# For production build
$ npm run build
$ npm start
The frontend application provides:
A visual PromptDSL editor with schema validation
PromptVault explorer for browsing public prompts
DAG Builder interface for creating multi-step workflows
Wallet integration for on-chain transactions
4. Common Issues and Troubleshooting
Problem: Anchor build fails with Rust errorsSolution: Ensure you have Rust toolchain installed: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Problem: Transaction errors during prompt registrationSolution: Check SOL balance: solana balance
. Airdrop if needed: solana airdrop 2
Problem: SDK connection issuesSolution: Verify RPC endpoint is correct and responsive: curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"getHealth"}' https://your-rpc-endpoint
Once initialized, developers can:
Register new prompts via the frontend
Browse the PromptVault and Asset Store
Visualize prompt DAGs
Simulate prompt invocation with model-compatible agents
These tools together form a full-stack developer environment for building on PromptHub.
Last updated