Price Fetch Example
To dip our toes into Hybird Compute's capabilities, consider the following simple smart contract which fetches the price of different cryptocurrencies. You can view the full example in our repository.
We can start by importing some libraries (one to allow the use of Hybrid Compute, one to give exclusive access to certain functions as an "owner") and providing the general structure of our contract:
To this, we can add our price fetching logic:
Note the call HA.CallOffchain()
; this leverages Hybrid Compute's ability to access data and compute off-chain. This reduces the time and complexity it takes to perform this price fetch, evident in how quickly this fetching happens. You can test this contract with this app, which includes a UI to clearly show the time (or lack thereof) Hybrid Compute takes to fetch the prices.
Last updated