You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/how-it-works.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ Submission logic defines what is done with the result of a service component aft
61
61
62
62
After the execution of a service component in the WAVS runtime, the results are passed to this contract, which can contain validation and submission logic for the service. Developers can use this contract to define their own logic for results and implement different rules depending on the specific needs of their service.
63
63
64
-
You can view an example service handler contract in the template tutorial. This service handler contract [calls the `Service Manager` contract](https://github.com/Lay3rLabs/wavs-foundry-template/blob/v0.3.0-rc1/src/contracts/WavsSubmit.sol) to validate operator signatures before executing the business logic (storing BTC price onchain in this case). This contract contains a basic example of verifying submission data, however, a submission contract can theoretically contain any business logic that a service may need.
64
+
You can view an example service handler contract in the template tutorial. This service handler contract [calls the `Service Manager` contract](https://github.com/Lay3rLabs/wavs-foundry-template/blob/v0.3.0/src/contracts/WavsSubmit.sol) to validate operator signatures before executing the business logic (storing BTC price onchain in this case). This contract contains a basic example of verifying submission data, however, a submission contract can theoretically contain any business logic that a service may need.
Copy file name to clipboardExpand all lines: content/docs/tutorial/1-overview.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,11 @@ In this guide, you will build a simple oracle service that fetches Bitcoin price
13
13
14
14
The price oracle service example has three basic parts:
15
15
16
-
1.[A trigger](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/src/contracts/WavsTrigger.sol): A trigger can be any on-chain event emitted from a contract. This event **triggers** a service to run. In the WAVS Foundry Template, there is a simple trigger contract that stores trigger requests, assigns them unique IDs, and emits an event when a new trigger is added. In this example, the trigger event will pass data pertaining to the ID of an asset for the CoinMarketCap price feed.
16
+
1.[A trigger](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/src/contracts/WavsTrigger.sol): A trigger can be any on-chain event emitted from a contract. This event **triggers** a service to run. In the WAVS Foundry Template, there is a simple trigger contract that stores trigger requests, assigns them unique IDs, and emits an event when a new trigger is added. In this example, the trigger event will pass data pertaining to the ID of an asset for the CoinMarketCap price feed.
17
17
18
-
2.[A service component](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/components/eth-price-oracle/src/lib.rs): The service component contains the business logic of a service. It is written in Rust (support for more languages is coming soon), compiled to WASM, and run by operators in the WAVS runtime. In this example, operators will listen for a new trigger event to be emitted and then run the service component off-chain, using the asset ID data from the trigger event as input. The component contains logic to fetch the price of the asset from the CoinMarketCap price feed API, which is then processed and encoded before being sent back on-chain.
18
+
2.[A service component](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/components/eth-price-oracle/src/lib.rs): The service component contains the business logic of a service. It is written in Rust (support for more languages is coming soon), compiled to WASM, and run by operators in the WAVS runtime. In this example, operators will listen for a new trigger event to be emitted and then run the service component off-chain, using the asset ID data from the trigger event as input. The component contains logic to fetch the price of the asset from the CoinMarketCap price feed API, which is then processed and encoded before being sent back on-chain.
19
19
20
-
3.[A submission contract](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/src/contracts/WavsSubmit.sol): Also known as the “service handler,” this contract contains the on-chain submission logic for the service. It validates and stores the processed data returned by the WAVS component. When an operator submits a response, the contract verifies the data’s integrity by checking the operator’s signature and then associates it with the original trigger ID, bringing the queried price on-chain.
20
+
3.[A submission contract](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/src/contracts/WavsSubmit.sol): Also known as the “service handler,” this contract contains the on-chain submission logic for the service. It validates and stores the processed data returned by the WAVS component. When an operator submits a response, the contract verifies the data’s integrity by checking the operator’s signature and then associates it with the original trigger ID, bringing the queried price on-chain.
21
21
22
22
These three parts come together to create a basic oracle service using WAVS. To learn more about services and how they work, visit the [How it works page](../how-it-works).
Copy file name to clipboardExpand all lines: content/docs/tutorial/3-project.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,11 +26,11 @@ code .
26
26
27
27
This template repo contains all the files you'll need to build, run, and test WAVS services locally.
28
28
29
-
The template already contains the necessary files for the oracle example to run. For example, the trigger ([`WavsTrigger.sol`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/src/contracts/WavsTrigger.sol)) and submission ([`WavsSubmit.sol`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/src/contracts/WavsSubmit.sol)) contracts can be found in the [`/my-wavs/src/contracts`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/6fb281c9382ceefdc8538b7a8e29916c509aafc9/src) folder.
29
+
The template already contains the necessary files for the oracle example to run. For example, the trigger ([`WavsTrigger.sol`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/src/contracts/WavsTrigger.sol)) and submission ([`WavsSubmit.sol`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/src/contracts/WavsSubmit.sol)) contracts can be found in the [`/my-wavs/src/contracts`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/src) folder.
30
30
31
-
In [`/eth-price-oracle/src/lib.rs`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/components/eth-price-oracle/src/lib.rs) you'll find the oracle service component.
31
+
In [`/eth-price-oracle/src/lib.rs`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/components/eth-price-oracle/src/lib.rs) you'll find the oracle service component.
32
32
33
-
This template uses a [`Makefile`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/Makefile) and environment variables to help with your developer experience. If you are ever curious about one of the `Make` commands in the following sections, you can always look at the [`Makefile`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/Makefile) to learn more.
33
+
This template uses a [`Makefile`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/Makefile) and environment variables to help with your developer experience. If you are ever curious about one of the `Make` commands in the following sections, you can always look at the [`Makefile`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/Makefile) to learn more.
The core logic of the price oracle in this example is located in the [`/eth-price-oracle/src/lib.rs` file](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/components/eth-price-oracle/src/lib.rs). Scroll down to follow a walkthrough of the code for the oracle component.
9
+
The core logic of the price oracle in this example is located in the [`/eth-price-oracle/src/lib.rs` file](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/components/eth-price-oracle/src/lib.rs). Scroll down to follow a walkthrough of the code for the oracle component.
10
10
11
11
12
12
<HoverContainer>
13
13
<Scrollycoding>
14
14
15
15
## !!steps trigger.rs
16
16
17
-
The [trigger.rs](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/components/eth-price-oracle/src/trigger.rs) file handles the decoding of incoming trigger data and preparing it for processing within the WAVS component. The `encode_trigger_output` function ensures that processed data is formatted correctly before being sent back. Update the code if you require different trigger types (e.g. Cosmos events) or if you are building a [custom trigger](./5-build#custom-triggers).
17
+
The [trigger.rs](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/components/eth-price-oracle/src/trigger.rs) file handles the decoding of incoming trigger data and preparing it for processing within the WAVS component. The `encode_trigger_output` function ensures that processed data is formatted correctly before being sent back. Update the code if you require different trigger types (e.g. Cosmos events) or if you are building a [custom trigger](./5-build#custom-triggers).
18
18
19
19
20
20
```rust ! trigger.rs
@@ -56,7 +56,7 @@ mod solidity {
56
56
57
57
## !!steps Oracle component definitions
58
58
59
-
The [`lib.rs`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/components/eth-price-oracle/src/lib.rs) file contains the main component logic for the oracle. The first section of the code imports the required modules for requests, serialization, and bindings, defines the component struct, and exports the component for execution within the WAVS runtime.
59
+
The [`lib.rs`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/components/eth-price-oracle/src/lib.rs) file contains the main component logic for the oracle. The first section of the code imports the required modules for requests, serialization, and bindings, defines the component struct, and exports the component for execution within the WAVS runtime.
Copy file name to clipboardExpand all lines: content/docs/tutorial/5-build.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,11 +82,11 @@ The maximum fuel allocation can be adjusted in the `Makefile` to accommodate dif
82
82
83
83
When developing a custom trigger, you will need to update the template code in a few places:
84
84
85
-
1. The trigger contract itself in [`src/WavsTrigger.sol`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/src/contracts/WavsTrigger.sol), which defines how triggers are created and emitted on-chain.
86
-
2. The `wasi-exec`commandin the [`Makefile`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/Makefile#L36-L40), which passes input data when testing WAVS components via `--input cast format-bytes32-string $(COIN_MARKET_CAP_ID)`. This simulates an Ethereum event during local execution.
87
-
3. The `decode_trigger_event`functionin [`/components/eth-price-oracle/src/trigger.rs`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/components/eth-price-oracle/src/trigger.rs#L11-L21), which processes the trigger data and extracts relevant fields like `trigger_id` and `data`.
88
-
4. The `run`functionin [`/components/eth-price-oracle/src/lib.rs`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/components/eth-price-oracle/src/lib.rs#L13), which calls decode_trigger_event, processes the extracted trigger data, and determines how to handle it.
89
-
5. The trigger script in [`/script/Trigger.s.sol`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/script/Trigger.s.sol#L15), which calls the `addTrigger`functionwith the `coinMarketCapID`, used in this template for the oracle example.
85
+
1. The trigger contract itself in [`src/WavsTrigger.sol`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/src/contracts/WavsTrigger.sol), which defines how triggers are created and emitted on-chain.
86
+
2. The `wasi-exec`commandin the [`Makefile`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/Makefile#L39-L43), which passes input data when testing WAVS components via `--input cast format-bytes32-string $(COIN_MARKET_CAP_ID)`. This simulates an Ethereum event during local execution.
87
+
3. The `decode_trigger_event`functionin [`/components/eth-price-oracle/src/trigger.rs`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/components/eth-price-oracle/src/trigger.rs#L11-L21), which processes the trigger data and extracts relevant fields like `trigger_id` and `data`.
88
+
4. The `run`functionin [`/components/eth-price-oracle/src/lib.rs`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/components/eth-price-oracle/src/lib.rs#L13), which calls decode_trigger_event, processes the extracted trigger data, and determines how to handle it.
89
+
5. The trigger script in [`/script/Trigger.s.sol`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/script/Trigger.s.sol#L15), which calls the `addTrigger`functionwith the `coinMarketCapID`, used in this template for the oracle example.
Copy file name to clipboardExpand all lines: content/docs/tutorial/6-run-service.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,11 +46,11 @@ The following command will deploy your WASI component and service information to
46
46
make deploy-service
47
47
```
48
48
49
-
This command specifies the event emitted from your trigger contract as the on-chain event that will trigger your service. In the [`Makefile`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/Makefile#L95-L102), you can also see that it specifies the submission contract as the `submit-address`, as well as the filename of your component.
49
+
This command specifies the event emitted from your trigger contract as the on-chain event that will trigger your service. In the [`Makefile`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/Makefile#L95-L102), you can also see that it specifies the submission contract as the `submit-address`, as well as the filename of your component.
50
50
51
51
<Callouttitle="Customize variables"type="info">
52
52
53
-
Open the [`Makefile`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/Makefile#L9-L22) to view the different variables that you can customize, including the trigger event, the component filename, and the service config.
53
+
Open the [`Makefile`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/Makefile#L9-L22) to view the different variables that you can customize, including the trigger event, the component filename, and the service config.
54
54
55
55
You can also modify variables by specifying them before running the `make` command:
56
56
@@ -65,7 +65,7 @@ TRIGGER_EVENT="NewTrigger(bytes)" make deploy-service
65
65
66
66
Next, use your deployed trigger contract to trigger the oracle to be run. In the following command, you'll specify the `COIN_MARKET_CAP_ID` as `1`, which corresponds to the ID of Bitcoin.
67
67
68
-
Running this command will execute [`/script/Trigger.s.sol`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/script/Trigger.s.sol) and pass the ID to the trigger contract, starting the following chain of events:
68
+
Running this command will execute [`/script/Trigger.s.sol`](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/script/Trigger.s.sol) and pass the ID to the trigger contract, starting the following chain of events:
69
69
70
70
1. The trigger contract will emit an event with the specified ID as its data.
71
71
2. Operators listening for the event will receive the data and run it in the oracle component off-chain.
Copy file name to clipboardExpand all lines: content/docs/tutorial/7-prediction.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ These contracts handle the creation of markets and conditional tokens.
30
30
31
31
In this demo, the oracle that resolves the market is triggered by the [`PredictionMarketOracleController.sol`](https://github.com/Lay3rLabs/wavs-demos/blob/d13fd90b1407cdb876340e2f399769bb31b1dc52/src/PredictionMarketOracleController.sol) contract.
32
32
33
-
This contract contains modifications to the `WavsTrigger.sol` contract from the [WAVS Foundry Template repo](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0-rc1/src/contracts/WavsTrigger.sol). Similar to the simple trigger contract, it passes data to the oracle AVS via the `NewTrigger` event.
33
+
This contract contains modifications to the `WavsTrigger.sol` contract from the [WAVS Foundry Template repo](https://github.com/Lay3rLabs/wavs-foundry-template/tree/v0.3.0/src/contracts/WavsTrigger.sol). Similar to the simple trigger contract, it passes data to the oracle AVS via the `NewTrigger` event.
0 commit comments