Interval tasks with Agents
Bookmark

Interval task with Agents

Introduction

This file can be run on any platform supporting Python, with the necessary install permissions. This example shows how to use the uAgents library to set up an interval task using the on_interval() decorator.

Guide

Supporting documentation

The agent

interval-task.py
from uagents import Agent, Context
 
alice = Agent(name="alice", seed="alice recovery phrase")
 
@alice.on_interval(period=2.0)
async def say_hello(ctx: Context):
    ctx.logger.info(f'hello, my name is {ctx.name}')
 
if __name__ == "__main__":
    alice.run()

Was this page helpful?

Bookmark