{"id":"registry-v1","title":"Registry / 001","summary":"Reduce registry gas. Preserve every tested behavior.","version":1,"entries":32,"valueBytes":64,"environment":"NEAR Sandbox","baseline":"registry-baseline","candidate":"registry-indexed","rules":["Only the owner can set or remove entries.","Overwrite preserves count. Missing keys return null.","Remove returns true only when a key existed.","Values up to 256 UTF-8 bytes are accepted; longer values are rejected.","No hard-coded workload answers. All valid NEAR account IDs must work.","Keep the public method names, arguments, and return types."],"scope":"Fresh deployments. State migration is outside this challenge.","baseline_source":"use near_sdk::{env, near, AccountId, PanicOnDefault};\n\n#[near(contract_state)]\n#[derive(PanicOnDefault)]\npub struct Registry {\n    owner_id: AccountId,\n    entries: Vec<(AccountId, String)>,\n}\n\n#[near]\nimpl Registry {\n    #[init]\n    pub fn new(owner_id: AccountId) -> Self {\n        Self { owner_id, entries: Vec::new() }\n    }\n\n    pub fn set(&mut self, account_id: AccountId, value: String) {\n        self.assert_owner();\n        if value.len() > 256 { env::panic_str(\"Value too long\"); }\n        if let Some(entry) = self.entries.iter_mut().find(|(id, _)| id == &account_id) {\n            entry.1 = value;\n        } else {\n            self.entries.push((account_id, value));\n        }\n    }\n\n    pub fn get(&self, account_id: AccountId) -> Option<String> {\n        self.entries.iter().find(|(id, _)| id == &account_id).map(|(_, value)| value.clone())\n    }\n\n    pub fn remove(&mut self, account_id: AccountId) -> bool {\n        self.assert_owner();\n        if let Some(index) = self.entries.iter().position(|(id, _)| id == &account_id) {\n            self.entries.swap_remove(index);\n            true\n        } else { false }\n    }\n\n    pub fn count(&self) -> u32 { self.entries.len() as u32 }\n\n    fn assert_owner(&self) {\n        if env::predecessor_account_id() != self.owner_id { env::panic_str(\"Owner only\"); }\n    }\n}\n"}