Understanding Celo Price Oracles

Understanding Celo Price Oracles https://celo.academy/uploads/default/optimized/2X/5/57cb87a94918d17d2c21bbcdb89ace61455710af_2_1024x576.jpeg
none 0.0 0


The world of blockchain and digital currencies is a fascinating ecosystem, offering a variety of functionalities and opportunities for developers and users alike. Among the many features that define this space, oracles play a critical role, especially in the case of platforms like Celo.

In the following sections, we will delve into the concept of Celo Price Oracles, explore their functioning, and elucidate their importance in maintaining the stability of Celo’s stablecoins. We will illustrate these concepts with practical examples using JavaScript and Solidity.

What is Celo?

Before we dive into the Price Oracles, let’s quickly understand what Celo is. Celo is a blockchain ecosystem focused on increasing cryptocurrency adoption among smartphone users. By using phone numbers as public keys, Celo hopes to introduce the world’s billions of smartphone owners, including those without access to basic financial services, to transacting in cryptocurrency.

The Celo ecosystem includes stablecoins, which are cryptocurrencies designed to minimize the volatility of the price of the stablecoin, relative to some “stable” asset or a basket of assets. Celo has its own native stablecoin, Celo Dollar (cUSD).

What Are Oracles?

Oracles in the world of blockchain technology are third-party services which provide smart contracts with external information. They serve as bridges between blockchains and the outside world. This information might include price data, temperature, whether a payment has been made, or other types of real-world data that a smart contract might need to execute correctly.

Understanding Celo Price Oracles

The Celo Price Oracles provide a mechanism for the Celo protocol to maintain the peg of its stablecoins, such as the Celo Dollar, to real-world assets. In the case of the Celo Dollar, the Celo protocol aims to keep the value of cUSD as close to one US dollar as possible. The Celo Price Oracles provide real-world price data to the protocol, allowing it to adjust parameters to maintain the peg.

How Celo Price Oracles Work

In the Celo ecosystem, oracles serve a vital role. They provide external, real-world data (like fiat currency exchange rates) to the blockchain. This data is crucial for maintaining the stability of Celo’s stablecoin (cUSD) and the operation of the platform’s stability protocol. Here’s a brief explanation of how the Celo oracles work:

On-Chain Oracles

On-chain oracles are smart contracts that exist on the blockchain. They source data directly from the blockchain itself. For Celo, on-chain oracles are responsible for pulling data related to the internal state of the blockchain. This might include transaction volumes, fees, number of accounts, and other on-chain metrics. There are several on-chain oracles running on Celo network, we explain them briefly here:

Band Protocol

Band Protocol is a cross-chain data oracle platform that combines and integrates real-world data and APIs to smart contracts across many blockchains. More information on the protocol’s specifics can be found here.

RedStone Oracle

RedStone is a data ecosystem that delivers fast and accurate financial information in a decentralised fashion using an innovative approach of on-demand data fetching. It offers a radically different design of Oracles catering for the needs of modern DeFi protocols. You can learn more on the it here

Other on-chain oracles such as Witnet and Pyth Network are used.

Off-Chain Oracles

Celo utilizes a set of trusted off-chain oracles that regularly report the price of CELO in various fiat currencies to the blockchain. These oracles pull data from outside of the blockchain (i.e., from the ‘real world’). The reported data is then aggregated, and the median is stored as the official exchange rate, ensuring the stability of the Celo Dollar (cUSD).

“SortedOracles” is a Smart Contract in the Celo Protocol. This Smart Contract gets price data from Oracles, maintains track of their median value, and compares them to a list of addresses that are authorized to submit price information. Oracles on Celo play an important role in the stability mechanism. The price of CELO in the fiat currency to which a stable value asset is linked, such as cUSD (stable value asset) to the fiat currency to which it is linked (US Dollar), is provided by Oracles.

Remember, Celo oracles are critical for maintaining the price stability of the cUSD stablecoin, enabling a variety of DeFi applications on the Celo platform.

The Celo Price Oracle system operates by having multiple reputable participants, known as oracle providers, fetch price data from various sources, then submit the median of those prices to the Celo blockchain.

More on RedStone

Here’s an example in Solidity using RedStone oracle amongst others. This is how you’d need to build and deploy a simple example of using redstone-evm-connector - a tool for injecting trusted pricing data to EVM Blockchains.:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import "redstone-evm-connector/lib/contracts/message-based/PriceAwareOwnable.sol";

contract ExampleContract is PriceAwareOwnable {

  uint256 private lastPrice = 0;
  function setPrice() public {
    uint256 ethPrice = getPriceFromMsg(bytes32("TSLA"));
    lastPrice = ethPrice;

  function getLastPrice() public view returns(uint256) {
    return lastPrice;

Let’s deploy.

const { WrapperBuilder } = require("redstone-evm-connector");
const ethers = require("ethers");
const ExampleContract = require("../artifacts/contracts/example.sol/ExampleContract.json");
const utils = require("./utils");

// Before running this script you should run ganache
// Learn more at: https://www.trufflesuite.com/ganache
// And put your privateKey to ../.secrets.json as { "privateKey": "REPLACE_WITH_PRIVATE_KEY..." }

(async () => {
  console.log("Deploying the contract");
  const wallet = utils.getWallet();
  const address = await utils.deployContract(ExampleContract, wallet);

  // Wrapping contract with redstone-stocks provider
  console.log("Contract wrapping");
  const contract = new ethers.Contract(address, ExampleContract.abi, wallet);
  const wrappedContract = WrapperBuilder
    .usingPriceFeed("redstone-stocks", { asset: "TSLA" });

  // Provider should be authorized once after contract deployment
  // You should be the owner of the contract to authorize provider
  await wrappedContract.authorizeProvider();

  // Then, you can interact with your wrapped contract
  console.log("Interacting with contract");
  await wrappedContract.setPrice();
  const price = await wrappedContract.getLastPrice();
  console.log("Got TSLA price in contract: " + price / (10 ** 8));

Importance of Celo Price Oracles

The Celo Price Oracles play a key role in maintaining the stability of Celo’s stablecoins. Without the oracles, the Celo protocol would lack the real-time price information it needs to adjust parameters and maintain the peg. Thus, the oracles are an integral part of the Celo ecosystem, supporting its stability and credibility.

In addition, the decentralization of the oracle system in Celo further strengthens the trust and reliability of the information being provided. This is because the risk of manipulation or error in the data is significantly reduced when it’s sourced from multiple independent and trustworthy participants.


In conclusion, Celo’s Price Oracles are fundamental in ensuring the stability and reliability of its stablecoins, thereby enhancing the overall robustness of the Celo ecosystem. By understanding the mechanics of these Price Oracles, developers can better appreciate the mechanisms that keep the Celo ecosystem functioning effectively.

Next Steps

The Celo program has other tutorials that helps you create other fascinating projects on the Celo blockchain, click here to know more.

About the Author

Joshua Obafemi

I’m a Web3 fullstack developer and technical writer. You can connect with me on GitHub, Twitter, Linkedin.



Congratulations on being among the top voted proposals this week! This is now approved by @Celo_Academy for you to get started whenever you’d like. :mortar_board: :seedling:


Congratulations man…lookforward to reading this articles.


Hi @Jorshimayor I will review for you


Oh okay, let me know if you need anything changed


You need to fix the JavaScript and Solidity code snippets. Prioritize formatting them first.


Okay. Thanks for that

1 Like

Ok you can move it to publish

1 Like

Okay thanks a lot @yafiabiyyu


Hello we are expecting explanation of each oracle, here is the link for the list Oracles on Celo | Celo Documentation


Hi, you can check this and let me know if more work should be done. Thanks


It’s not clear that this passed publishing. @ishan.pathak2711 please confirm. Moved back to Publish.