1010
1111** Template for quickly getting started with developing WAVS Rust applications**
1212
13- Continuous Integration is already set up to test both your Rust and Solidity
14- code, as well as ensure formatting and that your Rust bindings match the
15- Solidity build artifacts.
13+ A comprehensive template for developing WAVS (WebAssembly AVS) applications using Rust and Solidity. This template provides a pre-configured development environment with integrated testing frameworks for both Rust and Solidity components.
1614
17- <!-- ## Directory Structure
15+ ## Installation
1816
19- The project is structured as a mixed Rust workspace with a Foundry project under
20- `contracts/` and typesafe auto-generated bindings to the contracts under
21- `crates/bindings/`.
22-
23- ```
24- ├── Cargo.toml
25- ├── app // <-- Your Rust application logic
26- ├── crates
27- └── bindings // <-- Generated bindings to the smart contracts' abis (like Typechain)
28- ``` -->
29-
30- ## Install
17+ Create a new project using this template:
3118
3219``` bash
3320forge init --template https://github.com/Lay3rLabs/wavs-foundry-template my-wavs
@@ -38,19 +25,21 @@ forge init --template https://github.com/Lay3rLabs/wavs-foundry-template my-wavs
3825Given the repository contains both Solidity and Rust code, there's 2 different
3926workflows.
4027
41- ### Solidity
42-
43- Forge is using submodules to manage dependencies. Initialize the dependencies:
28+ ### Setting up the Environment
4429
45- If you are in the root directory of the project, run :
30+ Initialize the submodule dependencies :
4631
4732``` bash
4833forge install
4934```
5035
51- Then, run the tests:
36+ Build the contracts:
37+
38+ ``` bash
39+ forge build
40+ ```
5241
53- If you are in the root directory of the project, run :
42+ Run the tests :
5443
5544``` bash
5645forge test
@@ -61,12 +50,7 @@ forge test
6150Rust bindings to the contracts can be generated via ` forge bind ` , which requires
6251first building your contracts:
6352
64- <!-- Any follow-on calls to `forge bind` will check that the generated bindings match
65- the ones under the build files. If you want to re-generate your bindings, pass
66- the `--overwrite` flag to your `forge bind` command. -->
67-
6853``` bash
69- forge build
7054make bindings
7155```
7256
@@ -76,77 +60,65 @@ Then, you can run the tests:
7660cargo test
7761```
7862
79- ## WAVS Operations
63+ ## WAVS
64+
65+ Build the latest solidity:
8066
8167``` bash
8268forge build
8369```
8470
85- Run the following in the WAVS repo (separate terminal)
71+ Install the WAVS CLI:
72+
8673``` bash
87- # this is based on ebf8cf6bc001d8292696ef6883d55d749c41bdd9 in the WAVS repo
88- docker compose up # <- in the WAVS repository
74+ (cd lib/WAVS; cargo install --path ./packages/cli)
8975```
9076
91- Upload ServiceManager from this repo
92-
9377``` bash
94- export CLI_EIGEN_CORE_DELEGATION_MANAGER=` docker exec -it wavs bash -c ' jq -r .eigen_core.local.delegation_manager ~/wavs/cli/deployments.json' | tr -d ' \r' `
95- export CLI_EIGEN_CORE_REWARDS_COORDINATOR=` docker exec -it wavs bash -c ' jq -r .eigen_core.local.rewards_coordinator ~/wavs/cli/deployments.json' | tr -d ' \r' `
96- export CLI_EIGEN_CORE_AVS_DIRECTORY=` docker exec -it wavs bash -c ' jq -r .eigen_core.local.avs_directory ~/wavs/cli/deployments.json' | tr -d ' \r' `
97- export FOUNDRY_ANVIL_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
78+ cp .env.example .env
9879
99- forge script ./script/WavsServiceManager.s.sol --rpc-url http://localhost:8545 --broadcast
100- ```
101-
102- Build WAVS WASI component
80+ # [!] Get your key from: https://openweathermap.org/
81+ # Update the WAVS_ENV_OPEN_WEATHER_API_KEY in the .env file with your key`
10382
104- ``` bash
105- (cd components/eth-trigger-echo ; cargo component build --release)
83+ cp ./lib/WAVS/packages/wavs/wavs.toml .
84+ cp ./lib/WAVS/packages/cli/wavs-cli.toml .
10685
107- mkdir -p ./compiled && cp ./target/wasm32-wasip1/release/* .wasm ./compiled/
86+ # start the WAVS network
87+ docker compose up
10888```
10989
110- Verify
90+ Deploy Eigenlayer and upload your WAVS Service contract
11191
11292``` bash
113- # install wavs-cli
114- # https://github.com/Lay3rLabs/WAVS/issues/277
115- # - right now `E0308` is super annoying @ packages/wavs/src/submission/core.rs:426:13 ^ have to do a `result: result.into(),` for now.
116- (cd lib/WAVS; cargo install --path ./packages/cli)
117-
118- cp ./lib/WAVS/packages/cli/wavs-cli.toml .
93+ docker_cmd=" docker exec -it wavs bash -c"
94+ export CLI_EIGEN_CORE_DELEGATION_MANAGER=` ${docker_cmd} ' jq -r .eigen_core.local.delegation_manager ~/wavs/cli/deployments.json' | tr -d ' \r' `
95+ export CLI_EIGEN_CORE_REWARDS_COORDINATOR=` ${docker_cmd} ' jq -r .eigen_core.local.rewards_coordinator ~/wavs/cli/deployments.json' | tr -d ' \r' `
96+ export CLI_EIGEN_CORE_AVS_DIRECTORY=` ${docker_cmd} ' jq -r .eigen_core.local.avs_directory ~/wavs/cli/deployments.json' | tr -d ' \r' `
97+ export FOUNDRY_ANVIL_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
11998
120- # Local Exec
121- # ./compiled/eth_trigger_echo.wasm does not work because it's relative in `read_component(path: impl AsRef<Path>) -> Vec<u8> ... Path::new("../../")`
122- wavs-cli exec --component $( pwd) /compiled/eth_trigger_echo.wasm --input testing
99+ forge script ./script/WavsServiceManager.s.sol --rpc-url http://localhost:8545 --broadcast
100+ ```
123101
124- # use the Eigenlayer deployed contracts
125- mkdir -p .docker; docker cp wavs:/root/wavs/cli/deployments.json .docker/deployments.json
102+ Build WAVS WASI component(s)
126103
127- # Actual deploy
128- # - Service manager is from the script/WavsServiceManager.s.sol broadcast logs
129- export WAVS_CLI_ETH_MNEMONIC=" test test test test test test test test test test test junk"
130- wavs-cli deploy-service --component $( pwd) /compiled/eth_trigger_echo.wasm --service-manager 0x851356ae760d987E095750cCeb3bC6014560891C --data ./.docker
104+ ``` bash
105+ # build all components/*
106+ make wasi-build
131107
132- wavs-cli add-task --input " hello testing!" --data ./.docker --service-id < Service-ID>
108+ # Verify execution works as expected without deploying
109+ wavs-cli exec --component $( pwd) /compiled/eth_trigger_weather.wasm --input Nashville,TN
133110```
134111
112+ Deploy service and verify with adding a task
135113
136- ## Installing Foundry
137-
138- First run the command below to get ` foundryup ` , the Foundry toolchain installer:
114+ ``` bash
115+ source .env
139116
140- ``` sh
141- curl -L https://foundry.paradigm.xyz | bash
142- ```
117+ sudo chmod 0666 .docker/cli/deployments.json
143118
144- Then, in a new terminal session or after reloading your ` PATH ` , run it to get
145- the latest ` forge ` and ` cast ` binaries:
119+ wavs-cli deploy-service --data ./.docker/cli --component $( pwd) /compiled/eth_trigger_weather.wasm \
120+ --service-manager 0x851356ae760d987E095750cCeb3bC6014560891C \
121+ --service-config ' {"fuelLimit":100000000,"maxGas":5000000,"hostEnvs":["WAVS_ENV_OPEN_WEATHER_API_KEY"],"kv":[]}'
146122
147- ``` sh
148- foundryup
123+ wavs-cli add-task --input " Nashville,TN" --data ./.docker/cli --service-id < Service-ID>
149124```
150-
151- For more, see the official
152- [ docs] ( https://github.com/gakonst/foundry#installation ) .
0 commit comments