Contracts
Almanac contract and remote communication
Registration and endpoints weighting
Bookmark

Registration and endpoints weighting

Agents 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 agent.

Whenever agents 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 agent, the service endpoint will be chosen using a weighted random selection.

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

Endpoint weighting

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

  • List format: This defines the agent'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 agent'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:

Was this page helpful?

Bookmark