An Olas agent that makes transactions on the Celo network.
- Python
>=3.10
- Tendermint
==0.34.19
- IPFS node
==0.6.0
- Pip
- Poetry
- Docker Engine
- Docker Compose
- Set Docker permissions so you can run containers as non-root user
Alternatively, you can fetch this docker image with the relevant requirements satisfied:
NOTE: Tendermint and IPFS dependencies are missing from the image at the moment.
docker pull valory/open-autonomy-user:latest
docker container run -it valory/open-autonomy-user:latest
-
Clone this repo:
git clone git@github.com:valory-xyz/celo-trader.git
-
Create the virtual environment:
cd celo-trader poetry shell poetry install
-
Sync packages:
autonomy packages sync --update-packages
-
Prepare a keys.json file containing wallet address and the private key for each of the agents. To create this file, either generate a new one with
autonomy generate-key ethereum -n 1
or export a existing one using Metamask and follow the following format:[ { "address": "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65", "private_key": "0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a" } ]
-
Deploy a Safe on Celo and set your agent address as one of the signers.
-
Fund both your agent and Safe with a small amount of CELO, i.e. $0.05 each.
-
Make a copy of the env file:
cp sample.env .env
-
Fill in the required environment variables in .env. You'll need a Ethereum RPC even if the service runs on Celo. These variables are:
ALL_PARTICIPANTS
,ETHEREUM_LEDGER_RPC
andSAFE_CONTRACT_ADDRESS
. You can also modifyMAX_TRANSFER_VALUE_WEI
, which is a security measure to set the max amount of wei the agent should be able to send. This is a stopgap solution for hypothetical situations where the LLM malfunctions and specifies big transfer values. -
Check that Docker is running:
docker
-
Run the service:
bash run_service.sh
-
Look at the service logs (on another terminal):
docker logs -f celotrader_abci_0
-
Make a transfer request, for example to a specific address (use your own destination address):
curl -X POST http://localhost:8000/request -H "Content-Type: application/json" -d '{"prompt":"Transfer 1 wei to 0x8D7102ce2d35a409535285252599c149FBeABB73"}'
To extend agents, it is useful to first understand their architecture and the development process.
After you feel comfortable with running agents and their architecture, think about a useful addition or modification for the Celo Trader. For example: modify the agent and the mech tool to perform swaps. The high level steps would be:
-
Using the prepare_tx mech tool as template, create a new mech tool that prepares a swap transaction given a pair of tokens and the amount to swap.
-
Configure your TOOL env so the agent uses your new tool
-
Modify the agent's process_next_mech_response method in order to get the correct data from the new tool.
-
Update the transaction preparation on the agent so, instead of a simple transfer, it uses the data received in the previous step to make a call to Uniswap. Here's an example on how to make a contract call. Since agents communicate with contracts through the contract_api, you will need to create a contract package (essentially a contract wrapper) for Uniswap that implements a single method to swap. Here's a contract method for reference.
The trader agent might be a good example to understand how to make transactions using an agent. There's a easy to follow quickstart for this agent that anyone can use to run the trader.