Unlocking the Web3 Universe: Orochi Network's Orocle Service
Imagine building a Web3 application that thrives on real-world data, free from centralized control. This is the vision behind Orochi Network's Orocle service, a powerful tool poised to revolutionize the way DApps interact with the external world.
Traditionally, DApps have struggled to access external data sources, relying on centralized oracles – single points of failure susceptible to manipulation and bias. Orochi's Orocle shatters these limitations, offering a decentralized, secure, and versatile solution for feeding accurate and verifiable data into your DApps.
Deployed Platform
Orocle V2 was deployed on following smart contract platform.
Mainnet
Network Name | Address |
---|---|
Ancient8 Mainnet | 0x80011aA6171B433d33c46B59A619FD338c155161 |
U2U Solaris Mainnet | 0x6eFAA86dD3177d75d161A99e2c103409927f3C49 |
BNB Chain | 0xcE978D96f761a0AE9Dd252E666504482B74A4713 |
X Layer Mainnet | 0x5cb715ddb32d0facd9c5b9e3a10f2ffceba93285 |
Saakuru (L2) Mainnet | 0x5C27491559b3E438b18024A2d5C6f307fBD9Ba15 |
Sei Mainnet | 0x5C27491559b3E438b18024A2d5C6f307fBD9Ba15 |
Manta Pacific L2 Rollup | 0x155bF6a23e5551b431cfb716D2c62409e49B03dd |
ZKsync Era Mainnet | 0x4e12287584A3a506755f8212311f6165336f98a9 |
Scroll Mainnet | 0x59bcAa1fB8D336CE6103Ed95BD0929e78a1fcEf6 |
Zircuit Mainnet | 0xCB50b75b5CaF2F8A58e4842238475384fb6d5Ee6 |
Phoenix Mainnet | 0x9A19D4065b91FE61664fE5C50f20048969729D74 |
Etherlink Mainnet | 0xF971965E35b8923DF33332561f69ce74547c3fE3 |
5ireChain Mainnet | 0xcAfEc24Fdb365e278bCF873B674CCC340734AE4f |
Testnet
So, what exactly can the Orochi Orocle (Oracle) do?
- Gather Diverse Data: Access a vast pool of information, from financial markets and weather updates to social media sentiment and IoT sensor readings. The possibilities are endless, empowering DApps with real-time, relevant data.
- Decentralized & Trustworthy: Eliminate the risk of manipulation with a distributed network of nodes verifying and securing data integrity. No single entity controls the flow of information, fostering trust and transparency.
- Highly Scalable & Efficient: Designed to handle high volumes of data requests efficiently, ensuring your DApp performs smoothly even with complex data integrations.
- Chain Agnostic: Integrate seamlessly with various blockchain platforms, offering flexibility and wider reach for your DApp. But why is this important?
The potential applications are vast:
- Decentralized finance (DeFi): Integrate real-world market data for dynamic pricing and risk management in DeFi protocols.
- Prediction markets: Enable accurate and trustworthy predictions based on real-time events and data.
- Supply chain management: Track goods movement and environmental conditions transparently across complex supply chains.
- Gaming & Entertainment: Create immersive experiences that react to real-world events and user behavior.
Orochi's Orocle is more than just a data feed; it's a gateway to a truly decentralized and data-driven future for Web3. By unlocking the power of real-world data, it empowers developers to build DApps that are not only innovative but also robust, secure, and truly impactful.
Ready to explore the possibilities? Dive into the world of Orochi Network and unleash the full potential of your Web3 vision.
Installation
Installing @orochi-network/contracts
will help you interactive with Orochi Network Orocle and VRF (Orand) much more easier.
npm i --save-dev @orochi-network/contracts
Orocle Aggregator Overview
This section describes all methods of Orocle V2 that facilitate interaction from external smart contracts. To familiarize yourself with Orocle V2, the following terminology definitions may be helpful.
appId: Application ID on Orocle, our oracle support multiple applications there are two of them listed here:
Application ID | Description |
---|---|
1 | Asset Price |
2 | Cross Chain Data |
round: Each application will have different round number, every time a new dataset submitted the round number will be increased by 1
identifier: Data identifier, it's a bytes20
used to index data on smart contract, for asset price application identifier
is token's symbol
Note:
- Only 255 latest rounds will be cached on smart contract, you can not get more than 255 rounds from the current round by using
getData()
method - Round is uint64, so 2^64 is the limit of number of round
Summary:
- This contract defines an interface for interacting with an oracle aggregator.
- It provides functions to retrieve application metadata, data, and round information.
- It's designed for read-only access, as all functions are marked as view.
Key Points:
The IOrocleAggregatorV2 interface defines several methods:
request(uint256 identifier, bytes calldata data)
: This function is used to create a new request. It takes an identifier and data as parameters and returns a boolean indicating whether the request was successful.fulfill(uint256 identifier, bytes calldata data)
: This function is used to fulfill a request. It also takes an identifier and data as parameters and returns a boolean indicating whether the fulfillment was successful.getMetadata(uint32 appId, bytes20 identifier)
: This function is used to get the metadata of a given application. It takes an application ID and an identifier as parameters and returns the round and the last update time.getData(uint32 appId, uint64 round, bytes20 identifier)
: This function is used to get the data of an application for a specific round. It takes an application ID, a round number, and an identifier as parameters and returns the data.getLatestData(uint32 appId, bytes20 identifier)
: This function is used to get the latest data of an application. It takes an application ID and an identifier as parameters and returns the data.getLatestRound(uint32 appId, bytes20 identifier)
: This function is used to get the latest round of an application. It takes an application ID and an identifier as parameters and returns the round number, the last update time, and the data.
Example
Here is an example of AssetPrice
consumer:
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
import '@openzeppelin/contracts/access/Ownable.sol';
import '@orochi-network/contracts/IOrocleAggregatorV2.sol';
contract ConsumerAssetPrice is Ownable {
IOrocleAggregatorV2 private orocle;
event SetOrocle(address indexed oldOrocle, address indexed newOrocle);
constructor(address orocleAddress) {
_setOrocle(orocleAddress);
}
function _setOrocle(address newOrocle) internal {
emit SetOrocle(address(orocle), newOrocle);
orocle = IOrocleAggregatorV2(newOrocle);
}
/**
* Get price of an asset based USD
* @dev Token price will use 18 decimal for all token
* @param identifier Asset identifier (e.g. BTC, ETH, USDT)
* @return price
*/
function _getPrice(bytes20 identifier) internal view returns (uint256) {
return uint256(orocle.getLatestData(1, identifier));
}
/**
* Get price of a pair
* @dev Token price will use 18 decimal for all token
* (e.g. BTC/ETH => srcToken='BTC' dstToken='ETH')
* @param srcToken Asset identifier of source
* @param dstToken Asset identifier of destination
* @return price
*/
function _getPriceOfPair(bytes20 srcToken, bytes20 dstToken) internal view returns (uint256) {
return (_getPrice(srcToken) * 10 ** 9) / (_getPrice(dstToken));
}
/**
* Allow owner to set new Orocle address
* @param newOrocle new Orocle address
* @return success
*/
function setOrocle(address newOrocle) external onlyOwner returns (bool) {
_setOrocle(newOrocle);
return true;
}
}
Here is an example of BitcoinSeller
that used ConsumerAssetPrice
:
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
import './ConsumerAssetPrice.sol';
contract BitcoinSeller is ConsumerAssetPrice {
constructor(address provider) ConsumerAssetPrice(provider) {}
function estimate(uint256 amount) external view returns (uint256 total) {
total = _getPrice('BTC') * amount;
}
function ethOverBtc() external view returns (uint256 price) {
price = _getPriceOfPair('ETH', 'BTC');
}
}