Cover Image for Celo API: Transaction, Transfers and much more

Celo API: Transaction, Transfers and much more

MEV
Ethereum

Blockchain has redefined financial accessibility, given the shift towards mobile phones from computers. With billions of phone-based financial transactions occurring daily, mobile-based or mobile-first financial solutions are vital. Even though there are plenty of mobile-based financial apps, they are yet to fully tap into the potential of DeFi or crypto. So, in short, the need of the hour is a blockchain that prioritizes the mobile-first approach.

Celo was developed with this intent in mind and has emerged as a pioneering force in enabling people to make financial transactions from their smartphones.

In this article, let's look at the basics of Celo and explore several Bitquery APIs to understand the power of the Celo blockchain.  

What is Celo?

Celo, a blockchain platform, aims to create a financial system that is open, inclusive, and accessible to anyone with a mobile phone. Built on the principles of decentralization and transparency, Celo empowers individuals globally to send cryptocurrencies through their mobile phones, just like they would send a text.

Celo is a proof-of-stake blockchain, which was originally co-developed by an MIT professor and executives from GoDaddy, in 2017. It uses a Byzantine Fault Tolerant (BFT) consensus algorithm. Celo's native stablecoin is Celo Dollars (cUSD) and the native asset is CELO.

Note that Celo, which is an independent Layer 1 (EVM compatible) blockchain, is now transitioning to Ethereum Layer 2, according to the latest value proposition by cLabs. 

Architecture

The basic architecture of Celo consists of:

  • Celo Blockchain: Protocol for enabling applications and transactions

  • Core Layer: Technical layer that is made up of Core Contracts

  • Application Layer: Applications created on Celo

Governance 

Celo employs an on-chain governance mechanism to oversee and enhance components embedded in the Celo Core Contracts. In addition, the mechanism also manages other parameters of the Celo blockchain, such as smart contracts, currencies, assets, and more.

Components of Celo

The Celo blockchain includes the following elements in its topology:

  • Validators, which validate transactions

  • Full nodes, which connect validator nodes and mobile wallets

  • Ultralight clients, which are applications that run on mobile phone wallets

Key Features of Celo 

Important features of Celo are:

  • Mobile-friendly design

  • Stability through stable cryptocurrencies

  • Decentralized identity or lightweight identity

  • Blockchain interoperability

Applications of Celo

Developers can build the following applications for financial services, such as:

  • Remittances and cross-border payments

  • Microfinance and lending

  • Tokenization of assets

  • Enhanced transactions

Obtaining Celo On-chain Data Through Bitquery APIs 

Bitquery offers a wide range of APIs to obtain real-time or historic Celo on chain data. Check out the explorer to seamlessly view data related to blocks, DEX trades, transactions, token transfers, Gas costs, smart contract calls, and many more. 

Celo Explorer API: Overview of Celo Mainnet

Use the Bitquery Explorer to get an overall view of all the data available for Celo.

To embed queries in your applications, simply click the Get API on the bottom right of the screen (as shown in the above image). To write your own queries, use Bitquery's in-built GraphQL IDE.
Here are key APIs of the Celo blockchain that you can use to analyze the Celo on-chain performance. 

Active Addresses API

This API retrieves all active addresses on the Celo blockchain. 

To obtain the number of active addresses of Celo chain, use the following query in IDE. For example, this query retrieves the total number of all active addresses on the chain after October 2023. Specify the network as "Celo_mainnet" and the date as applicable.

query MyQuery {
  ethereum (network: celo_mainnet){
    activeAddresses(date: {after: "2023-10-01T00:00:00Z"}) {
      count(uniq: address)
    }
  }
}

Address API

Retrieving specific address data

This API helps you retrieve data of a specific address. 

For example, you can use the following query in IDE to get details of a specific address, say,  0xa9ea63861543ddb45bc192520da0439495427364. This gives you the basic details of the selected address. Specify the network as "Celo_mainnet" and the address as applicable.

{
  ethereum(network: celo_mainnet) {
    address(address: {is: "0xa9ea63861543ddb45bc192520da0439495427364"}) {
      smartContract {
        attributes {
          address {
            address
            annotation
          }
          name
          value
          type
        }
        contractType
        protocolType
        currency {
          decimals
          name
          symbol
          tokenType
        }
      }
      balance
      annotation
      address
    }
  }
}

Retrieving smart contract details of an address

With the Address API, you can also get details of a smart contract address. Just specify the address with the smart contract address as shown in the query below to get the details including balance, contract type, and more. Specify the network as "celo_mainnet" .

For example, the smart contract address we have used in this query is 0xefb84935239dacdecf7c5ba76d8de40b077b7b33. 

{
  ethereum(network: celo_mainnet) {
    address(address: {is: "0xefb84935239dacdecf7c5ba76d8de40b077b7b33"}) {
      smartContract {
        attributes {
          name
          value
          type
          address {
            address
            annotation
          }
        }
        contractType
        protocolType
        currency {
          decimals
          name
          symbol
          tokenType
        }
      }
      balance
      annotation
      address
    }
  }
}

Number of transactions of an address

To check for all the transactions sent or received by an address, use the following query. For example, this query retrieves data for the address, 0xe93685f3bba03016f02bd1828badd6195988d950 as shown below.  Specify the network as "celo_mainnet" and the address as given below.

{
  ethereum(network: celo_mainnet) {
    transactions(
      options: {desc: "block.timestamp.time", limit: 10, offset: 0}
      any: [{txTo: {is: "0xe93685f3bba03016f02bd1828badd6195988d950"}}, {txSender: {is: "0xe93685f3bba03016f02bd1828badd6195988d950"}}]
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      success
      address: to {
        address
        annotation
      }
      gasValue
      gas_value_usd: gasValue(in: USD)
      gasCurrency {
        symbol
      }
      hash
    }
  }
}

Obtaining token balance of an address

You can also use this API to obtain the native token balance of Celo. For example, to find out the token balances of the native token, cGLD (Celo Gold), of an address, say, 0xe93685f3bba03016f02bd1828badd6195988d950, use the following query. Specify the network as "Celo_mainnet" and set the parameter "currency" to cGLD as shown here.

query MyQuery {
  ethereum(network: celo_mainnet) {
    address(address: {is: "0xe93685f3bba03016f02bd1828badd6195988d950"}) {
      native_balance: balance
      balances(currency: {is: "cGLD"}) {
        value
        currency {
          address
          name
          symbol
        }
      }
      smartContract {
        attributes {
          address {
            annotation
            address
          }
        }
      }
    }
  }
}

Address Stats API 

Retrieving smart contract statistics

You can obtain statistical data,  such as smart contract calls, transaction days, amount received or sent, count of transactions, and balance by using this API. 

For example, let's get all the statistics related to an address, 0xe93685f3bba03016f02bd1828badd6195988d950 by using this query.  Specify the network as "Celo_mainnet" and the address as shown.

{
  ethereum (network: celo_mainnet){
    addressStats(address: {is: "0xe93685f3bba03016f02bd1828badd6195988d950"}) {
      address {
        balance
        callTxCount
        calledTxCount
        daysWithReceived
        daysWithSent
        daysWithTransactions
        daysWithTransfers
        feeAmount
        otherTxCount
        receiveAmount
        receiveFromCurrencies
        receiveTxCount
        receiveFromCount
        sendAmount
        sendToCount
        sendToCurrencies
        sendTxCount
      }
    }
  }
}

Arguments API

Obtaining arguments of smart contract calls

To obtain arguments of smart contract calls or events, use this query. This query retrieves all the arguments of the blocks on the Celo chain. Specify the network as "Celo_mainnet" .

{
  ethereum(network: celo_mainnet) {
    arguments(
      smartContractEvent: {is: "PairCreated"}
      options: {desc: "block.height", limit: 6}
    ) {
      block {
        height
      }
      argument {
        name
        type
      }
    }
  }
}

Blocks API

Obtaining number of blocks on the Celo chain

We can get data on blocks on the Celo chain with this API. For example, to retrieve the latest 20 blocks on Celo after 1st of October 2023, use this query. Specify the network as "Celo_mainnet" and the date as applicable.

{
  ethereum (network: celo_mainnet){
    blocks(
      options: {limit: 20, desc: "timestamp.iso8601"}
      date: {after: "2023-10-01T00:00:00Z"}
    ) {
      gasLimit
      height
      hash
      timestamp {
        iso8601
      }
      difficulty
      size
      reward
      uncleCount
      transactionCount
      totalDifficulty
    }
  }
}

To get a specific block's data, simply specify the "height" parameter to the required block ID in the above query. 

Coinpath API 

Tracking fund movement

To find out the money flow between addresses, use the coinpath API. This will retrieve data related to the amount transacted, number of transactions, amount sent or received, sender and receivers. For example, to obtain the fund movement of this address, 0xccbfd3e39bf646c8eee2dfd1ae59896701526a31, since the beginning of January 2024, use this query. Specify the network as "Celo_mainnet" , address, and the dates as applicable.

query ($network: EthereumNetwork!, $address: String!, $inboundDepth: Int!, $outboundDepth: Int!, $limit: Int!, $currency: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    inbound: coinpath(
      initialAddress: {is: $address}
      currency: {is: $currency}
      depth: {lteq: $inboundDepth}
      options: {direction: inbound, asc: "depth", desc: "amount", limitBy: {each: "depth", limit: $limit}}
      date: {since: $from, till: $till}
    ) {
      sender {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      receiver {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      amount
      currency {
        symbol
      }
      depth
      count
    }
    outbound: coinpath(
      initialAddress: {is: $address}
      currency: {is: $currency}
      depth: {lteq: $outboundDepth}
      options: {asc: "depth", desc: "amount", limitBy: {each: "depth", limit: $limit}}
      date: {since: $from, till: $till}
    ) {
      sender {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      receiver {
        address
        annotation
        smartContract {
          contractType
          currency {
            symbol
            name
          }
        }
      }
      amount
      currency {
        symbol
      }
      depth
      count
    }
  }
}

DEX API

This API enables you to extract DEX trade information from Ethereum blockchains. 

Retrieving trade data from Celo chain

To obtain the DEX trade data on Celo for the month of January 2024, use this query. Specify the network as "Celo_mainnet" and the date as applicable.

query ($network: EthereumNetwork!, $limit: Int!, $offset: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    dexTrades(
      options: {desc: ["block.height", "tradeIndex"], limit: $limit, offset: $offset}
      time: {since: $from, till: $till}
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      tradeIndex
      protocol
      exchange {
        fullName
      }
      smartContract {
        address {
          address
          annotation
        }
      }
      buyAmount
      buyCurrency {
        address
        symbol
      }
      buy_amount_usd: buyAmount(in: USD)
      sellAmount
      sellCurrency {
        address
        symbol
      }
      sell_amount_usd: sellAmount(in: USD)
      transaction {
        hash
      }
    }
  }
}

Traded Currencies on Celo

To see all the traded currencies over a period of time, use this API. For example, to see the number of currencies over a period of 1 month (Jan 2024), use this query. Specify the network as "Celo mainnet" and dates as applicable.

query ($network: EthereumNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    dexTrades(
      options: {asc: "date.date"}
      date: {since: $from, till: $till}
      tradeAmountUsd: {}
    ) {
      date: date {
        date(format: $dateFormat)
      }
      trades: countBigInt
      traders: countBigInt(uniq: takers)
      contracts: countBigInt(uniq: smart_contracts)
      currencies: countBigInt(uniq: buy_currency)
      count
    }
  }
}

Trades by Protocol on Celo

If you want to know the trades by protocol, say Uniswap or Balancer, use this API to get the data. For example, in this query, we are retrieving the number of trades by each protocol since the start of the current month. Specify the network as "Celo mainnet" and dates as applicable.

query ($network: EthereumNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    dexTrades(options: {asc: "date.date"}, date: {since: $from, till: $till}) {
      date: date {
        date(format: $dateFormat)
      }
      protocol
      count
    }
  }
}

To filter the trades by a specific protocol, such as Uniswap or Balancer, filter the above query using the protocol parameter and specify the protocol as required. 

Similarly, you can get trade data on token pairs, trade pairs, and more using the Bitquery explorer and DEX API filters. Learn more here.

Smart Contracts API

The Smart contract API  enables you to get all the smart contract calls made on the Celo network. 

Obtaining list of all smart contract calls on Celo

To obtain all the smart contract calls for the past month on the Avalanche blockchain, use the following query in IDE. Specify the network as "Celo mainnet" and provide the dates as required for the "since" and the "till" parameter as shown.

query ($network: EthereumNetwork!, $limit: Int!, $offset: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    smartContractCalls(
      options: {desc: "block.height", limit: $limit, offset: $offset}
      date: {since: $from, till: $till}
      external: true
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      address: caller {
        address
        annotation
      }
      arguments {
        argument
        value
      }
      callDepth
      smartContract {
        address {
          address
          annotation
        }
      }
      smartContractMethod {
        name
        signatureHash
      }
      transaction {
        hash
      }
      count
    }
  }
}

Retrieving number of unique smart contract calls on Celo

To obtain unique smart contract calls on the Celo chain during a specific week, use the following query in IDE. Replace the "from" and "till" variables with the dates you want. Replace the variable network with "Celo_mainnet". 

query ($network: EthereumNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    smartContractCalls(
      options: {asc: "date.date"}
      date: {since: $from, till: $till}
    ) {
      date: date {
        date(format: $dateFormat)
      }
      count: countBigInt
      contracts: countBigInt(uniq: smart_contracts)
      callers: countBigInt(uniq: senders)
      methods: countBigInt(uniq: smart_contract_methods)
    }
  }
}

Obtaining all calls for a specific smart contract

Similarly, you can query for calls from a specific smart contract. For example, if you want to know all the calls for a smart contact address "0x43d72ff17701b2da814620735c39c620ce0ea4a1", from 1st January to 24 January, use the following query in IDE. Specify the network as "Celo mainnet" and dates as applicable.

query ($network: EthereumNetwork!, $address: String!, $limit: Int!, $offset: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    smartContractCalls(
      options: {desc: "block.timestamp.time", limit: $limit, offset: $offset}
      date: {since: $from, till: $till}
      smartContractAddress: {is: $address}
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      smartContractMethod {
        name
        signatureHash
      }
      smartContract {
        address {
          address
          annotation
        }
      }
      transaction {
        hash
      }
      external
      gasValue
      gas_value_usd: gasValue(in: USD)
    }
  }
}

Similarly, you can have specific queries for method calls by specific addresses and specific smart contracts. Learn more here

Obtaining top callers of smart contracts

The Smart Contracts API also helps you obtain who the top callers of a smart contract are, which includes the number of calls by each caller, date of the call, and the gas costs incurred. 

For example, to find out the top callers of the smart contract, agEUR contract for the past 15 days, build the query as follows in the IDE. Replace the network variable with "Celo_mainnet" and the smart contract address as 0xc16b81af351ba9e64c1a069e3ab18c244a1e3049. Specify the from and to dates as required. 

query ($network: EthereumNetwork!, $address: String!, $limit: Int!, $offset: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    smartContractCalls(
      options: {desc: "count", limit: $limit, offset: $offset}
      date: {since: $from, till: $till}
      caller: {is: $address}
    ) {
      smartContract {
        address {
          address
          annotation
        }
        contractType
      }
      max_date: maximum(of: date)
      count
      uniq_methods: count(uniq: smart_contract_methods)
      gasValue(calculate: average)
      gas_value_usd: gasValue(in: USD, calculate: average)
    }
  }
}

Smart Contract Events API

This API returns information on smart contract events. 

For example, to obtain all the latest events for a specific smart contract, say 0xc16b81af351ba9e64c1a069e3ab18c244a1e3049, for the past 15 days, use this query in IDE. Specify the network as Celo-mainnet and dates as applicable.

query ($network: EthereumNetwork!, $address: String!, $limit: Int, $offset: Int, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    smartContractEvents(
      options: {desc: "count", limit: $limit, offset: $offset}
      date: {since: $from, till: $till}
      smartContractAddress: {is: $address}
    ) {
      smartContractEvent {
        name
        signature
        signatureHash
      }
      count
      max_date: maximum(of: date)
    }
  }
}

Celo Transactions API

Retrieving latest transactions on Celo

To obtain the 10 current transactions on Celo, use this query. Specify the network as "Celo_mainnet" and the current date as applicable.

query ($network: EthereumNetwork!, $limit: Int!, $offset: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    transactions(
      options: {desc: "block.height", limit: $limit, offset: $offset}
      time: {since: $from, till: $till}
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      address: sender {
        address
        annotation
      }
      hash
      gasValue
      gas_value_usd: gasValue(in: USD)
    }
  }
}

Gas Spent on Celo Transactions

To view the amount of gas spent by the transactions on Celo, check this query. In this example, we are retrieving data on the amount of gas spent in the current month. Specify the network as "Celo_mainnet'' and the dates as applicable. Use the parameters count and gasvalue to obtain the required data. 

query ($network: EthereumNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    transactions(options: {asc: "date.date"}, date: {since: $from, till: $till}) {
      date: date {
        date(format: $dateFormat)
      }
      count: countBigInt
      gasValue
    }
  }
}

Top Gas Burners

To see which smart contracts are burning the most gas, build this query.  This query retrieves top gas burners from 15th January to 25th january 2024. Specify the network as "Celo_mainnet'' and the dates as applicable. Use parameters gasValue and count to calculate the average costs as shown here. 

query ($network: EthereumNetwork!, $limit: Int!, $offset: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    smartContractCalls(
      options: {desc: "gasValue", limit: $limit, offset: $offset}
      date: {since: $from, till: $till}
      external: true
    ) {
      smartContract {
        address {
          address
          annotation
        }
      }
      gasValue
      gas_value_usd: gasValue(in: USD)
      average: gasValue(calculate: average)
      average_usd: gasValue(in: USD, calculate: average)
      count
    }
  }
}

You can also determine the gas cost of a specific address by specifying the smart contract address in the above query.

Transfers API

This API helps you get data on token transfers on Celo. You can get data regarding the transferred amount, the currency, unique senders, receivers and more. 

Top Token Transfers on Celo

To see the latest tokens transferred on Celo, use the following query. Specify the network as "Celo_mainnet'' and the dates as applicable. In this query, we retrieve the token transfers done till date starting from January 2024. 

query ($network: EthereumNetwork!, $limit: Int!, $offset: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    transfers(
      options: {desc: "count", limit: $limit, offset: $offset}
      amount: {gt: 0}
      time: {since: $from, till: $till}
    ) {
      currency {
        symbol
        address
      }
      count
      senders: count(uniq: senders)
      receivers: count(uniq: receivers)
      amount
      amount_usd: amount(in: USD)
    }
  }
}

Largest transfers on Celo

You can also retrieve data on the maximum amount that was transferred during a specific time period by using this query.

For example, to see the highest amount transferred during a month (1st Dec 2023 to 25th Jan 2024), build this query. Specify the network as Celo_mainnet, currency as "cGLD", dates as required, and use the parameter "max_amount" to determine the highest transfer amount on Celo. 

{
  ethereum(network: celo_mainnet) {
    transfers(
      date: {after: "2023-12-01", before: "2024-12-25"}
      currency: {is: "cGLD"}
      height: {gt: 0}
    ) {
      max_amount: maximum(of: amount, get: amount)
    }
  }
}

You can also use the API to build queries for obtaining transfers to and from addresses. Learn more here

Token API

List of all tokens traded on Celo

To obtain the current tokens traded on Celo, use this query. Specify the network as "Celo_mainnet" and the current date as required. You can get the data on unique receivers and senders, number of transfers and the amount transferred.

query ($network: EthereumNetwork!, $limit: Int!, $offset: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    transfers(
      options: {desc: "count", limit: $limit, offset: $offset}
      amount: {gt: 0}
      time: {since: $from, till: $till}
    ) {
      currency {
        symbol
        address
      }
      count
      senders: count(uniq: senders)
      receivers: count(uniq: receivers)
      amount
      amount_usd: amount(in: USD)
    }
  }
}

Daily Celo token transfers

To retrieve daily transfers of Celo's native crypto cGLD from January 1st 2024 till date, use the following query. Specify the network as "Celo_mainnet" and the dates as required to obtain the number of daily transfers.

query ($network: EthereumNetwork!, $token: String!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    transfers(
      currency: {is: $token}
      height: {gt: 0}
      amount: {gt: 0}
      date: {since: $from, till: $till}
    ) {
      date {
        date(format: $dateFormat)
      }
      count: countBigInt
      amount
    }
  }
}

Daily Celo token pair trades

You can retrieve all trades of token pairs on Celo. For example, to get data on token pairs of cGLD traded during 1st Jan 2024 to 10th Dec 2024, check this query. Specify the network as "Celo_mainnet" and dates as applicable. Specify the token as "cGLD" to get the required data.

query ($network: EthereumNetwork!, $dateFormat: String!, $token: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    dexTrades(
      options: {asc: "date.date"}
      date: {since: $from, till: $till}
      baseCurrency: {is: $token}
    ) {
      date: date {
        date(format: $dateFormat)
      }
      trades: countBigInt
      amount: baseAmount
      baseCurrency {
        symbol
      }
      contracts: countBigInt(uniq: smart_contracts)
      currencies: countBigInt(uniq: quote_currency)
    }
  }
}

Latest token price on Celo

As USD isn't available on blockchains, you can use this API to derive the token price in USD.  

For example, to obtain the latest token price of Celo's native currency (cGLD), use the following query. Specify the token address as 0x62b8b11039fcfe5ab0c56e502b1c372a3d2a9c7a (Good dollar token in Celo), which is the base currency and specify the network as Celo_mainnet. Specify the quote currency as "cGLD "to get the price in USD.

query get_token_price_in_usd($token: String) {
  ethereum(network: celo_mainnet) {
    dexTrades(
      baseCurrency: {is: $token}
      quoteCurrency: {is: "cGLD"}
      options: {desc: ["block.height"], limit: 1}
    ) {
      block {
        height
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
      }
      baseCurrency {
        symbol
      }
      quoteCurrency {
        symbol
      }
      quotePrice
      quoteAmountInUSD: quoteAmount(in: USD)
      baseAmount
      quotePriceInUSD: expression(get: "quoteAmountInUSD / baseAmount")
      exchange {
        fullNameWithId
        address {
          address
          annotation
        }
      }
    }
  }
}

Mining API

This API extracts mining information on Celo, including the number of miners, blocks produced by them and so on. 

Obtaining unique miners on Celo

In this example, let's get the data on the number of unique miners on Celo. To do so, build this query in IDE. Here, we will specify dates to get the number of unique miners on those  days, say 24th January and 25h January. Specify the network as "Celo_mainnet" . 

query ($network: EthereumNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    blocks(
      options: {asc: "date.date"}
      date: {since: $from, till: $till}
      height: {gt: 0}
    ) {
      date: date {
        date(format: $dateFormat)
      }
      count: countBigInt(uniq: miners)
      reward
      usd: reward(in: USD)
      difficulty(calculate: median)
    }
  }
}

Distribution of miners

This API also enables you to get data on the number of blocks produced by miners over a period of time. 

For example, to get the number of block count distributions of a specific miner address, say, 0x0c01dc28d19f83d0a45223ec844674b96ea086a5 for the past 5 days, use the following query in IDE. Specify the network as "Celo_mainnet" and set the dates to the one you require, say, 20-25 January 2024.

query ($network: EthereumNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    blocks(
      options: {asc: "date.date"}
      date: {since: $from, till: $till}
      height: {}
      miner: {is: "0x0c01dc28d19f83d0a45223ec844674b96ea086a5"}
    ) {
      address: miner {
        address
        annotation
      }
      date {
        date(format: $dateFormat)
      }
      count
      reward
    }
  }
}

Number of block rewards

If available, you can also see the rewards per block in USD for a  selected period. For example, to see the block rewards from Dec 2023 till date, use the following query. Specify the network as "Celo_mainnet", dates as applicable, and the USD parameter as shown here. 

query ($network: EthereumNetwork!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    blocks(
      options: {asc: "date.date"}
      date: {since: $from, till: $till}
      height: {}
    ) {
      date: date {
        date(format: $dateFormat)
      }
      count: countBigInt(uniq: miners)
      reward
      usd: reward(in: USD)
      difficulty(calculate: median)
    }
  }
}

Similarly, you can also obtain reward data for a specific block by specifying the height parameter.

Conclusion

As you can see, Celo is a powerful tool that can revolutionize financial services, especially on mobile phones. With its mobile-friendly design, stablecoins, and commitment to accessibility, the Celo API is poised to play a pivotal role in financial inclusion on a global scale.

As developers continue to explore its capabilities, the potential for transformative applications and positive impact becomes prominent. Explore and analyze all this and more on Celo through the Bitquery APIs. We've listed key ones in this article to get you started.

About Bitquery

Bitquery is a set of software tools that parse, index, access, search, and use information across blockchain networks in a unified way. Our products are:

  • Coinpath® APIs provide blockchain money flow analysis for more than 24 blockchains. With Coinpath’s APIs, you can monitor blockchain transactions, investigate crypto crimes such as bitcoin money laundering, and create crypto forensics tools. Read this to get started with Coinpath®.
  • Digital Assets API provides index information related to all major cryptocurrencies, coins, and tokens.
  • DEX API provides real-time deposits and transactions, trades, and other related data on different DEX protocols like Uniswap, Kyber Network, Airswap, Matching Network, etc.

If you have any questions about our products, ask them on our Telegram channel or email us at sales@bitquery.io. Also, subscribe to our newsletter below, we will keep you updated with the latest in the cryptocurrency world.

Subscribe to our newsletter

Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.