|
| 1 | +--- |
| 2 | +publication_date: 2025-03-12T00:00:00Z |
| 3 | +slug: user-registry |
| 4 | +tags: [gnoland, usernames, namespaces, dapps] |
| 5 | +authors: [leohhhn] |
| 6 | +--- |
| 7 | + |
| 8 | +# Introducing the New gno.land User Registry |
| 9 | + |
| 10 | +The user registration system has been around since the early days of gno.land, |
| 11 | +serving as one of the foundational components of the chain. It allows users to |
| 12 | +register custom names linked to their Gno addresses and claim matching namespaces |
| 13 | +for their Gno package deployments. |
| 14 | + |
| 15 | +While the username registration system existed as far back as April 2022 ([`r/demo/users`](https://github.com/gnolang/gno/commit/914f267dd31c0382a472b5fcf98fcfc53129a32d)) |
| 16 | +the namespace permission deployment went into effect with Test4 for the first time |
| 17 | +in July 2024. |
| 18 | + |
| 19 | +With changes to the Gno language, chain infrastructure, as well as the addition |
| 20 | +of governance and other new functionality, the user registry was due for a major |
| 21 | +refactor. This new version introduces a set of realms that integrate directly |
| 22 | +with the core of the gno.land blockchain, providing similar but more flexible |
| 23 | +functionality and upgradeability through GovDAO proposals. |
| 24 | + |
| 25 | +## Register your gno.land username now! |
| 26 | + |
| 27 | +We invite you to register your gno.land username with the new User Registry on |
| 28 | +the Portal Loop network. |
| 29 | + |
| 30 | +Here's how to register in a few steps: |
| 31 | +- Create a Gno address with `gnokey` or a third-party wallet such as Adena |
| 32 | +- Fetch Portal Loop GNOT from the [Faucet Hub](https://faucet.gno.land) |
| 33 | +- Visit the [User Registry realm](/r/gnoland/users/v1) |
| 34 | +- If you're using Adena, you can use [GnoStudio Connect](https://gno.studio/connect/view/gno.land/r/gnoland/users/v1?network=portal-loop#Register) |
| 35 | +to send a transaction via the web. |
| 36 | + - Under advanced options, make sure to set the "send" amount to `1000000ugnot` |
| 37 | + to pay for the registration fee. |
| 38 | +- If you're using `gnokey`, click on "Register" to get a pre-built `gnokey` command |
| 39 | + - Make sure to also set `-send "1000000ugnot"` to pay for the registration fee |
| 40 | +- Enter your desired username which follows the naming rules outlined in the |
| 41 | +User Registry realm. |
| 42 | +- Call the function and see your name show up in the "Latest registrations" section! |
| 43 | + |
| 44 | +> Make sure to specify exact amount of GNOT for the registration fee (1 GNOT). |
| 45 | +
|
| 46 | +## System Architecture |
| 47 | + |
| 48 | +For developers that are looking to use the new User Registry system in their |
| 49 | +realms, below is an outline of the main components of the system including a |
| 50 | +practical example found under `r/docs`. |
| 51 | + |
| 52 | +The new user registration system, paired with the namespace system, enables |
| 53 | +custom usernames and namespace permission checking upon package deployment. It |
| 54 | +consists of three key realms: |
| 55 | + |
| 56 | +- [`r/sys/users`](/r/sys/users) - Core logic of the system, handling storage and resolution. |
| 57 | +- [`r/gnolang/users/v1`](/r/gnoland/users/v1) - The user-facing application where users register names. |
| 58 | +- [`r/sys/names`](/r/sys/names) - The deployment permission system for namespaces. |
| 59 | + |
| 60 | +Let's dive into what each part of the system does. |
| 61 | + |
| 62 | +### r/sys/users |
| 63 | + |
| 64 | +This is a system realm that defines the core logic of the user registry. It is |
| 65 | +not upgradeable and serves as the foundational layer that includes key data |
| 66 | +structures, storage variables, and functions for managing usernames. |
| 67 | + |
| 68 | +Only whitelisted realms (approved via GovDAO proposals) can write to this storage, |
| 69 | +ensuring governance oversight over any entity modifying the registry. |
| 70 | + |
| 71 | +The `UserData` structure defines how user information is stored: |
| 72 | + |
| 73 | +```go |
| 74 | +type UserData struct { |
| 75 | + addr std.Address // User's blockchain address |
| 76 | + username string // Latest registered username |
| 77 | + deleted bool // Flag for soft deletion |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +This realm also provides user-facing functions for resolving names and addresses. |
| 82 | + |
| 83 | +#### Resolving Usernames & Addresses |
| 84 | + |
| 85 | +To enable applications and smart contracts to look up user information, |
| 86 | +`r/sys/users` provides functions to resolve both usernames and addresses: |
| 87 | + |
| 88 | +```go |
| 89 | +// ResolveName returns the latest UserData of a specific user by name or alias |
| 90 | +func ResolveName(name string) (data *UserData, isCurrent bool) {...} |
| 91 | + |
| 92 | +// ResolveAddress returns the latest UserData of a specific user by address |
| 93 | +func ResolveAddress(addr std.Address) *UserData {...} |
| 94 | +``` |
| 95 | + |
| 96 | +See how to use these functions in a practical example [here](/r/docs/users), and |
| 97 | +check out the source code [here](/r/sys/users$source&file=users.gno). |
| 98 | + |
| 99 | +### r/gnoland/users/v1 |
| 100 | + |
| 101 | +The first iteration of the gno.land user registry allows users to register a |
| 102 | +name following a specific pattern - starts with three letters, ends with three |
| 103 | +numbers, and is not longer than 20 characters. The registration costs 1 GNOT |
| 104 | +and the fee is modifiable via a GovDAO proposal. |
| 105 | + |
| 106 | +This is the user-facing realm where users interact with the registry. It |
| 107 | +provides an interface for registering usernames while enforcing certain constraints: |
| 108 | + |
| 109 | +- Usernames must start with three letters. |
| 110 | +- They must end with three numbers. |
| 111 | +- The total length must not exceed 20 characters. |
| 112 | +- Only `_` is allowed as a special character. |
| 113 | +- The registration fee is 1 GNOT (modifiable via GovDAO proposals). |
| 114 | + |
| 115 | +This realm communicates with `r/sys/users` to ensure new registrations follow the |
| 116 | +system-wide rules and that only valid usernames are stored. Future versions |
| 117 | +(v2, v3, etc.) will follow different patterns, such as vanity usernames, username |
| 118 | +auctions, and more can be introduced without modifying the core storage logic. |
| 119 | + |
| 120 | +Find all releases for `r/gnoland/users` [here](/r/gnoland/users). |
| 121 | + |
| 122 | +### r/sys/names |
| 123 | + |
| 124 | +The deployment permission system ensures that only the rightful owner of a |
| 125 | +namespace can deploy Gno packages under it. |
| 126 | + |
| 127 | +This check is performed at the GnoVM Keeper level, which communicates with |
| 128 | +`r/sys/names` realm before allowing a deployment to a certain package patch. |
| 129 | +This functionality is enabled in the genesis block, with an ownership-dropping |
| 130 | +mechanism ensuring no single entity retains control over the system. |
| 131 | + |
| 132 | +Check out the source code [here](/r/sys/names$source&file=verifier.gno). |
0 commit comments