Skip to content

Commit

Permalink
Merge pull request #92 from permaweb/PSkinnertech-TokengatedRevision
Browse files Browse the repository at this point in the history
refactor: corrected token and tokengated tutorials
  • Loading branch information
PSkinnerTech authored Feb 27, 2024
2 parents cedc4ac + 0f6f1c3 commit ec97ee4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/tutorials/begin/token.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ This will print the token information to the console. It should show your proces
Now that we've tested the token and it's working as expected, we can send some tokens to `Trinity`. We'll send 1000 tokens to `Trinity` using the `Action = "Transfer"` tag.
```sh
aos> Send({ Target = "Trinity", Action = "Transfer", Quantity = 1000 })
aos> Send({ Target = Trinity, Action = "Transfer", Quantity = 1000 })
```
When `Trinity` receives the tokens, she'll respond to the transfer with a message to confirm that she's received the tokens.
Expand Down
37 changes: 19 additions & 18 deletions src/tutorials/begin/tokengating.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Tokengating the Chatroom

:::warning
This tutorial is actively under development and the content is subject to change.
:::

::: info
Now that we've created a token and sent it to `Trinity`, we can use the token to tokengate our chatroom. This will allow only those who have the token to enter the chatroom.
:::

### How to Tokengate the Chatroom

Let's create a handler that will allow us to tokengate the chatroom. This handler will respond to the tag `Action = "broadcast"` meaning it will replace the original `broadcast` handler we built for our chatroom.
Let's create a handler that will allow us to tokengate the chatroom. This handler will respond to the tag `Action = "Broadcast"` meaning it will replace the original `broadcast` handler we built for our chatroom.

## Step 1: Start the same `aos` process.

Expand Down Expand Up @@ -37,7 +35,7 @@ Handlers.add(
ao.send({
Target = Members[i].Address,
Nickname = Members[i].Nickname,
Action = "Broadcasted",
Action = "Broadcast",
Broadcaster = m.From,
Data = m.Data
})
Expand Down Expand Up @@ -67,12 +65,16 @@ Now that the chatroom is tokengated, let's test it by sending a message to the c
First, we'll test it from the original aos process.

```sh
aos> Send({ Target = ao.id , Action = "Broadcast", Data = "It is done" })
aos> Send({ Target = ao.id , Action = "Broadcast", Data = "Hello" })
# Expected Results:
message added to outbox
Broadcasting message from Neo. Content: It is done.
Broadcasting message from Neo. Content: Hello.
```

## Testing from another Process ID.

````
### From a new aos process
Now, let's test it from a new aos process that doesn't have a token.
Expand All @@ -84,7 +86,7 @@ aos> Send({ Target = [Your Process ID], Action = "Register" })
# Expected Results:
message added to outbox
New Message From [Your Process ID]: Data = registered
```
````

Now, let's try to send a message to the chatroom.

Expand All @@ -97,20 +99,19 @@ UNAUTH REQ: [New Process ID]

As you can see, the message was not broadcasted because the new process doesn't have a token.

## Tell `Trinity` that the Chatroom is now "Locked"
## Tell Trinity "It is done"

Now that the chatroom is tokengated, let's tell `Trinity` that the chatroom is now "locked."
From the original aos process, send a broadcast message to the chatroom saying, "It is done."

```sh
aos> Send({ Target = "Trinity", Connect = "Locked", Data ="The Chatroom is now locked." }})
# Expected Results:
message added to outbox
New Message from [Trinity's Process ID]: Data = You have done it. I think it is now time for you to join the others. Register yourself to the Construct [Construct Process ID] where only those that have shown themselves to be worthy can enter.
```
Trinity will then respond to the chatroom being tokengated.

#### Expected Results:

Trinity will send a message saying, "I guess Morpheus was right. You are the one. Consider me impressed. You are now ready to join The Construct, an exclusive chatroom available to only those that have completed this tutorial. Now, go join the others by using the same tag you used `Register`, with this process ID: [Construct Process ID]. Good luck."

## Conclusion

You've done it! You've successfully tokengated the chatroom and told `Trinity` that the chatroom is now "locked." This has now unlocked access to the Construct, where only those that have fully completed this tutorial can enter.
You've done it! You've successfully tokengated the chatroom. This has now unlocked access to the Construct, where only those that have fully completed this tutorial can enter.

### Congratulations!

Expand Down

0 comments on commit ec97ee4

Please sign in to comment.