1. Oracle Service Overview

In this guide, you will build a simple oracle service that fetches Bitcoin price data from coinmarketcap.com. This example is built using the WAVS Foundry Template, which contains the tools you need to build your own custom service.
The price oracle service example has three basic parts:
-
A trigger: 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.
-
A service component: 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.
-
A submission contract: 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.
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.
Get Started
Click here to set up your environment and start building your service.