Echo Demo
This is a simple demo that introduces you to the main components of an AEA.
A full break down of the development is covered within the Development Quickstart. It is highly recommended that developers begin by following the quick start!
This demo assumes you have followed the setup guide.
The fastest way to have your first AEA is to fetch one that already exists!
aea fetch open_aea/my_first_aea:0.1.0:bafybeiaf6fgfmljz6pl7q6zfs3lhqmqbzydlqcen3qek5jjly77vhjowra --remote
cd my_first_aea
Install AEA dependencies
aea install
Add and create a private key
All AEAs need a private key to run. Add one now:
aea generate-key ethereum
aea add-key ethereum
Run the AEA
Run the AEA.
aea run
You will see the echo skill running in the terminal window (an output similar to the one below).
_ _____ _
/ \ | ____| / \
/ _ \ | _| / _ \
/ ___ \ | |___ / ___ \
/_/ \_\|_____|/_/ \_\
v1.2.0
Starting AEA 'my_first_aea' in 'async' mode ...
info: Echo Handler: setup method called.
info: Echo Behaviour: setup method called.
info: [my_first_aea]: Start processing messages...
info: Echo Behaviour: act method called.
info: Echo Behaviour: act method called.
info: Echo Behaviour: act method called.
...
Interact with the AEA
From a different terminal and same directory (i.e. the my_first_aea
project), you can send the AEA a message wrapped in an envelope via the input file.
echo 'my_first_aea,sender_aea,fetchai/default:1.0.0,\x12\x10\x08\x01\x12\x011*\t*\x07\n\x05hello,' >> input_file
You will see the Echo Handler
dealing with the envelope and responding with the same message to the output_file
, and also decoding the Base64 encrypted message in this case.
info: Echo Behaviour: act method called.
Echo Handler: message=Message(sender=sender_aea,to=my_first_aea,content=b'hello',dialogue_reference=('1', ''),message_id=1,performative=bytes,target=0), sender=sender_aea
info: Echo Behaviour: act method called.
info: Echo Behaviour: act method called.
Note, due to the dialogue reference having to be incremented, you can only send the above envelope once!
Stop the AEA
You can stop an AEA by pressing CTRL C
.
Once you do, you should see the AEA being interrupted and then calling the teardown()
methods:
info: Echo Behaviour: act method called.
info: Echo Behaviour: act method called.
^C my_first_aea interrupted!
my_first_aea stopping ...
info: Echo Handler: teardown method called.
info: Echo Behaviour: teardown method called.
To learn more about the folder structure of an AEA project read on here.
A full break down of the development is covered within the Development Quickstart. It is highly recommended that developers begin by following the quick start!