build strategy · onchain

Real onchain, 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 0G Galileo demo in one shot.

Why 0G Galileo and not Ethereum mainnet?

0G Galileo is a real EVM L1 testnet with the same wallets, same Solidity, same tooling — plus native decentralized storage (root-hash CIDs) and AI inference baked into the chain. Every contract you deploy is publicly inspectable on Chainscan-Galileo, but you never spend real OG and your demo can't accidentally drain a user. Promote to the Aristotle mainnet after the hackathon by swapping the RPC and chainId.

The recipe

recipe
# 1. In your Lovable project, add TWO secrets (Settings -> Secrets):
METAMASK_PRIVATE_KEY=0x...     # 0G Galileo deployer key
PRIVY_APP_ID=...               # Privy app (Google sign-in + embedded wallet; user signs their own tx)

# AI calls (if your idea uses AI) go through Lovable AI Gateway via the
# auto-provisioned LOVABLE_API_KEY — nothing to paste. Default model:
# google/gemini-3-flash-preview. Call it from a server route only.

# 0G's public RPC is hardcoded — no SEPOLIA_RPC_URL, no ETHERSCAN_API_KEY,
# no PINATA_JWT, no AISA_API_KEY. Storage uploads are signed by METAMASK_PRIVATE_KEY.

# 2. Fund the MetaMask account on 0G Galileo:
open https://faucet.0g.ai        # 0.1 OG / day
# alt: https://hub.0g.ai/faucet?network=testnet

# 3. Copy a mega-prompt from this repo into Lovable. One paste:
#    - scaffolds the React app
#    - writes the Solidity contract (with hackathon credit in NatSpec)
#    - deploys to 0G Galileo (chainId 16602)
#    - wires Privy social login + embedded wallet (user signs every tx, pays gas in OG)
#    - pins generated assets to 0G Storage via @0glabs/0g-ts-sdk
#    - exposes the contract address + Chainscan-Galileo link in the UI

# 4. Verify on Chainscan-Galileo (web UI):
#    https://chainscan-galileo.0g.ai/address/<addr> -> Contract -> Verify and Publish.

1. The contract — credit baked in

Every Solidity file deployed from a Creative Blockchain prompt MUST carry the hackathon credit in NatSpec, so provenance lives onchain alongside the bytecode.

contracts/Provenance.sol
// contracts/Provenance.sol — every contract carries the hackathon credit in NatSpec
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @title Provenance
/// @notice Built during the Creative AI & Quantum Hackathon
/// @notice organised by StreetKode Fam during Indian Krump Festival 14
contract Provenance {
    event Logged(address indexed author, string cid, uint256 at);

    function log(string calldata cid) external {
        emit Logged(msg.sender, cid, block.timestamp);
    }
}

2. Deploy + verify on 0G Chainscan

scripts/deploy.ts
// scripts/deploy.ts — reads METAMASK_PRIVATE_KEY from process.env
// 0G uses Chainscan's web UI for verification — no Etherscan plugin needed.
import { ethers } from "hardhat";

async function main() {
  const F = await ethers.getContractFactory("Provenance");
  const c = await F.deploy();
  await c.waitForDeployment();
  const addr = await c.getAddress();
  console.log("deployed:", addr);
  // Then: open https://chainscan-galileo.0g.ai/address/<addr>
  // -> Contract -> Verify and Publish (solc 0.8.24, optimizer on, runs 200).
}
main();

3. Pin assets to 0G Storage

src/lib/zerog-storage.ts
// src/lib/zerog-storage.ts — pin a Blob to 0G Storage, get a root-hash CID
import { Indexer, ZgFile } from "@0glabs/0g-ts-sdk";
import { ethers } from "ethers";

const RPC = "https://evmrpc-testnet.0g.ai";
const INDEXER = "https://indexer-storage-testnet-turbo.0g.ai";

export async function uploadToZeroG(file: File): Promise<string> {
  const signer = new ethers.Wallet(
    import.meta.env.VITE_METAMASK_PRIVATE_KEY,
    new ethers.JsonRpcProvider(RPC),
  );
  const zg = await ZgFile.fromBlob(file);
  const [tree] = await zg.merkleTree();
  const rootHash = tree!.rootHash()!;
  const indexer = new Indexer(INDEXER);
  const [, err] = await indexer.upload(zg, RPC, signer);
  if (err) throw err;
  await zg.close();
  return rootHash; // the CID written onchain
}

4. Sign in with Google via Privy

src/main.tsx
// src/main.tsx — Privy social login + embedded wallet on 0G Galileo (user signs their own tx)
import { PrivyProvider } from "@privy-io/react-auth";

const GALILEO = {
  id: 16602,
  name: "0G Galileo Testnet",
  nativeCurrency: { name: "0G", symbol: "OG", decimals: 18 },
  rpcUrls: { default: { http: ["https://evmrpc-testnet.0g.ai"] } },
  blockExplorers: { default: { name: "Chainscan", url: "https://chainscan-galileo.0g.ai" } },
};

<PrivyProvider
  appId={import.meta.env.VITE_PRIVY_APP_ID}
  config={{
    loginMethods: ["google", "email"],
    embeddedWallets: { createOnLogin: "users-without-wallets" },
    defaultChain: GALILEO,
    supportedChains: [GALILEO],
  }}
>
  <App />
</PrivyProvider>

Hackathon rules of thumb

  • · One mega-prompt = one build message. Don't iterate the architecture, iterate the UI.
  • · Always show the live Chainscan-Galileo link in the UI — that's your proof.
  • · Use Privy embedded wallets so judges sign in with Google — but tell them to grab 0.1 OG from faucet.0g.ai before they try the demo (Privy doesn't sponsor gas on 0G).
  • · Pin every user-generated asset to 0G Storage the moment it's created.
  • · Add a "Built during the Creative AI & Quantum Hackathon — StreetKode Fam · Indian Krump Festival 14" line to your footer.