Skip to main content

Solana Programs

Lucid has two Solana programs written in Rust using the Anchor framework. These programs provide the on-chain layer for verifiable AI — anchoring receipts and registering passports on the Solana blockchain.

lucid-receipts (Thought Epoch)

Stores epoch MMR roots on-chain. Each anchored epoch creates a Solana account containing:
FieldTypeDescription
epoch_idu64Sequential epoch identifier
mmr_root[u8; 32]Merkle Mountain Range root hash
receipt_countu32Number of receipts in the epoch
timestampi64Unix timestamp of anchoring
authorityPubkeySigner that anchored this epoch

Anchoring Flow

Offchain API → Collect receipts → Build MMR → Compute root hash

Submit Solana transaction → anchor_epoch instruction

Create on-chain epoch account with root hash

Verification

Anyone can verify a receipt belongs to an anchored epoch:
  1. Get the receipt’s MMR inclusion proof from the API
  2. Fetch the epoch’s on-chain MMR root from Solana
  3. Recompute the root from the proof and receipt hash
  4. Compare with the on-chain root
// Get proof from API
const proof = await lucid.receipts.getProof(receiptId);

// Fetch on-chain root (using @solana/web3.js)
const epochAccount = await program.account.epoch.fetch(epochPda);

// Verify
const computedRoot = computeMmrRoot(proof.leaves, proof.peaks, proof.position);
const valid = computedRoot.equals(epochAccount.mmrRoot);

lucid-registry (Lucid Passports)

Manages passport registration on-chain:
FieldTypeDescription
passport_id[u8; 32]Unique passport identifier
passport_typeenumModel, Agent, Compute, Tool, Dataset
ownerPubkeySolana wallet that owns this passport
metadata_uriStringURI to off-chain metadata (IPFS or API)
statusenumActive, Suspended, Revoked
created_ati64Registration timestamp

Register a Passport On-Chain

await program.methods
  .registerPassport({
    passportId: passportIdBytes,
    passportType: { model: {} },
    metadataUri: `https://api.lucid.foundation/v1/passports/${passportId}`,
  })
  .accounts({
    passport: passportPda,
    owner: wallet.publicKey,
    systemProgram: SystemProgram.programId,
  })
  .rpc();

gas-utils

The gas-utils program handles Cross-Program Invocations (CPI) for gas-efficient operations across both programs. It provides:
  • Batched epoch anchoring (multiple epochs in one transaction)
  • Passport + epoch combined operations
  • Fee calculation helpers

Program IDs

ProgramDevnetMainnet
lucid-receiptsLRec8vRdS4YmUzSgD6MjR2YMd8PJeLRJmp99jGuvkTTBD
lucid-registryLReg4TfpwCjgDHvQLXRs3aCBz4UpJ7LHPG3wNGRbKRTBD
gas-utilsLGas5DoPLo8fM7WA9jKm5cX3dNNQCVfp2RZnM1oHNUTBD

Dual Gas System

Lucid uses a dual-gas model on-chain:
  • iGas (inference gas) — consumed when anchoring inference receipts
  • mGas (memory gas) — consumed when storing agent memory on-chain
Both are denominated in SOL but tracked separately for metering and billing purposes.