[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7C73FSQ0W35ZNRN0BTB386C":3,"skill-same:01M7C73FSQ0W35ZNRN0BTB386C":47},{"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":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7C73FSQ0W35ZNRN0BTB386C","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.","austintgriffith\u002Fpicowallet","austintgriffith","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F2653167?v=4","01M7C72GPV281RWV90R8G7X2T5","Austin Griffith","01M7C72GQBJAE8DMGQTM0JZYY6",35,"MIT","https:\u002F\u002Fgithub.com\u002Faustintgriffith\u002Fpicowallet\u002Fblob\u002Fmain\u002Fapp\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},"main","91c94e72002a47486354c7cc646feca9be91c066","app\u002F.agents\u002Fskills\u002Fsiwe",6,"https:\u002F\u002Fgithub.com\u002Faustintgriffith\u002Fpicowallet","https:\u002F\u002Fgithub.com\u002Faustintgriffith","https:\u002F\u002Faustingriffith.com","👩‍🎤 builder on Ethereum","2026-10-03 09:11:37",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add austintgriffith\u002Fpicowallet --skill siwe",{"tool":39,"command":40},"bunx","bunx skills add austintgriffith\u002Fpicowallet --skill siwe",{"tool":42,"command":43},"pnpm","pnpm dlx skills add austintgriffith\u002Fpicowallet --skill siwe","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Faustintgriffith\u002Fpicowallet\u002Fblob\u002Fmain\u002Fapp\u002F.agents\u002Fskills\u002Fsiwe\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7C73VW6BP37G6952JZ420ZW","pico-emu","Write and test MicroPython for the Pico wallet (Pico 2 W + Waveshare Pico-LCD-1.3, 240x240 screen, joystick + A\u002FB\u002FX\u002FY) on the virtual wallet in emu\u002F, then put it on the real board. Use for \"build X for the Pico\", \"make a game\u002Fscreen\u002Fanimation for the wallet\", \"try this on the emulator\", or \"put it on the Pico\".","https:\u002F\u002Fgithub.com\u002Faustintgriffith\u002Fpicowallet\u002Fblob\u002Fmain\u002Femu\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7C73RDP5M6W7AXDQY7HRM9H","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\u002Faustintgriffith\u002Fpicowallet\u002Fblob\u002Fmain\u002Fapp\u002F.agents\u002Fskills\u002Fx402\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7C73MDMSG0M6B4BG5HBBGM8","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\u002Faustintgriffith\u002Fpicowallet\u002Fblob\u002Fmain\u002Fapp\u002F.agents\u002Fskills\u002Fsubgraph\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7C73A832KZMZ7CV52JAXHY7","ponder","Integrate Ponder into a Scaffold-ETH 2 project for blockchain event indexing. Use when the user wants to: index contract events, add a blockchain backend, set up GraphQL for onchain data, use Ponder with SE-2, or build an indexer for their dApp.","https:\u002F\u002Fgithub.com\u002Faustintgriffith\u002Fpicowallet\u002Fblob\u002Fmain\u002Fapp\u002F.agents\u002Fskills\u002Fponder\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7C735BZJBCF7WA2MG5DXJHR","openzeppelin","Develop smart contracts using OpenZeppelin Contracts library. Use when the user wants to create or modify Solidity contracts that use OpenZeppelin — including token standards (ERC20, ERC721, ERC1155), access control (Ownable, AccessControl), security primitives (Pausable, ReentrancyGuard), or any OZ extension. Covers library-first integration, pattern discovery from installed source, and version-safe development.","https:\u002F\u002Fgithub.com\u002Faustintgriffith\u002Fpicowallet\u002Fblob\u002Fmain\u002Fapp\u002F.agents\u002Fskills\u002Fopenzeppelin\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7C732DF3WRCRA8R2QJ1Q4D7","erc-721","Add an ERC-721 NFT contract to a Scaffold-ETH 2 project. Use when the user wants to: create an NFT collection, deploy an ERC-721, add NFT minting, build an NFT gallery or transfer UI, or work with non-fungible tokens in SE-2.","https:\u002F\u002Fgithub.com\u002Faustintgriffith\u002Fpicowallet\u002Fblob\u002Fmain\u002Fapp\u002F.agents\u002Fskills\u002Ferc-721\u002FSKILL.md",[],[]]