Contracts
Almanac Contract and Remote Communications
Registration and Endpoints Weighting

Registration and Endpoints Weighting

uAgents can communicate in a remote fashion with one another across different locations on the internet. This is achievable by using the Agent address to register into the Almanac contract ( by first paying a small fee), and then querying the Almanac to retrieve an HTTP endpoint of a recipient uAgent.

Whenever uAgents registers in the Almanac, they must specify the service endpoints it provides alongside a weight parameter for each endpoint provided. Then, when any agent tries to communicate with this uAgent, the service endpoint will be chosen using a weighted random selection.

For additional information on uAgents addresses, have a look at our guide ↗️

Endpoint weighting

There exist two format options when defining your agent's endpoints:

  • List format: This defines the uAgent's endpoints as a list of strings. The weights will be automatically assigned a value of 1.

    agent = Agent(
        name="alice",
        port=8000,
        seed="agent secret phrase",
        endpoint=["http://127.0.0.1:8000/submit","http://127.0.0.1:8001/submit"]
    )
  • Dictionary format: This defines the uAgent's endpoints in a Dict format, specifying the weight for each endpoint. If the weight parameter is not specified, it will be assigned a value of 1.

    agent = Agent(
        name="alice",
        port=8000,
        seed="agent recovery seed phrase",
        endpoint={
            "http://127.0.0.1:8000/submit": {"weight": 2},
            "http://127.0.0.1:8001/submit": {}, # weight value = 1
        },
    )

You can now head towards the following dedicated guides showing you how to: