Group *Transactions by hours/minutes? / "Cannot return null for non-nullable field EthereumTransactions.gasPrice"

Hello everybody,

I’m experimenting with retrieving average gas/fee prices in time intervals. One problem I encountered especially with smaller intervals is, that for some slow blockchains (like bitcoin), the intervals become so small, that there are no blocks or transactions processed during this time, and gasPrice becomes null. The field is set as not nullable, thus resulting in an error. This impedes my workflow and I have no reliable means to avoid this error, than to increase my intervals, as it seems.

{‘message’: ‘Cannot return null for non-nullable field EthereumTransactions.gasPrice’}

I would like this field to be nullable. If there are multiple calls to “gasPrice” in one query, it should be imho OK if one of them is null.

Can you show us which query you are trying?

One in the fashion of:

{
  ethereum(network: ethereum) {
    t0: transactions(
      time: {since: "2021-05-26T10:00:00+00:00", till: "2021-05-26T10:05:00+00:00"}
    ) {
      gasPrice
    }
    t1: transactions(
      time: {since: "2021-05-26T10:05:00+00:00", till: "2021-05-26T10:10:00+00:00"}
    ) {
      gasPrice
    }
    t2: transactions(
      time: {since: "2021-05-26T10:10:00+00:00", till: "2021-05-26T10:15:00+00:00"}
    ) {
      gasPrice
    }
  }
}

where t1, t2, … tn are 5 (15, 30, 60) minute intervals. I needed to use this hack, as it was only possible to get down to daily grouped data with the “date” field, but maybe I misunderstood the example:

{
  bitcoin {
    transactions(options: {asc: "date.date"}) {
      date: date {
        date(format: "%Y")
      }
      count: count
      feeValue
      avgFee: feeValue(calculate: average)
    }
  }
}

If you wanna group by date then check examples on this page, Click on the graphql button at bottom left of the widgets to check the query

Yes, this is exactly what the second example is doing. Problem is, that the smallest granularity available on date “days” are. How do I get smaller granularities?

So as I understand you are getting error for smaller timeframe, I have raised this issue with dev team.

1 Like

Hi there, I tested other timeframes as well and also to select 24h worth of transactions to get their average gasPrice for Ethereum. Selecting only the last 24h also gave me a non-nullable exception.

While you are searching for the problem, would it be allowed to make the field EthereumTransactions.gasPrice nullable? I’m really hindered right now because of this but could handle potential nulls in selected timespans. I would be immensely grateful if that were possible!

Let me pass this to the dev team.

Update to the possible reasons those calls fail: I tried several combinations and the requests seem to fail, when crossing the day boundary from 24:00 to 00:01. Also, this seems to happen with EthereumTransactions, but not BitcoinTransactions.
I hope this helps! :slight_smile:

1 Like