Onchain Oracle Template
Here we provider an example of an onchain provider interface for use in deploying multiparty oracles or wrapping arbitrary onchain logic
Constructor
This function takes in the Zap Coordinator, as well as the intended Public Key and Title. It then calls Zap's registry contract to add the smart contract into Zap's database as a new oracle.
Initialize Curve
This is where the smart contract sets up the pricing curve for the oracle and initializes an endpoint. For more information on how to set up the array the contract takes in as a parameter, look at the Curve Encoding section. You will notice that at the beginning, registry is redefined by the Zap Coordinator. This is in case the Zap contract has updated. The coordinator will fetch the updated address and use that for future reference
Set Provider Parameter
Sets any key:value pair for the provider, which is normally some asset that needs to be known by the subscriber.
Set Endpoint Params
Sets up the endpoint parameters for the endpoint. These parameters will determine how the oracle will retrieve an answer for queries made to the smart contract.
Receive
The way that Zap's dispatch contract calls on the oracle contract. Parameters for this function are standardized. Similar to the registry contracts, the dispatch contract in this contract is updated whenever the receive function is called. Eventually after the receive function is called, the contract should generate an answer for the query and call dispatch.respond(). It should be noted that the response types are from 1 to four strings, an integer array, or a bytes32 array.
Last updated