Skip to content

Commit fcdf558

Browse files
committed
sync
1 parent d4be288 commit fcdf558

26 files changed

+2073
-444
lines changed

content/docs/benefits.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: WAVS benefits
3+
description: Key advantages and use cases of WAVS platform
34
---
45
import { Callout } from 'fumadocs-ui/components/callout';
56
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
@@ -23,7 +24,7 @@ WAVS redefines the AVS paradigm, making AVSs easier to build, less expensive to
2324
- WASI components have instantaneous initialization vs. Docker's redundant OS layers and slower boot times.
2425
2. Simplified Development
2526
- Focus on your application logic, not overhead:
26-
- With templates, theres no need to write multiple custom contracts to parse events or aggregate signatures.
27+
- With templates, there's no need to write multiple custom contracts to parse events or aggregate signatures.
2728
- WAVS handles common AVS infrastructure, leaving AVS developers to focus on their core logic.
2829
3. Multichain Ready
2930
- WAVS is built to operate across multiple blockchain environments and will be released with support for EVM networks.

content/docs/design.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: WAVS design considerations
3+
description: Best practices and design patterns for WAVS services
34
---
45
import { Callout } from 'fumadocs-ui/components/callout';
56
import { DocsPage } from 'fumadocs-ui/page';
@@ -10,12 +11,13 @@ WAVS works best with the "serverless function" approach, wherein the priority of
1011

1112
## Aggregation and deterministic queries
1213

13-
WAVS currently supports "exact match" [aggregation](./how-it-works#signing-and-aggregation), meaning that consensus is reached if 2/3 of submitted responses from operators are identical. This approach fits many common use cases, but it means that developers must build their components to receive and process data only from deterministic or immutable sources, such as:
14+
WAVS currently supports "exact match" [aggregation](./handbook/submission#aggregator), meaning that consensus is reached if a threshold amount of submitted responses from operators are identical. This approach fits many common use cases, but it means that developers must build their components to receive and process data only from deterministic or immutable sources, such as:
1415

1516
- Data from the input event trigger
1617
- Ethereum queries at a given block height
1718
- IPFS data or other Content-Addressable Storage
1819
- Web2 APIs that are trusted to return the same result on every query
20+
- Seeded application parameters (e.g. Ollama for AI models)
1921

2022
For example, when designing a price oracle, a **blockheight** or **timestamp** should be specified in the query logic. This ensures that the query is deterministic and that the same data point is retrieved by all operators.
2123

@@ -25,7 +27,7 @@ Conversely, a component that is designed to fetch "current price" would be non-d
2527

2628
Persistent state introduces additional challenges in AVS design with WAVS: operators may execute triggers at different times or, in some cases, not run them at all if they join an AVS after it has been running for some time. Components that rely on operator-local mutable state risk failing consensus due to inconsistencies in execution. For these reasons, it is best practice to avoid storing operator-local mutable state within your components.
2729

28-
This functionality would require features such as state synchronization, guaranteed execution ordering, and Merkle-proof validation which are not yet supported.
30+
This functionality would require features such as state synchronization (P2P), guaranteed execution ordering, and Merkle-proof validation which are not yet supported.
2931

3032
## Caching
3133

content/docs/handbook/ai.mdx

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
---
2+
title: AI-powered component creation
3+
description: Use Claude or Cursor to create one-shot components with minimal prompting
4+
---
5+
import { Callout } from 'fumadocs-ui/components/callout';
6+
import { DocsPage } from 'fumadocs-ui/page';
7+
8+
9+
The WAVS Foundry Template contains built-in AI rulefiles for creating "one-shot" components with minimal prompting in Cursor or Claude Code.
10+
11+
These rulefiles are an experimental feature and may not work as expected every time. Components created with AI should not be used in production without thorough review and testing.
12+
13+
<Callout title="LLM resources" type="info">
14+
For more information on AI tools and AI-accessible documentation, visit the [LLM resources page](/resources/llms).
15+
</Callout>
16+
17+
## Claude Code
18+
19+
- Follow the [Claude Code installation instructions](https://docs.anthropic.com/en/docs/claude-code/getting-started) to install Claude Code and link your account.
20+
- The Claude rulefile is `claude.md` and contains instructions for Claude on how to create a component.
21+
- Learn more about Claude rulefiles: https://docs.anthropic.com/en/docs/claude-code/memory
22+
23+
## Cursor
24+
25+
- Download Cursor: https://www.cursor.com/downloads
26+
- The Cursor rulefiles are located in the `.cursor/rules` directory.
27+
- When using Cursor, always attach the `component-rules.mdc` file to the chat with your prompt.
28+
- Learn more about Cursor rulefiles: https://docs.cursor.com/context/rules
29+
30+
## Using AI to create components
31+
32+
1. Clone the [WAVS Foundry Template](https://github.com/Lay3rLabs/wavs-foundry-template) and follow the system setup requirements in the README.
33+
34+
```sh
35+
git clone https://github.com/Lay3rLabs/wavs-foundry-template.git
36+
cd wavs-foundry-template
37+
git checkout main
38+
# Follow the system setup requirements in the README.
39+
```
40+
41+
2. Open Claude Code or Cursor in the root of the template.
42+
43+
```sh
44+
claude
45+
# or
46+
cursor .
47+
```
48+
49+
<Callout title="Sandboxed Claude Code" type="info">
50+
51+
You can run a sandboxed instance of [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview) in a Docker container that only has access to this project's files by running the following command from the root of the project:
52+
53+
```bash docci-ignore
54+
npm run claude-code
55+
# or with no restrictions (--dangerously-skip-permissions)
56+
npm run claude-code:unrestricted
57+
```
58+
59+
</Callout>
60+
61+
3. Enter your prompt in the agent chat. You can use the following examples as a starting point, or you can create your own prompt.
62+
63+
<Callout title="Attaching rulefiles" type="warn">
64+
If you are using cursor, always attach `component-rules.mdc` file to the chat with your prompt.
65+
66+
```
67+
@component-rules.mdc <your prompt>
68+
```
69+
70+
</Callout>
71+
72+
### Prompt examples
73+
74+
These simple examples are provided to get you started.
75+
76+
#### API component
77+
78+
You can make a very simple prompt to create a component that can bring API responses verifiably onchain by including the API endpoint:
79+
80+
```
81+
Let's make a component that takes the input of a zip code, queries the openbrewerydb,
82+
and returns the breweries in the area.
83+
@https://api.openbrewerydb.org/v1/breweries?by_postal=92101&per_page=3
84+
```
85+
86+
#### Contract balance component
87+
88+
You can also make components that interact with the blockchain:
89+
90+
```
91+
I want to build a new component that takes the input of a wallet address,
92+
queries the usdt contract, and returns the balance of that address.
93+
```
94+
95+
#### Verifiable AI component
96+
97+
```
98+
Please make a component that takes a prompt as input, sends an api request to OpenAI,
99+
and returns the response.
100+
101+
Use this api structure:
102+
{
103+
"seed": $SEED,
104+
"model": "gpt-4o",
105+
"messages": [
106+
{"role": "system", "content": "You are a helpful assistant."},
107+
{"role": "user", "content": "<PROMPT>"}
108+
]
109+
}
110+
111+
My api key is WAVS_ENV_OPENAI_KEY in my .env file.
112+
```
113+
114+
You'll need an [OPENAI API account and key](https://platform.openai.com/login) to use this prompt. The agent will include your API key in the component as a [private variable](./components/variables).
115+
116+
Make sure to include your API key in a `.env` file:
117+
118+
```sh
119+
# copy the .env.example file
120+
cp .env.example .env
121+
# place your key in .env (must be prefixed with WAVS_ENV_)
122+
WAVS_ENV_OPENAI_KEY=your_api_key
123+
```
124+
125+
This example utilizes the OpenAI API with a [seed](https://platform.openai.com/docs/advanced-usage#reproducible-outputs) to make the response more deterministic. Please note that OpenAI models are not guaranteed to be 100% deterministic. This example is for demonstration purposes and should not be used in production.
126+
127+
## Component creation process
128+
129+
4. After receiving the prompt, the agent will start creating your component. Review the agent's work and accept changes carefully. Make sure to double check what the agent is doing and be safe about accepting changes.
130+
131+
5. The agent will start by planning its component and will create a `plan.md` file. The agent will then make a new component and files according to this plan.
132+
133+
6. The agent will test its component for errors by running validation tests using `make validate-component COMPONENT=your-component`.
134+
135+
7. The agent may need to make changes after running the Validation tests. After making changes, the agent will build the component using `WASI_BUILD_DIR=components/my-component make wasi-build`.
136+
137+
8. After successfully building your component, it's time to test it. The following command can be used to test your component logic without deploying WAVS. Make sure to replace the placeholders with the correct inputs.
138+
139+
```sh
140+
# Run this command to build the component:
141+
WASI_BUILD_DIR=components/openai-response make wasi-build
142+
143+
# Once built, test it with:
144+
export COMPONENT_FILENAME=openai_response.wasm
145+
export INPUT_DATA="Only respond with yes or no: Is AI beneficial to the world?"
146+
make wasi-exec
147+
```
148+
149+
The agent may try to run the `make wasi-exec` command themselves. You should prompt the agent to give you the command instead, as it can't run the command without permissions.
150+
151+
152+
9. Your component should execute and return a response. If there are any errors, share them with the agent for troubleshooting.
153+
154+
If you have any questions, join the WAVS DEVS Telegram channel: https://t.me/layer_xyz/818
155+
156+
## Tips for working with AI agents
157+
158+
- While this repo contains rulefiles with enough context for creating simple components, coding agents are unpredictable and may inevitably run into problems.
159+
- Feel free to update the rulefiles for your specific purposes or if you run into regular errors.
160+
- Coding agents can sometimes try to over-engineer their fixes for errors. If you feel it is not being productive, it may be beneficial to start fresh. You may need to adjust your prompt.
161+
- If you are building a complex component, it may be helpful to have the agent build a simple component first and then expand upon it.
162+
- The agent may try to fix warnings unnecessarily. You can tell the agent to ignore minor warnings and any errors found in `bindings.rs` (it is auto-generated).
163+
164+
### Prompting
165+
166+
This repo is designed to be used with short prompts for simple components. However, often, coding agents will do better with more context.
167+
168+
When creating a prompt, consider the following:
169+
170+
- Agents work best with short, clear instructions.
171+
- Provide relevant documentation (preferably as an `.md` file or other ai-digestible content).
172+
- Provide endpoints.
173+
- You may need to provide API response structure if the agent is not understanding responses.
174+
- Be specific about what you want the agent to build.
175+
- Agents work systematically to build components. For best results, agent should make a plan before they start building.
176+
- Be patient. Coding agents are not perfect. They may make mistakes.
177+
178+
## Troubleshooting
179+
180+
- You can ask the agent to fix errors it may not be able to catch when executing components. Make sure to give the agent full context of the error.
181+
- LLMs can be unpredictable. Minimal prompts provide a lot of room for creativity/error. If the agent is not able to fix an error after trying, sometimes deleting the component, clearing the history, and starting fresh can help.
182+
- The agent may try to edit the bindings.rs file to "fix" it. The agent never needs to do this, and you should tell the agent to not do this.
183+
- The agent is supposed to provide you with the `make wasi-exec` command. Sometimes it will try to run this itself and it will fail. Instead, ask it to give you the command.
184+
- When copying and pasting the full `make wasi-exec` command, be careful with line breaks. You may need to reformat long lines to avoid breaking the command.

content/docs/handbook/commands.mdx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: Makefile commands
3+
description: CLI commands for WAVS development
4+
---
5+
import { Callout } from 'fumadocs-ui/components/callout';
6+
import { DocsPage } from 'fumadocs-ui/page';
7+
8+
## Commands
9+
10+
Use `make help` to see all the commands:
11+
12+
```bash
13+
make help
14+
```
15+
16+
Here are the available `make` commands and their descriptions:
17+
18+
```bash
19+
build building the project
20+
wasi-build building WAVS wasi components | WASI_BUILD_DIR
21+
wasi-exec executing the WAVS wasi component(s) with ABI function | COMPONENT_FILENAME, INPUT_DATA
22+
wasi-exec-fixed the same as wasi-exec, except uses a fixed input as bytes (used in Go & TS components) | COMPONENT_FILENAME, INPUT_DATA
23+
clean cleaning the project files
24+
clean-docker remove unused docker containers
25+
validate-component validate a WAVS component against best practices
26+
fmt formatting solidity and rust code
27+
test running tests
28+
setup install initial dependencies
29+
start-all-local starting anvil and core services (like IPFS for example)
30+
get-trigger-from-deploy getting the trigger address from the script deploy
31+
get-submit-from-deploy getting the submit address from the script deploy
32+
wavs-cli running wavs-cli in docker
33+
upload-component uploading the WAVS component | COMPONENT_FILENAME, WAVS_ENDPOINT
34+
deploy-service deploying the WAVS component service json | SERVICE_URL, CREDENTIAL, WAVS_ENDPOINT
35+
get-trigger get the trigger id | SERVICE_TRIGGER_ADDR, RPC_URL
36+
show-result showing the result | SERVICE_SUBMISSION_ADDR, TRIGGER_ID, RPC_URL
37+
upload-to-ipfs uploading the a service config to IPFS | SERVICE_FILE, [PINATA_API_KEY]
38+
update-submodules update the git submodules
39+
check-requirements verify system requirements are installed
40+
```
41+
42+
For more information on commands when using the template, visit the [WAVS tutorial](/tutorial/1-overview).

0 commit comments

Comments
 (0)