A demo where an AVS uses an AI agent to propose transactions to a Safe.
TODO:
- Need to more reliably parse output from agent
- Safe module could have some extra safety features like permissions (should be deployed with a guard)
Reading and Resources:
- Zodiac: a bunch of useful extensions to the Safe. If you're looking for examples of extending Safe, Zodiac has a ton of them.
- Safe Modules: documentation on Safe Modules, allowing easily extending functionality of a Safe.
- Safe Guard: documentation on Safe Guards, allowing for checks on Safe transactions.
Install
cargo install cargo-component --locked
if you have not already.
# Install initial dependencies.
make setup
# Build the contracts and WASI components.
make build
# Run the tests.
make test
On MacOS Docker, ensure you've either enabled host networking (Docker Engine -> Settings -> Resources -> Network -> 'Enable Host Networking') or installed docker-mac-net-connect via
brew install chipmk/tap/docker-mac-net-connect && sudo brew services start chipmk/tap/docker-mac-net-connect
.
# Copy over the .env file.
cp .env.example .env
# Start all services.
make start-all
The
start-all
command must remain running in your terminal. Use another terminal to run other commands.You can stop the services with
ctrl+c
(you may have to press it twice).
forge script script/SafeAIModule.s.sol:DeploySafeAIModule --rpc-url http://localhost:8545 --broadcast
# Load the created addresses into the environment
export WAVS_SAFE_MODULE=$(cat .env | grep WAVS_SAFE_MODULE | tail -1 | cut -d '=' -f 2)
# fish shell:
# set -gx WAVS_SAFE_MODULE (cat .env | grep WAVS_SAFE_MODULE | tail -1 | cut -d '=' -f 2)
COMPONENT_FILENAME=dao_agent.wasm SERVICE_TRIGGER_ADDR=$WAVS_SAFE_MODULE SERVICE_SUBMISSION_ADDR=$WAVS_SAFE_MODULE make deploy-service
forge script script/SafeAIModule.s.sol:AddTrigger --sig "run(string)" "We should donate 1 ETH to 0xDf3679681B87fAE75CE185e4f01d98b64Ddb64a3." --rpc-url http://localhost:8545 --broadcast
forge script script/SafeAIModule.s.sol:ViewBalance --rpc-url http://localhost:8545
Notice that the balance now contains the 1 ETH donation. If you don't see anything, watch the Anvil and WAVS logs during the trigger creation above to make sure the transaction is succeeding.