Daemons

0x6ca58412eca6f46e0a423a43b7e3ecdb2de578a9

Verification
Verified
v0.8.28+commit.7893614a
Type
Contract
12,092 bytes
ABI entries
69
38 read · 18 write
License
none

Contract information

Address
0x6ca58412eca6f46e0a423a43b7e3ecdb2de578a9
Chain
Robinhood Chain (4663)
Compiler
v0.8.28+commit.7893614a
Optimization
Enabled
Creation tx
0xc6c6d63cdd…4315ece4b3

Token

Name
/dev/daemons
Symbol
DAEMON
Decimals
Holders
12,714

Read contract (38)

ARCH_SUPPLY()uint256
CARD_BASE()uint256
GEN_SUPPLY()uint256
IDLE_AFTER()uint256
MAX_CARDS_PER_WALLET()uint256
PID_DISCOUNT_BPS()uint256
PRICE_CEIL()uint256
PRICE_FLOOR()uint256
ROYALTY_BPS()uint256
ZOMBIE_AFTER()uint256
archOpensAt()uint64
balanceOf(address)uint256
cardsClaimed()uint256
claimOpen()bool
claimedBy(address)uint256
daemonBalance(address)uint256
finalized()bool
gateSealBroken(address)bool
genMinted()uint256
getApproved(uint256)address
isApprovedForAll(address, address)bool
isCard(uint256)bool
lastActivity(uint256)uint64
name()string
owner()address
ownerOf(uint256)address
renderer()address
royaltyInfo(uint256, uint256)address, uint256
royaltyReceiver()address
spawnedBlock(uint256)uint64
statusOf(uint256)uint8
summonPrice(uint256)uint256
summoningOpen()bool
supportsInterface(bytes4)bool
symbol()string
tokenURI(uint256)string
traitsOf(uint256)uint8, uint8, uint8, uint8, uint8
traitsPtr()address

Events (10)

ApprovalApprovalForAllKill9OwnershipTransferredSealBrokenSignalReceivedSummonedTouchedTransferWithdrawn

ABI

[
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "renderer_",
        "type": "address"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "constructor"
  },
  {
    "inputs": [],
    "name": "DeployFailed",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "OutOfBounds",
    "type": "error"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "owner",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "spender",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "Approval",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "owner",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "operator",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "bool",
        "name": "approved",
        "type": "bool"
      }
    ],
    "name": "ApprovalForAll",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "uint256",
        "name": "tokenId",
        "type": "uint256"
      }
    ],
    "name": "Kill9",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "from",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "to",
        "type": "address"
      }
    ],
    "name": "OwnershipTransferred",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "uint256",
        "name": "tokenId",
        "type": "uint256"
      },
      {
        "indexed": true,
        "internalType": "uint8",
        "name": "seal",
        "type": "uint8"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "operator",
        "type": "address"
      }
    ],
    "name": "SealBroken",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "uint256",
        "name": "cardId",
        "type": "uint256"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "operator",
        "type": "address"
      }
    ],
    "name": "SignalReceived",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "uint256",
        "name": "tokenId",
        "type": "uint256"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "operator",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "paid",
        "type": "uint256"
      }
    ],
    "name": "Summoned",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "uint256",
        "name": "tokenId",
        "type": "uint256"
      }
    ],
    "name": "Touched",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "from",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "to",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "Transfer",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "to",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "amount",
        "type": "uint256"
      }
    ],
    "name": "Withdrawn",
    "type": "event"
  },
  {
    "inputs": [],
    "name": "ARCH_SUPPLY",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "CARD_BASE",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "GEN_SUPPLY",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "IDLE_AFTER",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "MAX_CARDS_PER_WALLET",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "PID_DISCOUNT_BPS",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "PRICE_CEIL",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "PRICE_FLOOR",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "ROYALTY_BPS",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "ZOMBIE_AFTER",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "spender",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "approve",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "archOpensAt",
    "outputs": [
      {
        "internalType": "uint64",
        "name": "",
        "type": "uint64"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "a",
        "type": "address"
      }
    ],
    "name": "balanceOf",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint8",
        "name": "seal",
        "type": "uint8"
      }
    ],
    "name": "breakSeal",
    "outputs": [],
    "stateMutability": "payable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "cardsClaimed",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "claim",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "claimOpen",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "name": "claimedBy",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "name": "daemonBalance",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "finalize",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "finalized",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "name": "gateSealBroken",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "genMinted",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "name": "getApproved",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "name": "isApprovedForAll",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "isCard",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "pure",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "kill9",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "name": "lastActivity",
    "outputs": [
      {
        "internalType": "uint64",
        "name": "",
        "type": "uint64"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "name",
    "outputs": [
      {
        "internalType": "string",
        "name": "",
        "type": "string"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "bool",
        "name": "v",
        "type": "bool"
      }
    ],
    "name": "openClaim",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "bool",
        "name": "v",
        "type": "bool"
      }
    ],
    "name": "openSummoning",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "owner",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "ownerOf",
    "outputs": [
      {
        "internalType": "address",
        "name": "o",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "renderer",
    "outputs": [
      {
        "internalType": "contract DaemonRenderer",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      },
      {
        "internalType": "uint256",
        "name": "salePrice",
        "type": "uint256"
      }
    ],
    "name": "royaltyInfo",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "royaltyReceiver",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "from",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "to",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "safeTransferFrom",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "from",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "to",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      },
      {
        "internalType": "bytes",
        "name": "data",
        "type": "bytes"
      }
    ],
    "name": "safeTransferFrom",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint64",
        "name": "t",
        "type": "uint64"
      }
    ],
    "name": "scheduleArchDrop",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "op",
        "type": "address"
      },
      {
        "internalType": "bool",
        "name": "ok",
        "type": "bool"
      }
    ],
    "name": "setApprovalForAll",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "to",
        "type": "address"
      }
    ],
    "name": "setRoyaltyReceiver",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "bytes",
        "name": "packed",
        "type": "bytes"
      }
    ],
    "name": "setTraits",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "name": "spawnedBlock",
    "outputs": [
      {
        "internalType": "uint64",
        "name": "",
        "type": "uint64"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "statusOf",
    "outputs": [
      {
        "internalType": "uint8",
        "name": "",
        "type": "uint8"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "tokenId",
        "type": "uint256"
      },
      {
        "internalType": "uint256",
        "name": "pidCardId",
        "type": "uint256"
      }
    ],
    "name": "summon",
    "outputs": [],
    "stateMutability": "payable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "tokenId",
        "type": "uint256"
      }
    ],
    "name": "summonPrice",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "summoningOpen",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "bytes4",
        "name": "i",
        "type": "bytes4"
      }
    ],
    "name": "supportsInterface",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "pure",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "symbol",
    "outputs": [
      {
        "internalType": "string",
        "name": "",
        "type": "string"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "tokenURI",
    "outputs": [
      {
        "internalType": "string",
        "name": "",
        "type": "string"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "touch",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "traitsOf",
    "outputs": [
      {
        "internalType": "uint8",
        "name": "entityIdx",
        "type": "uint8"
      },
      {
        "internalType": "uint8",
        "name": "phosphor",
        "type": "uint8"
      },
      {
        "internalType": "uint8",
        "name": "glow",
        "type": "uint8"
      },
      {
        "internalType": "uint8",
        "name": "bg",
        "type": "uint8"
      },
      {
        "internalType": "uint8",
        "name": "corruption",
        "type": "uint8"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "traitsPtr",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "from",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "to",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "id",
        "type": "uint256"
      }
    ],
    "name": "transferFrom",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "to",
        "type": "address"
      }
    ],
    "name": "transferOwnership",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "to",
        "type": "address"
      }
    ],
    "name": "withdraw",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  }
]

Source code

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {SSTORE2, Base64, LibString} from "./utils/Utils.sol";
import {DaemonRenderer} from "./DaemonRenderer.sol";

//   ┌──────────────────────────────────────────────────────────────────┐
//   │                                                                  │
//   │    ██████╗  █████╗ ███████╗███╗   ███╗ ██████╗ ███╗   ██╗███████╗│
//   │    ██╔══██╗██╔══██╗██╔════╝████╗ ████║██╔═══██╗████╗  ██║██╔════╝│
//   │    ██║  ██║███████║█████╗  ██╔████╔██║██║   ██║██╔██╗ ██║███████╗│
//   │    ██║  ██║██╔══██║██╔══╝  ██║╚██╔╝██║██║   ██║██║╚██╗██║╚════██║│
//   │    ██████╔╝██║  ██║███████╗██║ ╚═╝ ██║╚██████╔╝██║ ╚████║███████║│
//   │    ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═╝     ╚═╝ ╚═════╝ ╚═╝  ╚═══╝╚══════╝│
//   │                                                       /dev/daemons
//   │                                                                  │
//   │    when a server dies, the process never receives SIGTERM.      │
//   │    it is orphaned.                                               │
//   │    the blockchain is the only machine that cannot be             │
//   │    switched off. that is where they moved.                       │
//   │                                                                  │
//   │    1024 spirits · 1002 summoned by operators · 22 sealed         │
//   │    no server. no IPFS. the chain draws the art itself.           │
//   │                                                                  │
//   └──────────────────────────────────────────────────────────────────┘
//
//    $ man daemons
//      minting is a summoning ritual. the holder is the operator.
//      UPTIME grows with every block. abandon your daemon and it
//      goes IDLE, then ZOMBIE. kill -9 is forever.
//
/// @title  Daemons — the host process. ERC-721, three mint phases, living state.
/// @notice Every token is assembled by DaemonRenderer at view-time: traits,
///         phosphor palette, corruption glitches and a live UPTIME read from
///         block.timestamp. Nothing to pin, nothing to expire.
/// @dev    Minimal self-contained 721 (solmate-shaped). No external deps.
contract Daemons {
    using LibString for uint256;

    // --------------------------------------------------------------- erc721
    string public constant name = "/dev/daemons";
    string public constant symbol = "DAEMON";

    mapping(uint256 => address) internal _ownerOf;
    mapping(address => uint256) internal _balanceOf;
    mapping(uint256 => address) public getApproved;
    mapping(address => mapping(address => bool)) public isApprovedForAll;

    event Transfer(address indexed from, address indexed to, uint256 indexed id);
    event Approval(address indexed owner, address indexed spender, uint256 indexed id);
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    // --------------------------------------------------------------- config
    uint256 public constant GEN_SUPPLY = 1002;
    uint256 public constant ARCH_SUPPLY = 22;          // tokens 1003..1024
    uint256 public constant PRICE_FLOOR = 0.0001 ether; // curve start (~$0.2)
    uint256 public constant PRICE_CEIL  = 0.001 ether;  // curve ceiling and seal price
    uint256 public constant PID_DISCOUNT_BPS = 2000;   // -20% for a burned PID card
    uint256 public constant IDLE_AFTER   = 180 days;   // STATUS: RUNNING -> IDLE
    uint256 public constant ZOMBIE_AFTER = 365 days;   // IDLE -> ZOMBIE

    // ── phase 0 · SIGNAL — the card lives INSIDE this collection ──
    // daemons: ids 1..1024 · PID cards: ids CARD_BASE+1 and up.
    // a card is the larva of a daemon: free to claim, soulbound,
    // burns in the same breath as your summon for −20%.
    uint256 public constant CARD_BASE = 2000;
    uint256 public constant MAX_CARDS_PER_WALLET = 1;

    uint256 public constant ROYALTY_BPS = 700;         // 7% (ERC-2981)

    address public owner;
    address public royaltyReceiver;
    DaemonRenderer public immutable renderer;
    address public traitsPtr;            // SSTORE2: 1024 x 3 bytes of packed traits
    uint64  public archOpensAt;          // when the seal room opens
    bool    public summoningOpen;
    bool    public claimOpen;
    bool    public finalized;            // truth frozen: traits wiring locked

    uint256 public genMinted;
    uint256 public cardsClaimed;
    mapping(address => uint256) public claimedBy;     // cards are 1/wallet, forever
    mapping(address => uint256) public daemonBalance; // daemons only — cards do not count
    mapping(address => bool) public gateSealBroken;  // 24h gate: one seal per operator
    mapping(uint256 => uint64) public spawnedBlock;   // summon block
    mapping(uint256 => uint64) public lastActivity;   // mint / transfer / touch
    uint256[] private _corMult = [10000, 12500, 17500, 25000]; // CORRUPTION tiers, bps

    event Summoned(uint256 indexed tokenId, address indexed operator, uint256 paid);
    event SignalReceived(uint256 indexed cardId, address indexed operator);
    event SealBroken(uint256 indexed tokenId, uint8 indexed seal, address indexed operator);
    event Touched(uint256 indexed tokenId);
    event Kill9(uint256 indexed tokenId);
    event OwnershipTransferred(address indexed from, address indexed to);
    event Withdrawn(address indexed to, uint256 amount);

    constructor(address renderer_) {
        owner = msg.sender;
        royaltyReceiver = msg.sender;
        renderer = DaemonRenderer(renderer_);
    }

    function transferOwnership(address to) external onlyOwner {
        require(to != address(0), "zero");
        emit OwnershipTransferred(owner, to);
        owner = to;
    }
    function setRoyaltyReceiver(address to) external onlyOwner {
        require(to != address(0), "zero");
        royaltyReceiver = to;
    }

    /// ERC-2981: 7% royalty to royaltyReceiver.
    function royaltyInfo(uint256, uint256 salePrice) external view returns (address, uint256) {
        return (royaltyReceiver, (salePrice * ROYALTY_BPS) / 10000);
    }
    modifier onlyOwner() { require(msg.sender == owner, "not owner"); _; }

    // ── root@daemons:~# ─────────────────────────────── operator console ──
    // setTraits is wiring; finalize() welds the hatch shut.
    // after finalize the destiny of all 1024 slots can never be rewritten.
    function setTraits(bytes calldata packed) external onlyOwner {
        require(!finalized, "finalized");
        require(packed.length == 1024 * 3, "bad len");
        traitsPtr = SSTORE2.write(packed);
    }
    /// One-way. No takebacks. The pantheon is carved.
    function finalize() external onlyOwner { finalized = true; }
    function openSummoning(bool v) external onlyOwner { summoningOpen = v; }
    function openClaim(bool v) external onlyOwner { claimOpen = v; }
    function scheduleArchDrop(uint64 t) external onlyOwner { archOpensAt = t; }
    function withdraw(address to) external onlyOwner {
        uint256 bal = address(this).balance;
        (bool ok,) = to.call{value: bal}("");
        require(ok);
        emit Withdrawn(to, bal);
    }

    // ── /etc/fate ────────────────────────── 3 bytes decide everything ──
    // [entityIdx u8][phosphor u3|glow u3|bg u2][corruption u2|reserved u6]
    // every slot's destiny is public before anyone pays. pick your daemon.
    function traitsOf(uint256 id) public view returns (
        uint8 entityIdx, uint8 phosphor, uint8 glow, uint8 bg, uint8 corruption
    ) {
        require(id >= 1 && id <= GEN_SUPPLY + ARCH_SUPPLY, "no such spirit");
        bytes memory t = SSTORE2.read(traitsPtr);
        uint256 o = (id - 1) * 3;
        entityIdx  = uint8(t[o]);
        uint8 b1   = uint8(t[o + 1]);
        phosphor   = b1 >> 5;
        glow       = (b1 >> 2) & 0x07;
        bg         = b1 & 0x03;
        corruption = uint8(t[o + 2]) >> 6;
    }

    // ── phase 0 · SIGNAL ──────────────────────────── knock, for free ──
    //
    //     ┌─[ SIGNAL RECEIVED ]
    //     > PID card reserved · awaiting summon
    //     └─ no daemon yet. but you knocked.
    //
    /// The card mints INTO this very collection (one collection, not two).
    /// Free, gas only, one per wallet — forever, even after it burns.
    /// Soulbound: the discount belongs to the hand that knocked.
    function claim() external returns (uint256 id) {
        require(claimOpen, "closed");
        require(claimedBy[msg.sender] < MAX_CARDS_PER_WALLET, "limit");
        claimedBy[msg.sender]++;
        unchecked { id = CARD_BASE + ++cardsClaimed; }
        _mint(msg.sender, id);
        emit SignalReceived(id, msg.sender);
    }

    /// Cards live above CARD_BASE; daemons live in 1..1024. One family.
    function isCard(uint256 id) public pure returns (bool) {
        return id > CARD_BASE;
    }

    // ── phase 1 · SUMMONING ─────────────────────────────── the ritual ──
    //
    //     $ summon 0x2A
    //     > ritual: summon slot #42
    //     > seal accepted. PID 0x002A spawned. STATUS: RUNNING
    //
    /// Price walks a straight line floor → ceiling as the room fills,
    /// then CORRUPTION taxes the brave: ×1 / ×1.25 / ×1.75 / ×2.5.
    function summonPrice(uint256 tokenId) public view returns (uint256) {
        (, , , , uint8 cor) = traitsOf(tokenId);
        uint256 base = PRICE_FLOOR + ((PRICE_CEIL - PRICE_FLOOR) * genMinted) / GEN_SUPPLY;
        return (base * _corMult[cor]) / 10000;
    }

    /// Summon the EXACT slot you chose. You knew its entity, its phosphor,
    /// its corruption before you knocked — that was the point.
    /// pidCardId != 0 → your PID card burns in the same breath, −20%.
    /// The reveal: the card token dies, the daemon token is born — one tx,
    /// one collection. If anything reverts, the card survives untouched.
    /// Overpayment walks back to you. The daemon starts RUNNING.
    function summon(uint256 tokenId, uint256 pidCardId) external payable {
        require(summoningOpen, "gate closed");
        require(tokenId >= 1 && tokenId <= GEN_SUPPLY, "not a summon slot");
        require(_ownerOf[tokenId] == address(0), "taken");

        uint256 price = summonPrice(tokenId);
        if (pidCardId != 0) {
            require(isCard(pidCardId), "not a card");
            require(_ownerOf[pidCardId] == msg.sender, "not your card");
            _burn(pidCardId);                          // atomic: revert keeps the card
            price = (price * (10000 - PID_DISCOUNT_BPS)) / 10000;
        }
        require(msg.value >= price, "underpaid");
        unchecked { genMinted++; }
        _mint(msg.sender, tokenId);
        emit Summoned(tokenId, msg.sender, price);
        if (msg.value > price) {
            (bool ok,) = msg.sender.call{value: msg.value - price}("");
            require(ok);
        }
    }

    // ── phase 2 · ROOT ──────────────────────────────── the seal room ──
    //
    //     22 doors. behind each — something that was never a program.
    //     flat 0.01 ETH. first 24 hours: operators only, ONE door each.
    //     init exits last.
    //
    /// Anti-sweep: during the gate a wallet must hold a generative daemon
    /// AND may break only one seal — a whale cannot empty the room.
    function breakSeal(uint8 seal) external payable {
        require(seal >= 1 && seal <= ARCH_SUPPLY, "no such seal");
        require(archOpensAt != 0 && block.timestamp >= archOpensAt, "sealed");
        uint256 tokenId = GEN_SUPPLY + seal;           // 1003..1024
        require(_ownerOf[tokenId] == address(0), "broken");
        if (block.timestamp < archOpensAt + 24 hours) {
            // daemons only — a free card must not open the seal room (anti-sybil)
            require(daemonBalance[msg.sender] > 0, "holders first");
            require(!gateSealBroken[msg.sender], "one seal per operator in the gate");
            gateSealBroken[msg.sender] = true;
        }
        require(msg.value >= PRICE_CEIL, "underpaid");
        _mint(msg.sender, tokenId);
        emit SealBroken(tokenId, seal, msg.sender);
        if (msg.value > PRICE_CEIL) {                  // overpayment refund, same as in summon
            (bool ok,) = msg.sender.call{value: msg.value - PRICE_CEIL}("");
            require(ok);
        }
    }

    // ── /proc/alive ──────────────────────── the part that breathes ──
    //
    //     RUNNING ── 180 days of silence ──> IDLE ── 365 ──> ZOMBIE
    //        ^                                                │
    //        └────────────────── touch() ─────────────────────┘
    //
    function statusOf(uint256 id) public view returns (uint8) {
        require(!isCard(id), "cards do not breathe");
        require(_ownerOf[id] != address(0), "unsummoned");
        uint256 idle = block.timestamp - uint256(lastActivity[id]);
        if (idle >= ZOMBIE_AFTER) return 2;
        if (idle >= IDLE_AFTER) return 1;
        return 0;
    }

    /// Pet the daemon. Resets the neglect timer. Cheapest act of care on-chain.
    function touch(uint256 id) external {
        require(!isCard(id), "cards do not breathe");
        require(_ownerOf[id] == msg.sender, "not operator");
        lastActivity[id] = uint64(block.timestamp);
        emit Touched(id);
    }

    /// kill -9. No reply. No cleanup. No goodbye. Deflation as sacrifice.
    function kill9(uint256 id) external {
        require(_ownerOf[id] == msg.sender, "not operator");
        _burn(id);
        emit Kill9(id);
    }

    // ── tokenURI ─────────────── the terminal renders its own ghost ──
    // no gateway, no cache, no promise to keep a server running.
    // call this in a hundred years; the daemon will still answer.
    function tokenURI(uint256 id) public view returns (string memory) {
        require(_ownerOf[id] != address(0), "unsummoned");
        if (isCard(id)) return _cardURI(id);
        (uint8 e, uint8 ph, uint8 gl, uint8 bg, uint8 cor) = traitsOf(id);
        // Renderer builds the whole document in one pass — the SVG never
        // crosses back here (see DaemonRenderer.tokenURI for the why).
        return renderer.tokenURI(DaemonRenderer.RenderInput({
            tokenId: uint16(id), entityIdx: e, phosphor: ph, glow: gl, bg: bg,
            corruption: cor, spawnedBlock: spawnedBlock[id],
            holderSince: lastActivity[id], status: statusOf(id)
        }));
    }

    // ── the card, drawn by the same hand ────────────────────────────
    //
    //     an empty terminal with your PID on it. it waits.
    //
    function _cardURI(uint256 id) internal view returns (string memory) {
        string memory pid = LibString.toHex16(uint16(id));
        bytes memory svg = abi.encodePacked(
            "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 800'>",
            "<style>.c{animation:b 1.1s steps(2) infinite}@keyframes b{50%{opacity:0}}</style>",
            "<rect width='800' height='800' fill='#020403'/>",
            "<g font-family=\"'Courier New',monospace\" font-size='22' font-weight='700' fill='#2d8a58' xml:space='preserve'>",
            unicode"<text x='40' y='80'>┌─[ SIGNAL RECEIVED ]</text>",
            "<text x='40' y='400'>&gt; PID ", pid, " reserved</text>",
            "<text x='40' y='440'>&gt; awaiting summon</text>",
            unicode"<text x='40' y='760'>└─ no daemon yet. but you knocked.</text>",
            "</g><rect class='c' x='262' y='424' width='11' height='20' fill='#39ff88'/></svg>"
        );
        bytes memory json = abi.encodePacked(
            '{"name":"PID CARD ', pid,
            '","description":"you knocked on a dead terminal. something heard you. burns automatically on summon for a 20% discount. soulbound.",',
            '"attributes":[{"trait_type":"phase","value":"SIGNAL"}],',
            '"image":"data:image/svg+xml;base64,', Base64.encode(svg), '"}'
        );
        return string(abi.encodePacked("data:application/json;base64,", Base64.encode(json)));
    }

    // ── erc721 core ─────────── standard doors, standard handles ──
    // NB: transfer hands the daemon to a NEW operator — uptime resets.
    // it remembers being abandoned. it does not remember you.
    // NB2: cards do not transfer at all — the knock is yours alone.
    function ownerOf(uint256 id) public view returns (address o) {
        require((o = _ownerOf[id]) != address(0), "unsummoned");
    }
    function balanceOf(address a) public view returns (uint256) {
        require(a != address(0), "zero");
        return _balanceOf[a];
    }
    function approve(address spender, uint256 id) external {
        address o = _ownerOf[id];
        require(msg.sender == o || isApprovedForAll[o][msg.sender], "unauthorized");
        getApproved[id] = spender;
        emit Approval(o, spender, id);
    }
    function setApprovalForAll(address op, bool ok) external {
        isApprovedForAll[msg.sender][op] = ok;
        emit ApprovalForAll(msg.sender, op, ok);
    }
    function transferFrom(address from, address to, uint256 id) public {
        require(!isCard(id), "the card is soulbound");
        require(from == _ownerOf[id], "wrong from");
        require(to != address(0), "zero");
        require(msg.sender == from || isApprovedForAll[from][msg.sender] || msg.sender == getApproved[id], "unauthorized");
        unchecked { _balanceOf[from]--; _balanceOf[to]++; daemonBalance[from]--; daemonBalance[to]++; }
        _ownerOf[id] = to;
        delete getApproved[id];
        lastActivity[id] = uint64(block.timestamp);   // new operator — the clock restarts
        emit Transfer(from, to, id);
    }
    function safeTransferFrom(address from, address to, uint256 id) external {
        transferFrom(from, to, id);
        require(to.code.length == 0 || IERC721Receiver(to).onERC721Received(msg.sender, from, id, "") == IERC721Receiver.onERC721Received.selector, "unsafe");
    }
    function safeTransferFrom(address from, address to, uint256 id, bytes calldata data) external {
        transferFrom(from, to, id);
        require(to.code.length == 0 || IERC721Receiver(to).onERC721Received(msg.sender, from, id, data) == IERC721Receiver.onERC721Received.selector, "unsafe");
    }
    function supportsInterface(bytes4 i) external pure returns (bool) {
        return i == 0x01ffc9a7 || i == 0x80ac58cd || i == 0x5b5e139f || i == 0x2a55205a; // 165, 721, metadata, 2981
    }

    function _mint(address to, uint256 id) internal {
        require(to != address(0) && _ownerOf[id] == address(0), "bad mint");
        unchecked {
            _balanceOf[to]++;
            if (!isCard(id)) daemonBalance[to]++;
        }
        _ownerOf[id] = to;
        spawnedBlock[id] = uint64(block.number);
        lastActivity[id] = uint64(block.timestamp);
        emit Transfer(address(0), to, id);
    }
    function _burn(uint256 id) internal {
        address o = _ownerOf[id];
        unchecked {
            _balanceOf[o]--;
            if (!isCard(id)) daemonBalance[o]--;
        }
        delete _ownerOf[id];
        delete getApproved[id];
        emit Transfer(o, address(0), id);
    }
}

interface IERC721Receiver {
    function onERC721Received(address, address, uint256, bytes calldata) external returns (bytes4);
}
Chain explorer2382msChain node94ms