The Singleton Pattern in Michelson
The immutable nature of the smart contract address itself forms the ultimate Singleton.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Conjuration // Stackmancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MICHELSON PATTERN //
parameter unit;
storage (pair (address %instance) (string %data));
code {
UNPAIR;
DROP;
# Ensure only the singular self-address is the recognized instance
SELF_ADDRESS;
UPDATE 1;
NIL operation; PAIR
}
Runic Tags:
#creational
#singleton
#stack-based smart contracts
#michelson
#tezos