The AEA weather skills demonstrate an interaction between two AEAs.

  • The provider of weather data (the weather_station).
  • The buyer of weather data (the weather_client).

Discussion

The scope of the specific demo is to demonstrate how to create a simple AEA with the usage of the AEA framework and a database. The weather_station AEA will read data from the database, that is populated with readings from a weather station, based on the requested dates and will deliver the data to the client upon payment. This demo does not utilize a smart contract. As a result, we interact with a ledger only to complete a transaction.

You can use this AEA as an example of how to read data from a database and advertise these to possible clients.

Communication

This diagram shows the communication between the various entities as data is successfully sold by the weather station AEA to the client.

sequenceDiagram participant Search participant Client_AEA participant Weather_AEA participant Blockchain activate Client_AEA activate Search activate Weather_AEA activate Blockchain Weather_AEA->>Search: register_service Client_AEA->>Search: search Search-->>Client_AEA: list_of_agents Client_AEA->>Weather_AEA: call_for_proposal Weather_AEA->>Client_AEA: propose Client_AEA->>Weather_AEA: accept Weather_AEA->>Client_AEA: match_accept Client_AEA->>Blockchain: transfer_funds Client_AEA->>Weather_AEA: send_transaction_hash Weather_AEA->>Blockchain: check_transaction_status Weather_AEA->>Client_AEA: send_data deactivate Client_AEA deactivate Search deactivate Weather_AEA deactivate Blockchain

Preparation instructions

Dependencies

Follow the Preliminaries and Installation sections from the AEA quick start.

Launch an OEF search and communication node

In a separate terminal, launch a local OEF search and communication node.

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

Keep it running for all the following demos.

Demo instructions:

A demo to run the same scenario but with a true ledger transaction on Fetch.ai testnet or Ethereum ropsten network. This demo assumes the buyer trusts the seller AEA to send the data upon successful payment.

Create the weather station

First, fetch the AEA that will provide weather measurements:

aea fetch fetchai/weather_station:0.6.0 --alias my_weather_station
cd my_weather_station
aea install
Alternatively, create from scratch.

The following steps create the weather station from scratch:

aea create my_weather_station
cd my_weather_station
aea add connection fetchai/oef:0.5.0
aea add connection fetchai/ledger:0.1.0
aea add skill fetchai/weather_station:0.5.0
aea install
aea config set agent.default_connection fetchai/oef:0.5.0
In `weather_station/aea-config.yaml` replace `ledger_apis: {}` with the following based on the network you want to connect. To connect to Fetchai:
ledger_apis:
  fetchai:
    network: testnet
and add
default_routing:
  fetchai/ledger_api:0.1.0: fetchai/ledger:0.1.0

Create the weather client

In another terminal, fetch the AEA that will query the weather station:

aea fetch fetchai/weather_client:0.6.0 --alias my_weather_client
cd my_weather_client
aea install
Alternatively, create from scratch.

The following steps create the weather client from scratch:

aea create my_weather_client
cd my_weather_client
aea add connection fetchai/oef:0.5.0
aea add connection fetchai/ledger:0.1.0
aea add skill fetchai/weather_client:0.4.0
aea install
aea config set agent.default_connection fetchai/oef:0.5.0
In `my_weather_client/aea-config.yaml` replace `ledger_apis: {}` with the following based on the network you want to connect. To connect to Fetchai:
ledger_apis:
  fetchai:
    network: testnet
and add
default_routing:
  fetchai/ledger_api:0.1.0: fetchai/ledger:0.1.0

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
Alternatively, create wealth for other test networks.

Ledger Config:
In `my_weather_station/aea-config.yaml` and `my_weather_client/aea-config.yaml` replace `ledger_apis: {}` with the following based on the network you want to connect. To connect to Ethereum:

ledger_apis:
  ethereum:
    address: https://ropsten.infura.io/v3/f00f7b3ba0e848ddbdc8941c527447fe
    chain_id: 3
    gas_price: 50
Alternatively, to connect to Cosmos:
ledger_apis:
  cosmos:
    address: https://rest-agent-land.prod.fetch-ai.com:443
Wealth:
To generate and add a private-public key pair for Ethereum use:
aea generate-key ethereum
aea add-key ethereum eth_private_key.txt
On the Ethereum `ropsten` network.
aea generate-wealth ethereum
Alternatively, to generate and add a private-public key pair for Cosmos use:
aea generate-key cosmos
aea add-key cosmos cosmos_private_key.txt
On the Cosmos `testnet` network.
aea generate-wealth cosmos

Update the skill configs

The default skill configs assume that the transaction is settled against the fetchai ledger.

Alternatively, configure skills for other test networks.

Weather station:
Ensure you are in the weather station project directory. For ethereum, update the skill config of the weather station via the `aea config get/set` command like so:

aea config set vendor.fetchai.skills.weather_station.models.strategy.args.currency_id ETH
aea config set vendor.fetchai.skills.weather_station.models.strategy.args.ledger_id ethereum
Or for cosmos, like so:
aea config set vendor.fetchai.skills.weather_station.models.strategy.args.currency_id ATOM
aea config set vendor.fetchai.skills.weather_station.models.strategy.args.ledger_id cosmos
This updates the weather station skill config (`my_weather_station/vendor/fetchai/skills/weather_station/skill.yaml`). Weather client:
Ensure you are in the weather client project directory. For ethereum, update the skill config of the weather client via the `aea config get/set` command like so:
aea config set vendor.fetchai.skills.weather_client.models.strategy.args.currency_id ETH
aea config set vendor.fetchai.skills.weather_client.models.strategy.args.ledger_id ethereum
Or for cosmos, like so:
aea config set vendor.fetchai.skills.weather_client.models.strategy.args.currency_id ATOM
aea config set vendor.fetchai.skills.weather_client.models.strategy.args.ledger_id cosmos
This updates the weather client skill config (`my_weather_client/vendor/fetchai/skills/weather_client/skill.yaml`).

Run the AEAs

Run both AEAs from their respective terminals.

aea run

You will see that the AEAs negotiate and then transact using the selected ledger.

Delete the AEAs

When you're done, go up a level and delete the AEAs.

cd ..
aea delete my_weather_station
aea delete my_weather_client