Note

This section is highly experimental. We will update it soon.

The fetchai/p2p_libp2p:0.2.0 connection allows AEAs to create a peer-to-peer communication network. In particular, the connection creates an overlay network which maps agents' public keys to IP addresses.

Local Demo

Create and run the genesis AEA

Create one AEA as follows:

aea create my_genesis_aea
cd my_genesis_aea
aea add connection fetchai/p2p_libp2p:0.1.0
aea config set agent.default_connection fetchai/p2p_libp2p:0.1.0
aea run --connections fetchai/p2p_libp2p:0.1.0

Create and run another AEA

Create a second AEA:

aea create my_other_aea
cd my_other_aea
aea add connection fetchai/p2p_libp2p:0.1.0
aea config set agent.default_connection fetchai/p2p_libp2p:0.1.0

Provide the AEA with the information it needs to find the genesis by adding the following block to vendor/fetchai/connnections/p2p_libp2p/connection.yaml:

config:
  libp2p_entry_peers: MULTI_ADDRESSES
  libp2p_host: 0.0.0.0
  libp2p_log_file: libp2p_node.log
  libp2p_port: 9001
Here MULTI_ADDRESSES needs to be replaced with the list of multi addresses displayed in the log output of the genesis AEA.

Run the AEA:

aea run --connections fetchai/p2p_libp2p:0.1.0

You can inspect the libp2p_node.log log files of the AEA to see how they discover each other.

Local Demo with skills

Fetch the weather station and client

Create one AEA as follows:

aea fetch fetchai/weather_station:0.4.0
aea fetch fetchai/weather_client:0.4.0

Then enter each project individually and execute the following to add the p2p_libp2p connection:

aea add connection fetchai/p2p_libp2p:0.1.0
aea config set agent.default_connection fetchai/p2p_libp2p:0.1.0

Then extend the aea-config.yaml of each project as follows:

default_routing:
  ? "fetchai/oef_search:0.1.0"
  : "fetchai/oef:0.3.0"

Run OEF

Run the oef for search and discovery:

python scripts/oef/launch.py -c ./scripts/oef/launch_config.json

Run weather station

Run the weather station first:

aea run --connections "fetchai/p2p_libp2p:0.1.0,fetchai/oef:0.3.0"
The weather station will form the genesis node. Wait until you see the lines:
My libp2p addresses: ...
Take note of these as the genesis' MULTI_ADDRESSES = ["{addr1}", "{addr2}"].

Generate wealth for the weather client AEA

The weather client needs to have some wealth to purchase the weather station information.

First, create the private key for the weather client AEA based on the network you want to transact. To generate and add a private-public key pair for Fetch.ai use:

aea generate-key fetchai
aea add-key fetchai fet_private_key.txt

Then, create some wealth for your weather client based on the network you want to transact with. On the Fetch.ai testnet network:

aea generate-wealth fetchai

Run the weather client

Provide the weather client AEA with the information it needs to find the genesis by adding the following block to vendor/fetchai/connnections/p2p_libp2p/connection.yaml:

config:
  libp2p_entry_peers: MULTI_ADDRESSES
  libp2p_host: 0.0.0.0
  libp2p_log_file: libp2p_node.log
  libp2p_port: 9001
Here MULTI_ADDRESSES needs to be replaced with the list of multi addresses displayed in the log output of the weather station AEA.

Then fund your Now run the weather client:

aea run --connections "fetchai/p2p_libp2p:0.1.0,fetchai/oef:0.3.0"

Deployed Test Network

Note

Coming soon.