build strategy · solana

Real Solana, three secrets, one build.

Every mega-prompt in this repo uses the same pattern, because it's the only pattern that lets a Lovable account ship a verifiable Solana Devnet demo in one shot — no anchor deploy, no wallet extension, no seed phrase.

Why Devnet and the SPL Memo program?

Devnet is a real Solana cluster with a free faucet. The SPL Memo program is pre-deployed on every cluster, so you can sign a real transaction that anyone can inspect on Solana Explorer — without writing or deploying a single line of Rust. For Metaplex NFT ideas, Umi + `mpl-token-metadata` runs the mint from the browser using the user's Privy embedded wallet. Skip to mainnet later by swapping the cluster.

The recipe

recipe
# 1. In your Lovable project, add secrets (Settings -> Secrets):
PRIVY_APP_ID=...
PINATA_JWT=eyJhbGciOi...              # only if the idea pins media
LOVABLE_API_KEY=...                   # AI calls via Lovable AI Gateway
SOLANA_RPC_URL=https://solana-devnet.g.alchemy.com/v2/<KEY>   # Alchemy Devnet
PHANTOM_PRIVATE_KEY=5J...             # base58 from Phantom, funded via faucet.solana.com

# 2. Copy a mega-prompt from this repo into Lovable. One paste:
#    - scaffolds the React + Vite app with a Buffer polyfill
#    - includes a tiny native Rust program under solana/program/
#    - wires scripts/deploy.ts to solana program deploy on Devnet using PHANTOM_PRIVATE_KEY
#    - wires Privy Google login + embedded Solana wallet for browser signing
#    - relies on Privy's Devnet gas sponsorship — no faucet needed for end users
#    - pins assets to IPFS via Pinata when needed
#    - links every tx to Solana Explorer with ?cluster=devnet

# 3. Run scripts/deploy.ts once locally to publish your program.
# 4. Sign in with Google. First action is signed against your deployed program. Provably onchain.

1. Sign in via Privy (embedded Solana wallet)

Google login provisions a Devnet address in the background. Enable Devnet gas sponsorship on the Privy dashboard so the user's first action is free — no faucet, no airdrop.

src/main.tsx
// src/main.tsx — Privy social login + embedded Solana wallet
import { PrivyProvider } from "@privy-io/react-auth";
import { toSolanaWalletConnectors } from "@privy-io/react-auth/solana";
import { Buffer } from "buffer";
(globalThis as any).Buffer = Buffer; // required for @solana/web3.js in the browser

<PrivyProvider
  appId={import.meta.env.VITE_PRIVY_APP_ID}
  config={{
    loginMethods: ["google", "email"],
    embeddedWallets: { solana: { createOnLogin: "users-without-wallets" } },
    externalWallets: { solana: { connectors: toSolanaWalletConnectors() } },
    solanaClusters: [{
      name: "devnet",
      rpcUrl: import.meta.env.VITE_SOLANA_RPC_URL || "https://api.devnet.solana.com",
    }],
  }}
>
  <App />
</PrivyProvider>

2. Sign a Solana memo — no program to deploy

src/lib/memo.ts
// src/lib/memo.ts — one tx per user action, no custom program to deploy
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";

const MEMO_PROGRAM_ID = new PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");

export function memoIx(payer: PublicKey, payload: string) {
  return new TransactionInstruction({
    keys: [{ pubkey: payer, isSigner: true, isWritable: true }],
    programId: MEMO_PROGRAM_ID,
    data: Buffer.from(payload, "utf8"),
  });
}

export function connection() {
  return new Connection(
    import.meta.env.VITE_SOLANA_RPC_URL || "https://api.devnet.solana.com",
    "confirmed",
  );
}

3. Pin assets to IPFS via Pinata

src/lib/pinata.ts
// src/lib/pinata.ts — pin a Blob to IPFS via Pinata JWT
export async function pinToIPFS(file: Blob, name = "artifact") {
  const fd = new FormData();
  fd.append("file", file, name);
  const r = await fetch("https://api.pinata.cloud/pinning/pinFileToIPFS", {
    method: "POST",
    headers: { Authorization: `Bearer ${import.meta.env.VITE_PINATA_JWT}` },
    body: fd,
  });
  const { IpfsHash } = await r.json();
  return IpfsHash as string; // the CID
}

4. AI calls — Lovable AI Gateway

One AI call per user action, routed through the Lovable AI Gateway with LOVABLE_API_KEY. OpenAI-compatible shape — swap the model any time.

src/lib/ai.ts
// src/lib/ai.ts — Lovable AI Gateway
const url = "https://ai.gateway.lovable.dev/v1/chat/completions";
const key = import.meta.env.VITE_LOVABLE_API_KEY;

export async function ask(prompt: string) {
  const r = await fetch(url, {
    method: "POST",
    headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
    body: JSON.stringify({
      model: "google/gemini-3-flash-preview",
      messages: [{ role: "user", content: prompt }],
    }),
  });
  return (await r.json()).choices[0].message.content as string;
}

Hackathon rules of thumb

  • · One mega-prompt = one build message. Don't iterate the architecture, iterate the UI.
  • · Always show the live Solana Explorer link (with ?cluster=devnet) in the UI — that's your proof.
  • · Use Privy embedded wallets + Devnet gas sponsorship so judges don't need Phantom (or a faucet) to try the demo.
  • · Pin every user-generated asset to IPFS the moment it's created; put the CID in the tx memo.
  • · Add a "Built during the Creative AI & Quantum Hackathon — StreetKode Fam · Indian Krump Festival 14" line to your footer.