PromptVault is the on-chain registry and lifecycle governance module of the PromptHub protocol. It serves as the canonical source of truth for all registered prompts and their associated versions, licensing terms, tokenization status, and invocation history. Deployed as an Anchor program on the Solana blockchain, PromptVault ensures that prompts are immutable, traceable, and economically enforceable.
1. Smart Contract Architecture
PromptVault is implemented as a modular Anchor program on Solana with the following core components:
// Main program structure (pseudo-code)#[program]pubmod prompt_vault {usesuper::*;// Initialize the global vault statepubfninitialize(ctx:Context<Initialize>,params:InitializeParams)->Result<()>{// Set up global parameters for the vault// Initialize fee structure, registry capabilities, etc.}// Register a new promptpubfnregister_prompt(ctx:Context<RegisterPrompt>,id:String,metadata_uri:String,version:String,license_type:u8,fee_amount:Option<u64>,token_gate:Option<Pubkey>,)->Result<()>{// Verify caller is authorized// Create on-chain prompt entry// Store IPFS content hash// Set licensing parameters// Emit registration event}// Create a new version of an existing promptpubfncreate_version(ctx:Context<CreateVersion>,prompt_id:String,metadata_uri:String,version:String,)->Result<()>{// Verify caller owns the prompt// Add new version to version history// Update metadata pointers// Emit version update event}// Execute a prompt and record the executionpubfnrecord_execution(ctx:Context<RecordExecution>,prompt_id:String,input_hash:[u8;32],output_hash:[u8;32],)->Result<()>{// Verify execution permission// Handle any token gates// Process usage fees// Record execution signature// Distribute royalties}// Update license termspubfnupdate_license(ctx:Context<UpdateLicense>,prompt_id:String,license_type:u8,fee_amount:Option<u64>,token_gate:Option<Pubkey>,)->Result<()>{// Verify caller owns the prompt// Update licensing terms// Emit license update event}// Toggle prompt visibility/statuspubfnupdate_status(ctx:Context<UpdateStatus>,prompt_id:String,status:u8,)->Result<()>{// Verify caller is authorized// Update prompt status (active, deprecated, etc.)// Emit status change event}// ... other management functions ...}
The Anchor contexts define the accounts required for each operation:
The primary on-chain data structures include:
2. Prompt Registration and Versioning
Each time a new prompt is submitted to PromptHub, PromptVault:
Generates a semantic hash of the PromptDSL structure
Links metadata (title, author, tags, version notes) to IPFS
Assigns a unique Prompt ID and version ID
Stores semantic version lineage for future forking and inheritance
The registration flow follows these steps:
Client-side: Author creates PromptDSL document
Client-side: Document is hashed and pinned to IPFS
On-chain: Author calls register_prompt with IPFS URI and metadata
On-chain: Solana program creates a PromptData account
Off-chain: Indexer picks up the registration event
Off-chain: Indexer builds searchable metadata store
Prompt authors can update prompts by submitting new versions, which are cryptographically linked to the previous state. This forms an auditable version tree and enables governance-based deprecation or certification of specific versions.
3. Token and Licensing Binding
PromptVault supports:
NFT Binding: linking a single prompt version to a PromptNFT (non-fungible)
SPL Token Binding: linking prompt usage rights to a fungible token (PromptToken)
Public or private visibility in Prompt Asset Store
4. Invocation Logging and Auditability
Each time a prompt is executed, PromptVault records a PromptSig entry, which includes:
Caller identity (wallet address or agent signature)
Prompt ID and version
Input and output content hash
Timestamp and unique nonce
This log is publicly queryable and can be used for:
Execution validation (proof of interaction)
Revenue disbursement to prompt authors
Performance analysis and ranking heuristics
The execution flow works as follows:
Client-side: Agent prepares inputs for prompt execution
Client-side: Inputs and prompt ID are hashed
On-chain: Agent calls record_execution with hashes
On-chain: Contract validates permissions and processes fees
On-chain: Execution record is stored
On-chain: Royalties are distributed to prompt author
Off-chain: Indexer updates execution statistics
5. Governance and Access Control
PromptVault enforces role-based and token-based access logic:
Authors can revoke, fork, or license their own prompts
DAO votes can certify or delist prompts
Vault admins can update system parameters or handle disputes (through governance)
DAO governance is implemented through a dedicated governance extension:
6. Integration with External Systems
PromptVault integrates with several external systems:
IPFS Integration:
All PromptDSL full definitions are stored on IPFS
Content addressing ensures immutability and versioning
IPFS CIDs are stored on-chain for reference
Metaplex Integration:
PromptNFTs leverage Metaplex metadata standard
Ensures compatibility with NFT marketplaces
Supports on-chain royalty enforcement
Oracle Integration:
Fee oracles can dynamically adjust prompt pricing
Usage statistics inform prompt rankings
External validators can attest to prompt quality
By combining metadata registration, licensing enforcement, and tamper-proof execution logs, PromptVault transforms prompt publishing into a sovereign, composable, and economic on-chain primitive.