Cover Image for Querying Conflux Blockchain using GraphQL APIs

Querying Conflux Blockchain using GraphQL APIs

Bitquery APIs

Conflux launched its mainnet Tethys in Oct 2020, and today we will show you how to query the Conflux network using our GraphQL APIs.

The APIs in this article are just the tip of the iceberg, you can query any on-chain data for the Conflux network using our APIs. Besides, check out our Conflux blockchain explorer.

Conflux blocks

Let’s start simple and check the daily blocks on the Conflux network. You can use the following query for this.

{
  conflux {
    blocks(
      options: { desc: "height", asc: "address.address", limit: 10, offset: 0 }
      time: { after: "2023-10-10" }
    ) {
      timestamp {
        time(format: "%Y-%m-%d %H:%M:%S")
      }
      height
      epoch
      hash
      pivot
      transactionCount
      address: miner {
        address
        annotation
      }
    }
  }
}

As you can see, the Conflux network produced more than 5 million blocks in November.

Conflux transaction by date

Now, let’s check the number of transactions the Conflux network processing every day.

{
  conflux {
    transactions(
      options: {
        desc: "block.height"
        asc: "address.address"
        limit: 10
        offset: 0
      }
      time: { after: "2023-10-10" }
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
        hash
      }
      address: sender {
        address
        annotation
      }
      hash
      gasValue
      gas_value_usd: gasValue(in: USD)
    }
  }
}

Conflux blockchain token transfers in USD

As we mentioned above, the Conflux blockchain launched just a few weeks before, so let’s check token transfers in USD

{
  conflux {
    transfers(
      options: {
        desc: "block.height"
        asc: "currency.symbol"
        limit: 10
        offset: 0
      }
      time: { since: "2023-10-10", till: "2023-10-11" }
      amount: { gt: 0 }
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      sender {
        address
        annotation
      }
      receiver {
        address
        annotation
      }
      currency {
        address
        symbol
      }
      amount
      amount_usd: amount(in: USD)
      transaction {
        hash
      }
      external
    }
  }
}

As you can see, the volume on the network increased multifold in December.

Conflux Gas spent by date

As shown above, Conflux processed more than 1.12 million transactions in the month of November. Let’s see how much Gas (transaction fee) was used to process these transactions.

{
  conflux {
    transactions(
      options: { asc: "date.date" }
      date: { since: "2023-10-04", till: "2023-10-11T23:59:59" }
    ) {
      date: date {
        date(format: "%Y-%m-%d")
      }
      count: countBigInt
      gasValue
    }
  }
}

As you can see, the total transaction fee was less than $5 for 1.12 million transactions.

Unique smart contracts deployed on Conflux

Conflux is a smart contract blockchain and supports Solidity. In other words, you can write Solidity smart contracts and deploy them on the Conflux network. Let’s see how many unique smart contracts are already deployed on the Conflux network.

{
  conflux {
    smartContractCalls {
      count(uniq: smart_contracts)
    }
  }
}

Top Conflux tokens based on transfer count

It’s been a month since the launch of Conflux mainnet, and there are plenty of tokens already deployed on the network. Let’s see top Conflux tokens based on the number of transfers.

{
  conflux {
    transfers(
      options: { desc: "count", limit: 10, offset: 0 }
      time: { since: "2023-09-10", till: "2023-10-11" }
    ) {
      currency {
        address
        symbol
      }
      count(uniq: transfers)
    }
  }
}

Conflux active addresses

Active addresses is one of the critical metrics to understand the growth and usage of any blockchain. So let’s see how to query active addresses on the Conflux network.

{
  conflux {
    activeAddresses(
      options: { limit: 10, desc: "count" }
      date: { after: "2023-10-10" }
    ) {
      address {
        address
        annotation
      }
      count(uniq: address)
    }
  }
}

Data aggregation

Usually, we need to aggregate different properties while analyzing any dataset. For example, when querying Conflux blockchain, we might ask questions like “What is the average or median Gas fee on the blockchain.” To get this, let me show you how to perform aggregation using our GraphQL APIs.

{
  conflux {
    transfers(
      options: { limit: 30, desc: "date.date" }
      date: { since: "2023-09-01" }
      currency: { is: "cfx:accebz8w353x5940c1c4w0f5827f61vjv2ehk8ngv2" }
    ) {
      average: amount(calculate: average)
      median: amount(calculate: median)
      date {
        date(format: "%y-%m-%d")
      }
    }
  }
}

Conflux blockchain data and APIs

We just showed you how to get primary on-chain data for the Conflux network. Additionally, our GrpahQL APIs have comprehensive coverage for the Conflux blockchain data, and you can build more complex APIs using Bitquery IDE.

If you have any questions or building any application on the Conflux network, join our Telegram group and let us know.

You might also be interested in:

About Bitquery

Bitquery is your comprehensive toolkit designed with developers in mind, simplifying blockchain data access. Our products offer practical advantages and flexibility.

  • APIs - Explore API: Easily retrieve precise real-time and historical data for over 40 blockchains using GraphQL. Seamlessly integrate blockchain data into your applications, making data-driven decisions effortless.
  • Coinpath® - Try Coinpath: Streamline compliance and crypto investigations by tracing money movements across 40+ blockchains. Gain insights for efficient decision-making.
  • Data in Cloud - Try Demo Bucket: Access indexed blockchain data cost-effectively and at scale for your data pipeline. We currently support Ethereum, BSC, Solana, with more blockchains on the horizon, simplifying your data access.
  • Explorer - Try Explorer: Discover an intuitive platform for exploring data from 40+ blockchains. Visualize data, generate queries, and integrate effortlessly into your applications.

Bitquery empowers developers with straightforward blockchain data tools. If you have questions or need assistance, connect with us on our Telegram channel or via email at sales@bitquery.io. Stay updated on the latest in cryptocurrency by subscribing to our newsletter below.

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.