The AEA erc1155_deploy and erc1155_client skills demonstrate an interaction between two AEAs with the usage of a smart contract.

  • The erc1155_deploy skill deploys the smart contract, creates and mints items.
  • The erc1155_client skill signs a transaction to complete a trustless trade with the counterparty.

Preparation instructions


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


The scope of the specific demo is to demonstrate how to deploy a smart contract and interact with it. For the specific use-case, we create two AEAs one that deploys and creates tokens inside the smart contract and the other that signs a transaction so we can complete an atomic swap. The smart contract we are using is an ERC1155 smart contract with a one-step atomic swap functionality. That means the trade between the two AEAs can be trustless.


This demo serves demonstrative purposes only. Since the AEA deploying the contract also has the ability to mint tokens, in reality the transfer of tokens from the AEA signing the transaction is worthless.

Launch an OEF node

In a separate terminal, launch a local OEF node (for search and discovery).

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

Keep it running for all the following demos.


Create the deployer AEA

Create the AEA that will deploy the contract.

aea create erc1155_deployer
cd erc1155_deployer
aea add connection fetchai/oef:0.3.0
aea add skill fetchai/erc1155_deploy:0.4.0
aea install
aea config set agent.default_connection fetchai/oef:0.3.0

Additionally, create the private key for the deployer AEA. Generate and add a key for Ethereum use:

aea generate-key ethereum
aea add-key ethereum eth_private_key.txt

Create the client AEA

In another terminal, create the AEA that will sign the transaction.

aea create erc1155_client
cd erc1155_client
aea add connection fetchai/oef:0.3.0
aea add skill fetchai/erc1155_client:0.3.0
aea install
aea config set agent.default_connection fetchai/oef:0.3.0

Additionally, create the private key for the client AEA. Generate and add a key for Ethereum use:

aea generate-key ethereum
aea add-key ethereum eth_private_key.txt

Update the AEA configs

Both in my_erc1155_deploy/aea-config.yaml and my_erc1155_client/aea-config.yaml, replace ledger_apis: {} with the following based on the network you want to connect

Connect to Ethereum:

    chain_id: 3
    gas_price: 50
And change the default ledger:
aea config set agent.default_ledger ethereum

Fund the AEAs

To create some wealth for your AEAs for the Ethereum ropsten network. Note that this needs to be executed from each AEA folder:

aea generate-wealth ethereum

To check the wealth use (after some time for the wealth creation to be mined on Ropsten):

aea get-wealth ethereum


If no wealth appears after a while, then try funding the private key directly using a web faucet.

Run the AEAs

First, run the deployer AEA.

aea run --connections fetchai/oef:0.3.0

It will perform the following steps: - deploy the smart contract - create a batch of items in the smart contract - mint a batch of itemsin the smart contract

At some point you should see the log output:

Successfully minted items. Transaction digest: ...

Then, in the separate terminal run the client AEA.

aea run --connections fetchai/oef:0.3.0

You will see that upon discovery the two AEAs exchange information about the transaction and the client at the end signs and sends the signature to the deployer AEA to send it to the network.


Transactions on Ropsten can take a significant amount of time! If you run the example a second time, and the previous transaction is still pending, it can lead to a failure. The warning message `Cannot verify whether transaction improves utility. Assuming it does!` can be ignored.

Delete the AEAs

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

cd ..
aea delete erc1155_deployer
aea delete erc1155_client


This diagram shows the communication between the various entities as data is successfully trustless trade.

sequenceDiagram participant Search participant Erc1155_contract participant Client_AEA participant Deployer_AEA participant Blockchain activate Deployer_AEA activate Search activate Client_AEA activate Erc1155_contract activate Blockchain Deployer_AEA->>Blockchain: deployes smart contract Deployer_AEA->>ERC1155_contract: creates tokens Deployer_AEA->>ERC1155_contract: mint tokens Deployer_AEA->>Search: register_service Client_AEA->>Search: search Search-->>Client_AEA: list_of_agents Client_AEA->>Deployer_AEA: call_for_proposal Deployer_AEA->>Client_AEA: inform_message Client_AEA->>Deployer_AEA: signature Deployer_AEA->>Blockchain: send_transaction Client_AEA->>ERC1155_contract: asks_balance deactivate Deployer_AEA deactivate Search deactivate Client_AEA deactivate ERC1155_contract deactivate Blockchain