Comment on page
Hat ids are semantic. They have meaning.
Hat ids uint256 bitmaps that create an "address" — more like an web or IP address than an Ethereum address — that includes information about where in the tree a hat is located, including its entire branch of admins.
The 32 bytes of a hat's id are structured as follows:
- The first 4 bytes are reserved for the top hat id. Since top hat ids are unique across a given deployment of Hats Protocol, we can also think of them as the top level "domain" for a hat tree.
- Each of the next chunks of 16 bits refers to a single "Hat Level".
There are 15 total hat levels, beginning with the top hat at level 0 and going up to level 14.
Consider the following hat id (in hex): 0x0000000f00020005000a00010000000000000000000000000000000000000000
For convenience, we can reformat it into shorthand, just like an IP address: 188.8.131.52.1
From the id alone, we know a lot about this hat:
- It is in hat tree 15
- It is a level 4 hat
- Its immediate admin (aka parent) is 184.108.40.206
- Its grandparent is 15.2.5
A hat tree can have up to 14 levels, plus the top hat (tree root). Within those 14 levels are 224 bits of address space (remember, one level contains 16 bits of space), so the maximum number of hats in a single hat tree is approximately:
which is well beyond the number of stars in the universe.