⚙️ MICHELSON RUNE DIFFICULTY: Adept Structural

The Flyweight Pattern in Michelson

Minimizing storage costs by sharing intrinsic contract state across multiple invocations.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Transmutation // Stackmancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MICHELSON PATTERN //
parameter (pair int address);
storage (map int string);
code {
  UNPAIR;
  UNPAIR;
  DIG 2;
  DUP;
  DIG 3;
  GET;
  IF_NONE {
    PUSH string "FlyweightError: Intrinsic state uninitialized";
    FAILWITH;
  } {
    # Extrinsic state is the address, intrinsic state is the string from the map
    DROP; # Conceptually combining them
  };
  SWAP; DROP;
  NIL operation; PAIR
}
Runic Tags: #structural #flyweight #stack-based smart contracts #michelson #tezos