-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbob.py
31 lines (21 loc) · 911 Bytes
/
bob.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from uagents.setup import fund_agent_if_low
from uagents import Agent, Context, Model
class Message(Model):
message: str
bob = Agent(
name="bob",
port=8001,
seed="tool model void slim mixed brave muffin inform swim loyal envelope front mind feed hold timber like shove cube donor paddle walk opinion elder",
endpoint=["http://127.0.0.1:8001/submit"],
)
fund_agent_if_low(bob.wallet.address())
# print your agent's identifier/address and its fetch network/wallet address
print("uAgent address/identifier: ", bob.address)
print("Fetch network/wallet address: ", bob.wallet.address())
@bob.on_message(model=Message)
async def message_handler(ctx: Context, sender: str, msg: Message):
ctx.logger.info(f"Received message from {sender}: {msg.message}")
# send the response
await ctx.send(sender, Message(message="hello there alice"))
if __name__ == "__main__":
bob.run()