### Install Rust using rustup Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Downloads and executes the official rustup installer script using curl to install the Rust programming language. This is the recommended way to get Rust.
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
--------------------------------
### Install Docker Networking Helper on MacOS Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Installs the 'docker-mac-net-connect' helper tool using Homebrew and starts its service. This provides an alternative or supplementary method for enabling host networking for Docker on macOS.
```bash
brew install chipmk/tap/docker-mac-net-connect && sudo brew services start chipmk/tap/docker-mac-net-connect
```
--------------------------------
### Install Cargo Component Tools Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Installs 'cargo-binstall' for binary installations, then uses it to install 'cargo-component', 'warg-cli', and 'wkg' with specific flags. Finally, it configures the default registry for 'wkg' to 'wa.dev'. These tools are essential for building WebAssembly components.
```bash
cargo install cargo-binstall
cargo binstall cargo-component warg-cli wkg --locked --no-confirm --force
wkg config --default-registry wa.dev
```
--------------------------------
### Install Foundryup Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Downloads and runs the official Foundry installer script using curl. Foundryup is the toolchain manager for the Foundry Solidity development suite.
```bash
curl -L https://foundry.paradigm.xyz | bash
```
--------------------------------
### Install JQ on Linux Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Installs the JQ command-line JSON processor using the APT package manager on Linux systems. Requires superuser privileges.
```bash
sudo apt -y install jq
```
--------------------------------
### Install Make on Linux Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Installs the GNU Make build automation tool using the APT package manager on Linux systems. Requires superuser privileges.
```bash
sudo apt -y install make
```
--------------------------------
### Install JQ on MacOS Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Installs the JQ command-line JSON processor on macOS using the Homebrew package manager. Requires Homebrew to be installed.
```bash
brew install jq
```
--------------------------------
### Start Local Environment Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/README.md
Copies the example environment file and starts the local development environment including an Ethereum node (anvil), the WAVS service, and deployed Eigenlayer contracts via docker-compose.
```Bash
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
```
--------------------------------
### Run Foundryup to Install Foundry Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Executes the 'foundryup' command to install the Foundry toolchain, which includes Anvil, Forge, Cast, and Chisel. This command should be run after installing Foundryup.
```bash
foundryup
```
--------------------------------
### Install Rust Toolchain and WASM Target Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Installs the latest stable Rust toolchain and adds the required 'wasm32-wasip2' target for building WebAssembly components. This step is necessary after a fresh installation of Rust.
```bash
rustup toolchain install stable
rustup target add wasm32-wasip2
```
--------------------------------
### Install Make on MacOS Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Installs the GNU Make build automation tool on macOS using the Homebrew package manager. Requires Homebrew to be installed.
```bash
brew install make
```
--------------------------------
### Install Docker and Compose on Linux Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Installs the Docker engine ('docker.io') and Docker Compose v2 ('docker-compose-v2') using the APT package manager on Linux systems. Requires superuser privileges.
```bash
sudo apt -y install docker.io
sudo apt-get install docker-compose-v2
```
--------------------------------
### Install Docker on MacOS Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Installs Docker Desktop on macOS using the Homebrew package manager with the '--cask' option. Requires Homebrew to be installed on the system.
```bash
brew install --cask docker
```
--------------------------------
### Setup Project Dependencies Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/README.md
Installs project dependencies defined in package.json (via npm) and initializes git submodules.
```Bash
# Install packages (npm & submodules)
make setup
```
--------------------------------
### Installing Wavs Development Tools (Bash)
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/5-build.mdx
Installs essential Rust tools (`cargo-binstall`, `cargo-component`, `warg-cli`, `wkg`) required for building and interacting with Wavs components using `cargo binstall`. It also configures the default `wkg` registry to `wa.dev`. This step requires Rust and Cargo to be installed on the system.
```bash
cargo install cargo-binstall
cargo binstall cargo-component warg-cli wkg --locked --no-confirm --force
# Configure default registry
wkg config --default-registry wa.dev
```
--------------------------------
### Building and Testing Contracts with Makefile and Forge (Bash)
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/3-project.mdx
Runs a sequence of commands to prepare, build, and test the smart contracts within the project. It first executes `make setup` for dependencies, then `forge build` to compile, and finally `forge test` to run the Foundry tests.
```bash
make setup
# Build the contracts
forge build
# Run the solidity tests.
forge test
```
--------------------------------
### Install Rust Toolchain Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/README.md
Installs the rustup toolchain manager, adds the stable toolchain, and includes the wasm32-wasip2 target required for building WASI components.
```Bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup toolchain install stable
rustup target add wasm32-wasip2
```
--------------------------------
### Copying Environment File (Bash)
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/6-run-service.mdx
Creates a local `.env` configuration file for the project by copying the provided example file. This file is used to define environment variables required for subsequent setup and execution steps.
```bash
cp .env.example .env
```
--------------------------------
### Initializing WAVS Foundry Project with Forge (Bash)
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/3-project.mdx
Initializes a new project directory using the `forge init` command, specifying the `Lay3rLabs/wavs-foundry-template` and checking out the `0.3` branch. This command requires Foundry (forge) to be installed and accessible in your terminal.
```bash
forge init --template Lay3rLabs/wavs-foundry-template my-wavs --branch 0.3
```
--------------------------------
### Upgrade Rust and Update WASM Target Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/2-setup.mdx
Removes old WASI targets if present, updates Rust to the latest stable version, and adds the required 'wasm32-wasip2' target. Use these commands to upgrade an existing Rust installation.
```bash
rustup target remove wasm32-wasi || true
rustup target remove wasm32-wasip1 || true
rustup update stable
rustup target add wasm32-wasip2
```
--------------------------------
### Starting Development Services (Bash/Makefile)
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/tutorial/6-run-service.mdx
Executes a Makefile target to simultaneously start the local Anvil test blockchain, the WAVS runtime environment, and deploy the core EigenLayer contracts necessary for the service. This command should be kept running in a dedicated terminal.
```bash
make start-all
```
--------------------------------
### Create Foundry Project Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/README.md
Initializes a new Foundry project based on the specified WAVS template repository and branch name. Requires Foundry to be installed.
```Bash
# 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
```
--------------------------------
### Install Cargo Components & Config Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/README.md
Installs necessary Rust cargo subcommands and tools (`cargo-component`, `warg-cli`, `wkg`) for working with WebAssembly components and configures the default warg registry.
```Bash
# 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
```
--------------------------------
### Listing Template Directory Structure Bash
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/custom-components.mdx
Displays the standard directory layout of the `wavs-foundry-template` project, highlighting the location of core components, contracts, scripts, and configuration files to guide developers through the project structure.
```Bash
wavs-foundry-template/
├── README.md
├── makefile # Commands, variables, and configs
├── components/ # WASI components
│ └── eth-price-oracle/
│ ├── Cargo.toml # Component dependencies
│ ├── lib.rs # Main Component logic
│ ├── trigger.rs # Trigger handling
│ └── bindings.rs # Bindings generated by `make build`
├── compiled/ # WASM files compiled by `make build`
├── src/
│ ├── contracts/ # Trigger and submission contracts
│ └── interfaces/ # Solidity interfaces
├── script/ # Scripts used in makefile commands
├── cli.toml # CLI configuration
├── wavs.toml # WAVS service configuration
├── docs/ # Documentation
└── .env # Private environment variables
```
--------------------------------
### Example WAVS Component Implementation Rust
Source: https://github.com/lay3rlabs/wavs-foundry-template/blob/0.3/docs/custom-components.mdx
Presents a Rust example for implementing a WAVS WASI component. It demonstrates decoding an Ethereum log trigger using `decode_event_log_data!`, performing placeholder business logic, and encoding a structured result using `abi_encode()` for potential onchain submission. Requires `wavs-wasi-chain` and `alloy_sol_types` dependencies.
```Rust
#[allow(warnings)]
mod bindings;
use alloy_sol_types::{sol, SolValue};
use bindings::{export, wavs::worker::layer_types::{TriggerData, TriggerDataEthContractEvent}, Guest, TriggerAction};
use wavs_wasi_chain::decode_event_log_data;
// Solidity types for the incoming trigger event using the `sol!` macro
sol! {
event MyEvent(uint64 indexed triggerId, bytes data);
struct MyResult {
uint64 triggerId;
bool success;
}
}
// Define the component
struct Component;
export!(Component with_types_in bindings);
impl Guest for Component {
fn run(action: TriggerAction) -> Result