Request form
Cookbook may introduce a token in the future. Share and contribute to be eligible for future airdrops.
close icon
relevant tag icon
Cross-chain Oracle L2 Oracle Spoke
copy icon
UMA
• version 1.0.0
Oracle
Hub
Cross-Chain
Audited

Cross-chain Oracle L2 Oracle Spoke

Audited

This contract is primarily intended to receive messages on the child chain from a parent chain and allow contracts deployed on the child chain to interact with this contract as an Oracle. Moreover, this contract gives child chain contracts the ability to trigger cross-chain price requests to the mainnet DVM. This Spoke knows how to communicate with the parent chain via a "ChildMessenger" contract which directly communicates with the "ParentMessenger" on mainnet.

*Visit desktop site to download or deploy

Version

1.0.0

Creator

UMA

Last Publish

11/5/2022
Any contract you deploy is yours.
Fully owned and controlled by your wallet.
Documentation
Source Code
requestPrice(bytes32,uint256) :
This function is used to request a price from the parent contract. It takes three parameters: an identifier, a time, and ancillary data. The function first calls the _requestPrice() internal function, which checks if the requested price is already stored in the contract. If the price is not stored, the function sends a message to the parent contract with the identifier, time, and ancillary data. The ancillary data is stamped with the _stampAncillaryData() internal function before being sent. (autogenerated documentation)
processMessageFromParent() :
This function is an override of the processMessageFromParent() function in the Messenger contract. It is used to decode and process a message sent from the parent contract. The message contains four pieces of data: an identifier, a timestamp, ancillary data, and a price. The function then calls the _publishPrice() function, passing in the four pieces of data, which publishes the price to the contract. (autogenerated documentation)
hasPrice(bytes32,uint256) :
This function checks if a price has been set for a given identifier, time, and ancillary data. It does this by encoding the identifier, time, and ancillary data into a price request ID, and then checking if the state of the price associated with that request ID is set to "Resolved". If it is, then the function returns true, indicating that a price has been set. (autogenerated documentation)
getPrice(bytes32,uint256) :
This function is used to retrieve the price of a given asset at a given time. It takes three parameters: an identifier for the asset, a timestamp, and ancillary data. It first encodes the parameters into a unique price request ID, then looks up the corresponding price in the 'prices' mapping. If the price has been resolved, it returns the price, otherwise it throws an error. (autogenerated documentation)
stampAncillaryData() :
This function is used to stamp ancillary data onto the blockchain. It takes a byte array of ancillary data as an input and returns a byte array of the stamped ancillary data. The function works by using the _stampAncillaryData() internal function to stamp the ancillary data onto the blockchain. This internal function is responsible for verifying the ancillary data and then storing it on the blockchain. (autogenerated documentation)
_stampAncillaryData() :
This function is an internal view function that appends a key-value pair to a given bytes memory array. The key is "childChainId" and the value is the chainid of the current block. This function is used to add ancillary data to a transaction, which is data that is not part of the transaction itself but is related to it. This data can be used to provide additional context or information about the transaction. (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i uma-oracle-spoke
copy icon

Last Publish

11/5/2022

Version

1.0.0

Creator

UMA

Cookbook is free.
Any contract you deploy is yours.
Your contract is owned and controlled by you.