{
  "id": "encryption-single",
  "name": "Encrypt Single Value",
  "category": "encryption",
  "difficulty": "beginner",
  "tags": ["encryption", "fromExternal", "externalEuint64", "createEncryptedInput", "input", "beginner", "sifreleme"],
  "description": "How to encrypt and send a single value to a FHEVM contract",
  "longDescription": "This fundamental example teaches the complete encryption flow in FHEVM. Learn how clients encrypt values using createEncryptedInput(), send them to contracts as external* types, and how contracts receive and store them using FHE.fromExternal(). This is the foundation for all FHE applications - every encrypted value starts with this flow.",
  "blocks": [
    {
      "id": "imports",
      "type": "import",
      "lines": [1, 5],
      "explanation": "Import both internal types (euint*, ebool) for storage and external types (externalEuint*, externalEbool) for receiving encrypted inputs from clients.",
      "searchTerms": ["import", "euint", "externalEuint", "ebool", "types"]
    },
    {
      "id": "store-uint8",
      "type": "function",
      "lines": [38, 53],
      "explanation": "Receive encrypted 8-bit value from client. Client uses add8() to encrypt, contract receives as externalEuint8, converts with FHE.fromExternal(), then sets ACL permissions.",
      "searchTerms": ["store", "uint8", "fromExternal", "8-bit", "small number"]
    },
    {
      "id": "store-uint64",
      "type": "function",
      "lines": [78, 95],
      "explanation": "Receive encrypted 64-bit value - the most common type for balances, amounts, and IDs. Client uses add64() with BigInt values (n suffix for large numbers).",
      "searchTerms": ["store", "uint64", "balance", "amount", "large number"]
    },
    {
      "id": "store-bool",
      "type": "function",
      "lines": [99, 115],
      "explanation": "Receive encrypted boolean. Client uses addBool() to encrypt true/false. Useful for private flags, votes, and conditions.",
      "searchTerms": ["store", "bool", "boolean", "flag", "true", "false"]
    },
    {
      "id": "plaintext-warning",
      "type": "function",
      "lines": [120, 140],
      "explanation": "WARNING: FHE.asEuint64() takes a plaintext value that IS VISIBLE on-chain! Only use for initialization with known public values. For private values, always use encrypted input from client.",
      "searchTerms": ["plaintext", "asEuint", "warning", "visible", "public"]
    }
  ],
  "files": [
    { "path": "contracts/EncryptSingle.sol", "source": "EncryptSingle.sol" },
    { "path": "test/EncryptSingle.test.ts", "source": "EncryptSingle.test.ts" }
  ],
  "fheOperations": ["fromExternal", "asEuint64", "allowThis", "allow"],
  "fheTypes": ["euint8", "euint16", "euint32", "euint64", "ebool", "externalEuint8", "externalEuint16", "externalEuint32", "externalEuint64", "externalEbool"],
  "relatedTemplates": ["encryption-multiple", "decryption-user-single"],
  "prerequisites": [],
  "nextSteps": ["encryption-multiple", "decryption-user-single", "input-proofs"]
}
