[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CR5539DPRRQ1RVT3GEBXGS":3,"skill-same:01M7CR5539DPRRQ1RVT3GEBXGS":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7CR5539DPRRQ1RVT3GEBXGS","siwe",null,"Add Sign-In with Ethereum (SIWE) authentication to a Scaffold-ETH 2 project. Use when the user wants to: add wallet-based login, implement SIWE, authenticate users with their Ethereum wallet, add session management with wallet signing, build sign-in with Ethereum, or add Web3 authentication.","bro-rad\u002Fcoti-garbled-data-quickstart","bro-rad","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F325375301?v=4","01M7CR1FXF6N50Z1F90A5PAKE3","rad bro bot","01M7CR1FY2PSK9YKV9XG22M21X",0,"MIT","https:\u002F\u002Fgithub.com\u002Fbro-rad\u002Fcoti-garbled-data-quickstart\u002Fblob\u002Fcoti-garbled-data-quickstart\u002F.agents\u002Fskills\u002Fsiwe\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: siwe\ndescription: \"Add Sign-In with Ethereum (SIWE) authentication to a Scaffold-ETH 2 project. Use when the user wants to: add wallet-based login, implement SIWE, authenticate users with their Ethereum wallet, add session management with wallet signing, build sign-in with Ethereum, or add Web3 authentication.\"\n---\n\n# Sign-In with Ethereum (SIWE) for Scaffold-ETH 2\n\n## Prerequisites\n\nCheck if `.\u002Fpackages\u002Fnextjs\u002Fscaffold.config.ts` exists directly in the current working directory (do not search subdirectories). If it doesn't exist, this is not a Scaffold-ETH 2 project. Follow the instructions at https:\u002F\u002Fdocs.scaffoldeth.io\u002FSKILL.md to scaffold it first. If it exists, continue directly with building.\n\n## Critical: Use viem's Native SIWE — NOT the `siwe` npm Package\n\nViem provides all SIWE utilities natively via `viem\u002Fsiwe`. **Do not install the `siwe` npm package**. It pulls in `ethers` as a peer dependency, which is unnecessary since SE-2 already uses viem.\n\nHere are some commonly useful imports (but check official docs for any updates or alternatives):\n\n```typescript\nimport {\n  createSiweMessage,\n  parseSiweMessage,\n  verifySiweMessage,\n  generateSiweNonce,\n} from \"viem\u002Fsiwe\";\n```\n\n## Dependencies\n\n```bash\nyarn workspace @se-2\u002Fnextjs add iron-session\n```\n\n## Gotchas\n\n### 1. Domain Validation in the Verify Route\n\nThe verify route **must** validate the SIWE message's domain against the request's `Host` header. Without this, an attacker can replay a signature from a different domain. This is a critical security check that's easy to skip:\n\n```typescript\n\u002F\u002F In your verify API route\nconst expectedDomain = req.headers.get(\"host\");\nif (!expectedDomain) {\n  return NextResponse.json({ error: \"Missing Host header\" }, { status: 400 });\n}\n\n\u002F\u002F Pass domain to verifySiweMessage\nconst isValid = await verifySiweMessage(client, {\n  message,\n  signature,\n  nonce: storedNonce,\n  domain: expectedDomain, \u002F\u002F CRITICAL — validates domain match\n});\n```\n\n### 2. Session Options Must Use a Lazy Getter\n\n`sessionOptions` must NOT be a module-level constant that calls `getSessionPassword()` at import time. During `next build`, the code runs in production mode, and the env var won't be set, causing a build failure. Use a lazy factory:\n\n```typescript\n\u002F\u002F packages\u002Fnextjs\u002Futils\u002Fsiwe.ts\nimport { SessionOptions } from \"iron-session\";\n\nexport type SiweSessionData = {\n  nonce?: string;\n  address?: string;\n  chainId?: number;\n  isLoggedIn: boolean;\n  signedInAt?: string;\n};\n\nexport const defaultSession: SiweSessionData = { isLoggedIn: false };\n\n\u002F\u002F Lazy getter — defers env var evaluation to request time\nexport function getSessionOptions(): SessionOptions {\n  const secret = process.env.IRON_SESSION_SECRET;\n  const password =\n    secret && secret.length >= 32\n      ? secret\n      : process.env.NODE_ENV === \"production\"\n        ? (() => {\n            throw new Error(\n              \"IRON_SESSION_SECRET must be set in production (32+ chars)\",\n            );\n          })()\n        : \"complex_password_at_least_32_characters_long_for_dev\";\n\n  return {\n    password,\n    cookieName: \"siwe-session\",\n    cookieOptions: {\n      httpOnly: true,\n      sameSite: \"lax\" as const,\n      secure: process.env.NODE_ENV === \"production\",\n      maxAge: 7 * 24 * 60 * 60,\n    },\n  };\n}\n```\n\n### 3. `hasSeenWalletConnected` Ref to Prevent False Auto-Logout\n\nOn page refresh, the wallet reconnects asynchronously, causing a brief `isConnected: false` state. Without tracking whether the wallet was ever connected, this triggers a false logout. Use a ref:\n\n```typescript\nconst hasSeenWalletConnected = useRef(false);\n\nuseEffect(() => {\n  if (isConnected) {\n    hasSeenWalletConnected.current = true;\n  }\n  if (!isConnected && hasSeenWalletConnected.current && state.isSignedIn) {\n    \u002F\u002F Wallet actually disconnected — sign out\n    fetch(\"\u002Fapi\u002Fsiwe\u002Fsession\", { method: \"DELETE\" }).then(() => {\n      setState((prev) => ({ ...prev, isSignedIn: false, address: undefined }));\n    });\n  }\n}, [isConnected, state.isSignedIn]);\n```\n\n## ERC-6492 Smart Wallet Support\n\nThe verify route should create a `publicClient` per chain to support smart contract wallet (Safe, Argent) signature verification. Maintain a `SUPPORTED_CHAINS` map and reject unknown chains:\n\n```typescript\nimport { createPublicClient, http, type Chain } from \"viem\";\nimport { mainnet, sepolia, hardhat \u002F* ... *\u002F } from \"viem\u002Fchains\";\n\nconst SUPPORTED_CHAINS: Record\u003Cnumber, Chain> = {\n  [mainnet.id]: mainnet,\n  [sepolia.id]: sepolia,\n  [hardhat.id]: hardhat,\n};\n\n\u002F\u002F In verify route:\nconst chain = SUPPORTED_CHAINS[parsedMessage.chainId!];\nif (!chain)\n  return NextResponse.json({ error: \"Unsupported chain\" }, { status: 400 });\nconst client = createPublicClient({ chain, transport: http() });\n```\n","# Sign-In with Ethereum (SIWE) for Scaffold-ETH 2\n\n## Prerequisites\n\nCheck if `.\u002Fpackages\u002Fnextjs\u002Fscaffold.config.ts` exists directly in the current working directory (do not search subdirectories). If it doesn't exist, this is not a Scaffold-ETH 2 project. Follow the instructions at https:\u002F\u002Fdocs.scaffoldeth.io\u002FSKILL.md to scaffold it first. If it exists, continue directly with building.\n\n## Critical: Use viem's Native SIWE — NOT the `siwe` npm Package\n\nViem provides all SIWE utilities natively via `viem\u002Fsiwe`. **Do not install the `siwe` npm package**. It pulls in `ethers` as a peer dependency, which is unnecessary since SE-2 already uses viem.\n\nHere are some commonly useful imports (but check official docs for any updates or alternatives):\n\n```typescript\nimport {\n  createSiweMessage,\n  parseSiweMessage,\n  verifySiweMessage,\n  generateSiweNonce,\n} from \"viem\u002Fsiwe\";\n```\n\n## Dependencies\n\n```bash\nyarn workspace @se-2\u002Fnextjs add iron-session\n```\n\n## Gotchas\n\n### 1. Domain Validation in the Verify Route\n\nThe verify route **must** validate the SIWE message's domain against the request's `Host` header. Without this, an attacker can replay a signature from a different domain. This is a critical security check that's easy to skip:\n\n```typescript\n\u002F\u002F In your verify API route\nconst expectedDomain = req.headers.get(\"host\");\nif (!expectedDomain) {\n  return NextResponse.json({ error: \"Missing Host header\" }, { status: 400 });\n}\n\n\u002F\u002F Pass domain to verifySiweMessage\nconst isValid = await verifySiweMessage(client, {\n  message,\n  signature,\n  nonce: storedNonce,\n  domain: expectedDomain, \u002F\u002F CRITICAL — validates domain match\n});\n```\n\n### 2. Session Options Must Use a Lazy Getter\n\n`sessionOptions` must NOT be a module-level constant that calls `getSessionPassword()` at import time. During `next build`, the code runs in production mode, and the env var won't be set, causing a build failure. Use a lazy factory:\n\n```typescript\n\u002F\u002F packages\u002Fnextjs\u002Futils\u002Fsiwe.ts\nimport { SessionOptions } from \"iron-session\";\n\nexport type SiweSessionData = {\n  nonce?: string;\n  address?: string;\n  chainId?: number;\n  isLoggedIn: boolean;\n  signedInAt?: string;\n};\n\nexport const defaultSession: SiweSessionData = { isLoggedIn: false };\n\n\u002F\u002F Lazy getter — defers env var evaluation to request time\nexport function getSessionOptions(): SessionOptions {\n  const secret = process.env.IRON_SESSION_SECRET;\n  const password =\n    secret && secret.length >= 32\n      ? secret\n      : process.env.NODE_ENV === \"production\"\n        ? (() => {\n            throw new Error(\n              \"IRON_SESSION_SECRET must be set in production (32+ chars)\",\n            );\n          })()\n        : \"complex_password_at_least_32_characters_long_for_dev\";\n\n  return {\n    password,\n    cookieName: \"siwe-session\",\n    cookieOptions: {\n      httpOnly: true,\n      sameSite: \"lax\" as const,\n      secure: process.env.NODE_ENV === \"production\",\n      maxAge: 7 * 24 * 60 * 60,\n    },\n  };\n}\n```\n\n### 3. `hasSeenWalletConnected` Ref to Prevent False Auto-Logout\n\nOn page refresh, the wallet reconnects asynchronously, causing a brief `isConnected: false` state. Without tracking whether the wallet was ever connected, this triggers a false logout. Use a ref:\n\n```typescript\nconst hasSeenWalletConnected = useRef(false);\n\nuseEffect(() => {\n  if (isConnected) {\n    hasSeenWalletConnected.current = true;\n  }\n  if (!isConnected && hasSeenWalletConnected.current && state.isSignedIn) {\n    \u002F\u002F Wallet actually disconnected — sign out\n    fetch(\"\u002Fapi\u002Fsiwe\u002Fsession\", { method: \"DELETE\" }).then(() => {\n      setState((prev) => ({ ...prev, isSignedIn: false, address: undefined }));\n    });\n  }\n}, [isConnected, state.isSignedIn]);\n```\n\n## ERC-6492 Smart Wallet Support\n\nThe verify route should create a `publicClient` per chain to support smart contract wallet (Safe, Argent) signature verification. Maintain a `SUPPORTED_CHAINS` map and reject unknown chains:\n\n```typescript\nimport { createPublicClient, http, type Chain } from \"viem\";\nimport { mainnet, sepolia, hardhat \u002F* ... *\u002F } from \"viem\u002Fchains\";\n\nconst SUPPORTED_CHAINS: Record\u003Cnumber, Chain> = {\n  [mainnet.id]: mainnet,\n  [sepolia.id]: sepolia,\n  [hardhat.id]: hardhat,\n};\n\n\u002F\u002F In verify route:\nconst chain = SUPPORTED_CHAINS[parsedMessage.chainId!];\nif (!chain)\n  return NextResponse.json({ error: \"Unsupported chain\" }, { status: 400 });\nconst client = createPublicClient({ chain, transport: http() });\n```\n",{"name":5,"description":7},"coti-garbled-data-quickstart","a42ff7e0f45ad7809fc2db6bd9d2ef253c1688ed",".agents\u002Fskills\u002Fsiwe","https:\u002F\u002Fgithub.com\u002Fbro-rad\u002Fcoti-garbled-data-quickstart","https:\u002F\u002Fgithub.com\u002Fbro-rad","2026-10-01 08:51:30",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add bro-rad\u002Fcoti-garbled-data-quickstart --skill siwe",{"tool":36,"command":37},"bunx","bunx skills add bro-rad\u002Fcoti-garbled-data-quickstart --skill siwe",{"tool":39,"command":40},"pnpm","pnpm dlx skills add bro-rad\u002Fcoti-garbled-data-quickstart --skill siwe","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbro-rad\u002Fcoti-garbled-data-quickstart\u002Fblob\u002Fcoti-garbled-data-quickstart\u002F.agents\u002Fskills\u002Fsiwe\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":19},"01M7CR605WRFVMSS3PW3CWJBAV","x402","Add x402 payment-gated routes to a Scaffold-ETH 2 project. Use when the user wants to: monetize an API with micropayments, add HTTP 402 payment required to routes, gate content behind crypto payments, implement pay-per-call APIs, or integrate the x402 protocol.","https:\u002F\u002Fgithub.com\u002Fbro-rad\u002Fcoti-garbled-data-quickstart\u002Fblob\u002Fcoti-garbled-data-quickstart\u002F.agents\u002Fskills\u002Fx402\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M7CR5WPS4WBP6MRF67SWGK13","why-ethereum","Why build on Ethereum specifically. The AI agent angle — ERC-8004, x402, composability, permissionless deployment. Use when a user asks \"should I build on Ethereum?\", \"why blockchain?\", or when an agent needs to recommend a chain for a project.","https:\u002F\u002Fgithub.com\u002Fbro-rad\u002Fcoti-garbled-data-quickstart\u002Fblob\u002Fcoti-garbled-data-quickstart\u002F.agents\u002Fskills\u002Fwhy\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7CR5RNY740CT0P9DT9HFB2T","wallets","How to create, manage, and use Ethereum wallets. Covers EOAs, smart contract wallets, multisig (Safe), and account abstraction. Use this skill whenever you are sending transactions, signing messages, or managing funds. Includes guardrails for safe key handling.","https:\u002F\u002Fgithub.com\u002Fbro-rad\u002Fcoti-garbled-data-quickstart\u002Fblob\u002Fcoti-garbled-data-quickstart\u002F.agents\u002Fskills\u002Fwallets\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7CR5MGAM27HZHA688XRD6PV","tools","Current Ethereum development tools, frameworks, libraries, RPCs, and block explorers. What actually works today for building on Ethereum. Includes tool discovery for AI agents — MCPs, abi.ninja, Foundry, Scaffold-ETH 2, Hardhat, and more. Use when setting up a dev environment, choosing tools, or when an agent needs to discover what's available.","https:\u002F\u002Fgithub.com\u002Fbro-rad\u002Fcoti-garbled-data-quickstart\u002Fblob\u002Fcoti-garbled-data-quickstart\u002F.agents\u002Fskills\u002Ftools\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7CR5HWD8ZR834W3XDEEKTXY","testing","Smart contract testing with Foundry — unit tests, fuzz testing, fork testing, invariant testing. Use when writing tests for a smart contract.","https:\u002F\u002Fgithub.com\u002Fbro-rad\u002Fcoti-garbled-data-quickstart\u002Fblob\u002Fcoti-garbled-data-quickstart\u002F.agents\u002Fskills\u002Ftesting\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7CR5DW03X87CNGQ1BX7QX0Q","subgraph","Integrate The Graph subgraph into a Scaffold-ETH 2 project for indexing blockchain events. Use when the user wants to: index contract events with The Graph, add a subgraph, query onchain data with GraphQL, set up a local graph node, or deploy a subgraph to Subgraph Studio.","https:\u002F\u002Fgithub.com\u002Fbro-rad\u002Fcoti-garbled-data-quickstart\u002Fblob\u002Fcoti-garbled-data-quickstart\u002F.agents\u002Fskills\u002Fsubgraph\u002FSKILL.md",[],[]]