Skip to content

Commit

Permalink
fix(docs): addresses issue in name service guide
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixNicolaeBucsa committed Oct 3, 2024
1 parent f2a009b commit 8884ad1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pages/guides/agents/advanced/name-service.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ Let's start with the first agent of this example, Bob.
faucet.get_wealth(my_wallet.address())
```

We first create a wallet from a seed phrase and this wallet is used for interacting with the Fetch.ai blockchain. We then proceed and define the Name Service Contract. It retrieves the name service contract to register the agent's name on the blockchain. The `test=True` parameter indicates this is a `test` setup. Then, we define the faucet used to fund the wallet with test tokens. We then define the domain for the agent's name registration and finally proceed to request funds from the faucet to ensure the agent's wallet has sufficient funds to operate. Remember that you need to provide the `name`, `seed`, `port`, `endpoint` and `DOMAIN` parameters to correctly run this code!

We first create a wallet from a seed phrase and this wallet is used for interacting with the Fetch.ai blockchain. We then proceed and define the Name Service Contract. It retrieves the name service contract to register the agent's name on the blockchain. The `test=True` parameter indicates this is a `test` setup. Then, we define the faucet used to fund the wallet with test tokens. We then define the domain for the agent's name registration and finally proceed to request funds from the faucet to ensure the agent's wallet has sufficient funds to operate. Remember that you need to provide the `name`, `seed`, `port`, `endpoint` and `DOMAIN` parameters to correctly run this code!

5. We continue and define Bob's functions. We start with a register_agent_name function which registers Bob's name within the blockchain using the agent's wallet, address, name and domain parameters:

Expand All @@ -116,9 +115,9 @@ Let's start with the first agent of this example, Bob.
)
```

Here, we defined the `register_agent_name` function. It registers the agent's name on the blockchain when the agent is initialized. The function uses the name service contract to register `bob-0.example.agent` agent using the `my_wallet` wallet.
Here, we defined the `register_agent_name` function. It registers the agent's name on the blockchain when the agent is initialized. The function uses the name service contract to register `bob-0.example.agent` agent using the `my_wallet` wallet. **It is important that you provide only lower case letters for your agent's `name` and `DOMAIN` parameters as otherwise you will face issues the moment you run your agent**.

7. We now define a `message_handler` function for Bob to handle incoming messages:
6. We now define a `message_handler` function for Bob to handle incoming messages:

```python copy
@bob.on_message(model=Message)
Expand All @@ -131,7 +130,7 @@ Let's start with the first agent of this example, Bob.

Here we defined a function handling incoming messages of type `Message`. It logs the sender's address and the message content.

8. Finally we save and run the script.
7. Finally, we save and run the script.

The overall script for this example should look as follows:

Expand Down Expand Up @@ -216,7 +215,7 @@ Let's now define the code for our second agent, Alice.
DOMAIN = "example.agent"
```

5. Finally we define the functions and behaviours for Alice:
5. Finally, we define the functions and behaviours for Alice:

```python copy
@alice.on_interval(period=5)
Expand All @@ -231,7 +230,7 @@ Let's now define the code for our second agent, Alice.

This `alice_interval_handler()` function runs at regular intervals of 5 seconds to send messages. The handler constructs Bob's address using the domain and sends a message to Bob. It combines `bob-0` name with the `DOMAIN` to form `bob-0.example.agent`. The agent logs the action and sends a message with the content "Hello there bob." to Bob agent.

Remember that you need to provide the `name`, `seed`, `port`, `endpoint` and `DOMAIN` parameters to correctly run this code!
Remember that you need to provide the `name`, `seed`, `port`, `endpoint` and `DOMAIN` parameters to correctly run this code! **Additionally, it is important that you provide only lower case letters for your agent's `name` and `DOMAIN` parameters as otherwise you will face issues the moment you run your agent**.

The overall script for this example should look as follows:

Expand Down

0 comments on commit 8884ad1

Please sign in to comment.