Cairo Dictionaries

Explain Cairo Felt252Dict usage, insert/get/entry patterns, and dictionary squashing; use when a request involves key-value storage, dictionary performance, or borrow/ownership rules for dictionaries in Cairo.

teddyjfpender 62e0cf2 2 files · 2.3 KB Updated

File contents

Cairo Dictionaries

Overview

Guide correct creation and use of Cairo dictionaries with proper ownership and performance notes.

Quick Use

  • Read references/dictionaries.md before answering.
  • Show minimal snippets using Felt252Dict plus Felt252DictTrait methods.
  • Mention squashing and cost implications when discussing performance.

Response Checklist

  • Use Felt252Dict::<T>::default() to initialize.
  • Use insert and get for basic operations; use entry/finalize for advanced patterns.
  • Remind that keys are felt252 and values are generic T.
  • Call out that dictionary access is linear in the number of entries and squashing occurs on destruction.

Example Requests

  • "How do I store balances by address in Cairo?"
  • "Why does get return a default value sometimes?"
  • "What is dictionary squashing and when does it happen?"

Cairo by Example

teddyjfpender/skill-issues/tree/main/skills/cairo-dictionaries commit 62e0cf2c44

Frequently asked questions

npx skillmds@latest add teddyjfpender/cairo-dictionaries