Building on Celo: Exploring and Leveraging the Ecosystem Partners for Enhanced Dapp Development

Building on Celo: Exploring and Leveraging the Ecosystem Partners for Enhanced Dapp Development
none 0.0 0


Before proceeding with this tutorial, you should have:

  • Intermediate understanding of JavaScript and Solidity programming languages
  • Basic understanding of Blockchain and Decentralized Finance concepts
  • Familiarity with Celo’s ecosystem and the Hardhat development environment
  • A system with Node.js (version 10 or later) and NPM installed
  • A Celo wallet with some testnet tokens for development and testing


To follow this tutorial, you need:

  • Code Editor like VS Code
  • Node.js and NPM (Node Package Manager)
  • Hardhat development environment
  • Celo Extension Wallet or another Celo Wallet solution
  • Testnet tokens which you can get from the Celo Alfajores Faucet


Celo, a mobile-first blockchain platform, offers unique opportunities to developers by facilitating the creation of diverse decentralized applications (DApps). The versatility of the Celo ecosystem is magnified by the strategic partnerships it has forged, allowing developers to build robust, user-friendly DApps. This tutorial delves into three of these partners—Ubeswap, Moola Market, and The Graph, exploring how you can utilize their offerings for advanced DApp development.

Ubeswap: Building Decentralized Exchanges

Ubeswap, a decentralized exchange protocol, forms an integral part of the Celo ecosystem. It uses automated market-making (AMM) to facilitate token swaps, liquidity provision, and farming. Essentially, it presents a compelling toolkit for DApp developers, given its operational efficiency and user-centric features.

Understanding Automated Market Making (AMM)

In traditional exchanges, trades are facilitated by an order book where buy and sell orders are matched. However, decentralized exchanges like Ubeswap operate differently. They employ an automated market-making mechanism where the pricing of tokens is determined by a mathematical formula based on the supply and demand of the tokens in the liquidity pool.

This system replaces the traditional order book with a liquidity pool for each trading pair. The price of tokens automatically adjusts based on the ratio of the tokens in the pool as users trade. This mechanism ensures that trading can happen 24/7, and even tokens with low trading volumes can be traded efficiently.

Interacting with Ubeswap using ContractKit

To interact with Ubeswap, we leverage smart contracts. We can build a DApp that allows token swapping using Ubeswap’s Router contract. Below is an example of how to achieve this:

const Web3 = require("web3");
const ContractKit = require("@celo/contractkit");
const UbeswapRouterABI = require("./UbeswapRouterABI.json"); // Import the ABI

const web3 = new Web3(""); // Connect to Celo node
const kit = ContractKit.newKitFromWeb3(web3);

const UbeswapRouterAddress = "..."; // Ubeswap Router contract address
const UbeswapRouter = new kit.web3.eth.Contract(

async function swapTokens() {
  const amountIn = "1000000000000000000"; // 1 cUSD in wei
  const path = ["cUSDAddress", "CELOAddress"]; // Addresses of cUSD and CELO
  const to = "myAddress"; // Your address
  const deadline = Math.floor( / 1000) + 60 * 20; // 20 minutes from now

  const tx = UbeswapRouter.methods.swapExactTokensForTokens(

  const txObject = await tx.send({ from: myAddress }); // Replace with your address

This script initializes a transaction (tx) that calls the swapExactTokensForTokens function in Ubeswap’s Router contract. The function parameters include the amount of tokens to be swapped (amountIn), the minimum amount of tokens to receive (0 in this case, indicating no lower limit), the swap path (path), the recipient address (to), and the transaction deadline (deadline).

Moola Market: Expanding DeFi Capabilities

Moola Market is another crucial partner in the Celo ecosystem, providing lending and borrowing facilities to users. This open-source platform lets users earn interest on deposits and borrow assets against collateral, forming a key component of many DeFi applications.

Understanding Lending and Borrowing Protocols

Lending and borrowing protocols are fundamental to the DeFi ecosystem. These protocols enable users to supply their assets to earn interest or borrow other assets against their holdings. The interest rates are algorithmically determined based on supply and demand for each asset.

Moola Market, operating on Celo, allows users to interact with these protocols using cTokens, which represent a claim on a portion of assets in the market. When a user deposits an asset into Moola Market, they receive cTokens in return, which can be redeemed for the underlying asset at any time.

Interacting with Moola Market

Similar to Ubeswap, developers can interact with Moola Market’s smart contracts using Celo’s ContractKit. The primary contracts to consider are the cToken contracts and the Comptroller contract, which manages the markets.

Here’s an example of how to deposit assets (mint cTokens) and borrow assets from Moola Market:

const Web3 = require("web3");
const ContractKit = require("@celo/contractkit");
const MoolaMarketABI = require("./MoolaMarketABI.json"); // Import the ABI

const web3 = new Web3(""); // Connect to Celo node
const kit = ContractKit.newKitFromWeb3(web3);

const MoolaMarketAddress = "..."; // Moola Market contract address
const MoolaMarket = new kit.web3.eth.Contract(

async function depositTokens() {
  const myAddress = "..."; // Your address
  const depositAmount = "1000000000000000000"; // 1 cUSD in wei

  // Approve the Moola Market contract to spend cUSD on your behalf
  const cUSDContract = new kit.web3.eth.Contract(
  const approveTx = cUSDContract.methods.approve(
  await approveTx.send({ from: myAddress });

  // Deposit cUSD to Moola Market
  const tx =;
  const txObject = await tx.send({ from: myAddress });

async function borrowTokens() {
  const borrowAmount = "500000000000000000"; // 0.5 CELO in wei
  const tx = MoolaMarket.methods.borrow(borrowAmount);
  const txObject = await tx.send({ from: myAddress }); // Your address

In this example, we have two functions: depositTokens() and borrowTokens(). depositTokens() approves the Moola Market contract to spend cUSD on your behalf and deposits cUSD to Moola Market, while borrowTokens() borrows CELO from Moola Market.

This interaction forms the basis of any DeFi application aiming to include lending and borrowing capabilities.

Leveraging Moola for Advanced DeFi Applications

With Moola Market, developers can build DApps that allow users to earn passive income, take out loans, or even develop advanced DeFi strategies, such as yield farming and liquidity mining. These strategies typically involve a combination of lending, borrowing, and earning new tokens as rewards for providing liquidity.

Moola Market’s open-source, permissionless protocol means that developers are free to build on top

of it, creating innovative solutions that can potentially revolutionize financial systems. This freedom of development, combined with the robustness of Moola Market, serves as a fertile ground for DApp development, pushing the boundaries of what is possible within the DeFi space.

The Graph: Creating Efficient APIs

The Graph is a decentralized protocol for indexing and querying data from blockchains, which is crucial for DApp developers. It allows developers to efficiently and reliably access blockchain data, making it a significant partner in the Celo ecosystem.

Understanding The Graph

The Graph employs a network of ‘subgraphs’, which can be thought of as APIs that anyone can define and publish. These subgraphs describe how to fetch and store blockchain data in a way that’s easy to access and use. Once a subgraph is deployed, anyone can run a node to help serve that subgraph’s data and earn fees in return.

These characteristics make The Graph an important tool for blockchain developers, as it provides a reliable and efficient way to interact with on-chain data without having to run a full node or write complex data parsing code.

Interacting with The Graph

To interact with The Graph, you need to define and deploy a subgraph. Here’s a simplified example:.

Creating a Subgraph for Your DApp

A subgraph defines how blockchain data gets collected, stored, and accessed. It’s the backbone of any DApp as it allows for efficient retrieval of data. Here’s how to create a subgraph for your DApp:

First, install The Graph CLI:

npm install -g @graphprotocol/graph-cli

Then, initialize a new subgraph:

graph init --from-example <GITHUB_USERNAME>/<SUBGRAPH_NAME>

Replace <GITHUB_USERNAME> with your GitHub username and <SUBGRAPH_NAME> with the name you want to give to your subgraph.

The graph init command creates a new directory with the subgraph manifest (a YAML file), schema (a GraphQL file), and mappings (JavaScript or TypeScript files). It also generates an example subgraph that you can modify to fit your DApp’s requirements.

The manifest (subgraph.yaml) defines what data the subgraph indexes from the blockchain, how it indexes it, and how it can be queried using the schema. The schema (schema.graphql) defines the entities and their properties that the subgraph will return on a query. The mappings (mappings.ts) are scripts that run to translate the blockchain data into the format defined in the schema.

Once you’ve modified these files to suit your DApp, you can build and deploy your subgraph to The Graph’s hosted service:

graph auth <ACCESS_TOKEN>
graph deploy --node --ipfs <GITHUB_USERNAME>/<SUBGRAPH_NAME>

Replace <ACCESS_TOKEN> with the access token you got from The Graph’s dashboard and <GITHUB_USERNAME>/<SUBGRAPH_NAME> with your GitHub username and subgraph name.

After deployment, you can query your subgraph using GraphQL on The Graph’s playground.

Leveraging The Graph in DApps

By building on The Graph, developers can create highly responsive DApps that provide real-time updates to users. For instance, a DApp that tracks the token transfers of a particular token can use The Graph to efficiently fetch the data, rather than making repeated calls to a Celo node or storing a large amount of data on the client-side.

Through The Graph, developers can also make their DApps more robust and reliable by providing data redundancy and failover options, adding another layer of reliability to their applications. With these features, The Graph opens up a new world of possibilities for DApp developers, enabling the creation of efficient, high-performing applications.


With Ubeswap, Moola Market, and The Graph, you have all the necessary building blocks to create diverse and feature-rich DApps in the Celo ecosystem. These examples provide a solid foundation, but remember, the true depth and potential can only be realized when these elements are tailored to meet your unique project requirements. Always aim to familiarize yourself more deeply with each component and experiment with different configurations to fully unlock their capabilities.

About the Author

Elijah Sorinola

Web3 technical writer with a passion for communicating complex technical concepts in a clear and concise manner. Let’s connect on LinkedIn to discuss your content needs.


  1. Ubeswap
  2. Moola Market
  3. The Graph
  4. Celo ContractKit
  5. Hardhat
  6. Celo Blockchain Docs
  7. The Graph Docs

Note: The code snippets provided in this tutorial are for learning purposes and may require modifications before production use. Always conduct thorough testing when interacting with smart contracts.


This appears to be a tutorial so I removed the pathway tag.

1 Like

Hi @Elijah007 - this topic has received a high number of votes so I’d like to approve it. Could you update it to meet our proposal guidelines to help developer build on Celo? Perhaps focusing on the Celo Developer ecosystem and roadmap and showing developers how to access a broader range of tools.

1 Like

I’ve edited the topic and outline to comply with your last feedback. @Celo_Academy , let me know what the next step is. Thanks!

1 Like

It’s now up for votes from the community to become eligible for this weeks approvals. Thanks for the updates! :seedling:


Fantastic news! Your proposal has landed in this week’s top voted list. As you begin your project journey, remember to align with our community and technical guidelines, ensuring a high quality platform for our developers. Congratulations! :mortar_board: :seedling:

Note: It’s not clear how many partners will be included or what technical demonstrations you will provide. Moving forward with this, please ensure that it provides concrete technical demonstrations with significant depth to get them started, and additional resources as necessary. Thank you.


I will be reviewing this article @Elijah007 , and make sure to move it in review rather than publish


Great. Thanks for pointing that out @ishan.pathak2711