WAVS Example Apps
Templates for getting started with developing WAVS applications
The ETH Price Oracle is a simple oracle service that fetches the current price of Ethereum from CoinMarketCap and saves it on chain.
The Sports Scores Oracle is a simple oracle service that fetches the current scores of basketball games from SportRadar and saves it on chain.
Prompt to recreate this component available here.
The OpenAI Inference is a simple oracle service that fetches the current inference of OpenAI from OpenAI and saves it on chain.
Prompt to recreate this component available here.
Core (Docker, Compose, Make, JQ, Node v21+)
- MacOS:
brew install --cask docker
- Linux:
sudo apt -y install docker.io
- Windows WSL: docker desktop wsl &
sudo chmod 666 /var/run/docker.sock
- Docker Documentation
- MacOS: Already installed with Docker installer
- Linux + Windows WSL:
sudo apt-get install docker-compose-v2
- Compose Documentation
- MacOS:
brew install make
- Linux + Windows WSL:
sudo apt -y install make
- Make Documentation
- MacOS:
brew install jq
- Linux + Windows WSL:
sudo apt -y install jq
- JQ Documentation
- Required Version: v21+
- Installation via NVM
Rust v1.84+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup toolchain install stable
rustup target add wasm32-wasip2
# Remove old targets if present
rustup target remove wasm32-wasi || true
rustup target remove wasm32-wasip1 || true
# Update and add required target
rustup update stable
rustup target add wasm32-wasip2
Cargo Components
# Install required cargo components
# https://github.com/bytecodealliance/cargo-component#installation
cargo install cargo-binstall
cargo binstall cargo-component warg-cli wkg --locked --no-confirm --force
# Configure default registry
wkg config --default-registry wa.dev
# If you don't have foundry: `curl -L https://foundry.paradigm.xyz | bash && $HOME/.foundry/bin/foundryup`
forge init --template Lay3rLabs/wavs-foundry-template my-wavs --branch 0.3
Tip
Run make help
to see all available commands and environment variable overrides.
Install the required packages to build the Solidity contracts. This project supports both submodules and npm packages.
# Install packages (npm & submodules)
make setup
# Build the contracts
forge build
# Run the solidity tests
forge test
Now build the WASI rust components into the compiled
output directory.
Warning
If you get: error: no registry configured for namespace "wavs"
run, wkg config --default-registry wa.dev
Warning
If you get: failed to find the 'wasm32-wasip1' target and 'rustup' is not available
brew uninstall rust
& install it from https://rustup.rs
make wasi-build # or `make build` to include solidity compilation.
Test run the component locally to validate the business logic works. Nothing will be saved on-chain, just the output of the component is shown.
An ID of 1 is Bitcoin.
COIN_MARKET_CAP_ID=1 make wasi-exec
Fetch basketball scores from SportRadar API.
# Replace with your actual API key in the Makefile
# SPORTRADAR_API_KEY=your_api_key_here
# Call with a game ID
make scores-exec GAME_ID="fa15684d-0966-46e7-a3f8-f1d378692109"
Note
If you are running on a Mac with an ARM chip, you will need to do the following:
- Set up Rosetta:
softwareupdate --install-rosetta
- Enable Rosetta (Docker Desktop: Settings -> General -> enable "Use Rosetta for x86_64/amd64 emulation on Apple Silicon")
Configure one of the following networking:
- Docker Desktop: Settings -> Resources -> Network -> 'Enable Host Networking'
brew install chipmk/tap/docker-mac-net-connect && sudo brew services start chipmk/tap/docker-mac-net-connect
Start an ethereum node (anvil), the WAVS service, and deploy eigenlayer contracts to the local network.
cp .env.example .env
# Start the backend
#
# This must remain running in your terminal. Use another terminal to run other commands.
# You can stop the services with `ctrl+c`. Some MacOS terminals require pressing it twice.
make start-all
Upload your service's trigger and submission contracts. The trigger contract is where WAVS will watch for events, and the submission contract is where the AVS service operator will submit the result on chain.
export SERVICE_MANAGER_ADDR=`make get-eigen-service-manager-from-deploy`
forge script ./script/Deploy.s.sol ${SERVICE_MANAGER_ADDR} --sig "run(string)" --rpc-url http://localhost:8545 --broadcast
Tip
You can see the deployed trigger address with make get-trigger-from-deploy
and the deployed submission address with make get-service-handler-from-deploy
Deploy the compiled component with the contracts from the previous steps. Review the makefile for more details and configuration options.TRIGGER_EVENT
is the event that the trigger contract emits and WAVS watches for. By altering SERVICE_TRIGGER_ADDR
you can watch events for contracts others have deployed.
TRIGGER_EVENT="NewTrigger(bytes)" make deploy-service
Anyone can now call the trigger contract which emits the trigger event WAVS is watching for from the previous step. WAVS then calls the service and saves the result on-chain.
export COIN_MARKET_CAP_ID=1
export SERVICE_TRIGGER_ADDR=`make get-trigger-from-deploy`
forge script ./script/Trigger.s.sol ${SERVICE_TRIGGER_ADDR} ${COIN_MARKET_CAP_ID} --sig "run(string,string)" --rpc-url http://localhost:8545 --broadcast -v 4
Query the latest submission contract id from the previous request made.
# Get the latest TriggerId and show the result via `script/ShowResult.s.sol`
make show-result