Skip to content

Commit

Permalink
better examples and understanding for the nameservice based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Oct 30, 2024
1 parent deddec2 commit 922c007
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Building your first Cosmos-SDK blockchain with Spawn. This tutorial focuses on a
* Interacting with the network
:::

## How a Name Service works

Imagine you have a set of labeled containers, each with a unique name like "Essentials" "Electronics" and "Books". The label on each container is called the key, and what’s stored inside is the value. For example, the key "Books" leads you to a container full of books, while "Essentials" might have things like toiletries or basic supplies.

In a nameservice, this key-value system lets you quickly find or access specific data by referencing a unique name, or key, which reliably points you to the related value. This is useful for mapping names to specific information or resources, so with just the name, you can always find exactly what you're looking for.

For this tutorial we map a human readable name (like `"alice"`) to a complex wallet address (like `roll1efd63aw40lxf3n4mhf7dzhjkr453axur57cawh`) so it is easier to understand and view as a user.

## Prerequisites
- [System Setup](../01-setup/01-system-setup.md)
- [Install Spawn](../01-setup/02-install-spawn.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ slug: /build/name-service-application

# Save Storage Structure

You now need to set the data structure in the keeper to store the wallet to name pair. Keeper's are where the data is stored for future use.
You now need to set the data structure in the keeper to store the wallet to name pair. Keepers are where the data is stored for future use and handle the business logic.
Think of it like a box where you store your data and the methods used to modify this data. It is self contained and only gets further access if you allow the keeper to do so (shown in [part 2](../02-build-your-application/08-ibc-module.md)).

```go title="x/nameservice/keeper/keeper.go"

Expand All @@ -34,8 +35,6 @@ func NewKeeper() Keeper {
}
```

![keeper NewKeeper NameMapping](https://github.com/rollchains/spawn/assets/31943163/47ed4a41-4df2-4a5d-9ac5-bfb23aeefd94)

---

## Application Logic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ The chain will begin to create (mint) new blocks. You can see the logs of the ne

### Interact Set Name

Using the newly built binary *(rolld from the --bin flag when the chain was created)*, you are going to execute the `set` transaction to your name. In this example, use "alice". This links account `acc1` address to the desired name in the keeper.
Using the newly built binary executable *(rolld from the --bin flag when the chain was created)*, you are going to execute the `set` action to your name. In this example, use "alice". This links account `acc1` address to the desired name in the keeper.

Then, resolve this name with the nameservice lookup. `$(rolld keys show acc1 -a)` is a substitute for the acc1's address. You can also use just `roll1hj5fveer5cjtn4wd6wstzugjfdxzl0xpg2te87` here.
You can either query or set data in the network using the command executable. If you wish to perform an action you submit a transaction (tx). If you wish to read data you are querying (q). The next sub command specifies which module will receive the action on. In this case, the `nameservice` module since our module is named nameservice. Then the `set` command is called, which was defined in the autocli.go.

```bash
rolld tx nameservice set alice --from=acc1 --yes
Expand Down

0 comments on commit 922c007

Please sign in to comment.