Build real things · ≈ 12 min

A name registry

First come, first served — and the transfer rules that decide whether a name is really yours.

A registry maps a human-readable name to an owner. Every naming system on every chain is a variation on three operations:

  • claim a name nobody holds
  • transfer a name you hold
  • release a name you no longer want, returning it to the pool

The interesting design questions are all about the edges. Can a name be re-claimed after release? Can you transfer to yourself? Is Alice the same name as alice?

Normalise before you store, or you have sold the same name twice. If Alice and alice are different keys, two people each believe they own "alice" and both are right according to the contract. Every dispute after that is unresolvable.

Pick a rule — lowercase ASCII only, say — enforce it in claim, and reject anything that does not conform rather than silently mangling it. A rejected claim is a clear error; a silently normalised one surprises someone later.

contracts/examples/registry is deliberately minimal — set, get, has, remove keyed by address. The ownership and normalisation rules below are what you add when the thing being registered is *scarce* rather than personal.

Your turn

Implement claim, owner_of, transfer and release. Names must be non-empty lowercase ASCII (reject anything else with b"bad_name"). A claimed name cannot be re-claimed; only its owner may transfer or release it; a released name becomes claimable again.

Hints

Stuck? Ask

Answered by Animica's own free inference network. It is donated GPU capacity, so give it 20-30 seconds.