build strategy · onchain

Real onchain, five 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 Optimism Sepolia demo in one shot.

Why Optimism Sepolia?

Optimism Sepolia is Coinbase's free L2 testnet — full EVM, Optimism Etherscan explorer, standard wallets, but funded by a public faucet. Contracts are publicly inspectable, you never spend real ETH, and Privy sponsored transactions on Optimism cost fractions of a cent so judges can try the demo without a wallet. Optimism Etherscan is Etherscan-v2 under the hood, so a single ETHERSCAN_API_KEY verifies contracts on both.

The recipe

recipe
# 1. In your Lovable project, add five secrets (Settings -> Secrets):
METAMASK_PRIVATE_KEY=0x...
OPTIMISM_SEPOLIA_RPC_URL=https://sepolia.optimism.io  # or Alchemy Optimism Sepolia HTTPS URL
ETHERSCAN_API_KEY=...   # Etherscan v2 single key — covers Optimism Etherscan
PRIVY_APP_ID=...
PINATA_JWT=eyJhbGciOi...

# 2. Fund the MetaMask account on Optimism Sepolia:
open https://console.optimism.io/faucet
# or https://www.alchemy.com/faucets/optimism-sepolia

# 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 Optimism Sepolia and verifies on Optimism Etherscan
#    - wires Privy social login + sponsored tx
#    - pins generated assets to IPFS via Pinata
#    - exposes the contract address + Optimism Etherscan link in the UI

# 4. Open the live Optimism Etherscan link. Your demo is provably onchain.

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. Hardhat config for Optimism Sepolia + Etherscan v2

Install @nomicfoundation/hardhat-ethers and @nomicfoundation/hardhat-verify. Etherscan v2 uses a single API key across 60+ EVM chains including Optimism — no separate Optimism Etherscan key required.

hardhat.config.cjs
// hardhat.config.cjs — Optimism Sepolia (chainId 11155420) + Etherscan v2 verification
require("@nomicfoundation/hardhat-ethers");
require("@nomicfoundation/hardhat-verify");

const pk = process.env.METAMASK_PRIVATE_KEY;

module.exports = {
  solidity: { version: "0.8.24", settings: { optimizer: { enabled: true, runs: 200 } } },
  networks: {
    optimismSepolia: {
      url: process.env.OPTIMISM_SEPOLIA_RPC_URL || "https://sepolia.optimism.io",
      accounts: pk ? [pk.startsWith("0x") ? pk : "0x" + pk] : [],
      chainId: 11155420,
    },
  },
  etherscan: {
    // Single Etherscan v2 key — works for Optimism Etherscan too.
    apiKey: process.env.ETHERSCAN_API_KEY,
    customChains: [{
      network: "optimismSepolia",
      chainId: 11155420,
      urls: {
        apiURL: "https://api.etherscan.io/v2/api?chainid=11155420",
        browserURL: "https://sepolia-optimism.etherscan.io",
      },
    }],
  },
  sourcify: { enabled: false },
};

3. Deploy + verify on Optimism Etherscan

scripts/deploy.cjs
// scripts/deploy.cjs — deploys, then verifies on Optimism Etherscan
const hre = require("hardhat");
async function main() {
  const F = await hre.ethers.getContractFactory("Provenance");
  const c = await F.deploy();
  await c.waitForDeployment();
  const addr = await c.getAddress();
  console.log("deployed:", addr);
  // then, in a second command:
  // npx hardhat verify --network optimismSepolia <address>
}
main().catch((e) => { console.error(e); process.exit(1); });

4. 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 ${process.env.PINATA_JWT}` },
    body: fd,
  });
  const { IpfsHash } = await r.json();
  return IpfsHash as string; // the CID
}

5. Sign in with Google via Privy

Enable Optimism Sepolia (chainId 11155420) as a supported chain in your Privy dashboard before shipping.

src/main.tsx
// src/main.tsx — Privy social login + sponsored Optimism Sepolia transactions
import { PrivyProvider } from "@privy-io/react-auth";

<PrivyProvider
  appId={import.meta.env.VITE_PRIVY_APP_ID}
  config={{
    loginMethods: ["google", "email"],
    embeddedWallets: { ethereum: { createOnLogin: "users-without-wallets" } },
    defaultChain: { id: 11155420, name: "Optimism Sepolia" },
  }}
>
  <App />
</PrivyProvider>

Hackathon rules of thumb

  • · One mega-prompt = one build message. Don't iterate the architecture, iterate the UI.
  • · Always show the live Optimism Etherscan link in the UI — that's your proof.
  • · Use Privy sponsored tx so judges don't need a wallet to try the demo.
  • · Pin every user-generated asset to IPFS the moment it's created.
  • · Add a "Built during the Creative AI & Quantum Hackathon — StreetKode Fam · Indian Krump Festival 14" line to your footer.