A Beginner's Guide To Exploring Ethereum Mainnet Data

A Beginner’s Guide To Exploring Ethereum Mainnet Data

What is the Bitquery Explorer?

Bitquery Explorer is a visual dashboard that allows users to view a list of different blockchain projects and smart contracts.

To access the project dashboard, follow these steps:

When you open the tab, you will see a list of various sub-tabs, including Blocks, Gas Analytics, Transfers, Protocols, and others. Each focusing on various aspects of the blockchain data.

You can see the date range for which the data is displayed at the top right of the screen.

Let’s say you want to explore the data on Gas prices, click on the tab ‘Gas Analytics’

Click on the “Get API” button at the bottom of any graph that you want to understand. This will open a GraphQL IDE tab.

Analysing Data With the GraphQL IDE

The IDE

Bitquery has a custom GraphQL online IDE (GraphQL IDE ) that allows you to create a query using the helper tab on the side.

A query is shown below that fetches transaction counts for different protocols with trade amounts greater than 1.5 since yesterday.


query MyQuery {

  ethereum(network: matic) {

    dexTrades(

      buyAmount: {gt: 1.5}

      any: {date: {after: "2022-10-24"}} #add yesterday's date in after

    ){

      #what data you want to see for the criteria

       protocol

      trades: count

     

    }

  }

  }


The response would look something like this:

# Sample Response

{

  "ethereum": {

    "dexTrades": [

      {

        "protocol": "Balancer Pool Token",

        "trades": 672

      },

      {

        "protocol": "Balancer v2",

        "trades": 50586

      },

      {

        "protocol": "Dodo",

        "trades": 6809

      },

      {

        "protocol": "Mooniswap",

        "trades": 64

      },

      {

        "protocol": "Uniswap",

        "trades": 97

      },

      {

        "protocol": "Uniswap v2",

        "trades": 734936

      },

      {

        "protocol": "Uniswap v3",

        "trades": 674756

      },

      {

        "protocol": "Zerox Exchange v2",

        "trades": 1

      },

      {

        "protocol": "Zerox Exchange v4",

        "trades": 9

      }

    ]

  }

}

1. Prebuilt Queries

Click on “Get API” button below a chart to view the GraphQL query. You can use these prebuilt queries to modify and create your own.

For example, the below query fetches all transactions on the Ethereum Network between two given dates. Parameters “from” and “till” are used to set the date range.


query ($network: EthereumNetwork!, $limit: Int!, $offset: Int!, $from: ISO8601DateTime, $till: ISO8601DateTime) {

  ethereum(network: $network) {

    blocks(

      options: {desc: "height", limit: $limit, offset: $offset}

      date: {since: $from, till: $till}

    ) {

      timestamp {

        time(format: "%Y-%m-%d %H:%M:%S")

      }

      height

      transactionCount

      address: miner {

        address

      }

      reward

      reward_usd: reward(in: USD)

      rewardCurrency {

        symbol

      }

    }

  }

}

# Parameters

{

  "limit": 10,

  "offset": 0,

  "network": "ethereum",

  "from": "2022-10-31",

  "till": "2022-11-07T23:59:59",

  "dateFormat": "%Y-%m-%d"

}

2. Exploring Custom Queries by Other Contributors

There is a “Explore” button at the top of the GraphQL IDE. Clicking it will open a community-based space to find and contribute queries.

Querying Information on DEX

Trading orders on decentralised exchanges are done without the involvement of any intermediaries thanks to smart contracts. Uniswap, for example, uses two smart contracts: an “Exchange” contract and a “Factory” contract. They are automatic computer programs that perform specific functions when certain conditions are met.

Where does a protocol come into picture?

Protocols are merely predefined rules (properties and methods) that smart contracts must follow in order to be implemented. It is up to the contract to implement the methods in accordance with the protocol.

1.Trades Executed on the Ethereum Network

Let’s use a GraphQL to query the Ethereum network for the smart contract information related to trades executed after a particular day. Let us limit it to 10 for now.


query MyQuery {

  ethereum(network: ethereum) {

    dexTrades(options: {limit: 10, desc: "noOftrades"}, time: {after: "yyyy-mm-dd"}) {

      noOftrades: count

      smartContract {

        contractType

        protocolType

      }

    }

  }

}




Here's how a sample response would look:

{

  "ethereum": {

    "dexTrades": [

      {

        "noOftrades": 9035,

        "smartContract": {

          "contractType": "DEX",

          "protocolType": "Uniswap v3"

        }

      },

      {

        "noOftrades": 4300,

        "smartContract": {

          "contractType": "DEX",

          "protocolType": "Uniswap v3"

        }

      },

      {

        "noOftrades": 3379,

        "smartContract": {

          "contractType": "DEX",

          "protocolType": "Uniswap v2"

        }

      },

      {

        "noOftrades": 2601,

        "smartContract": {

          "contractType": "DEX",

          "protocolType": "Uniswap v2"

        }

      },

      {

        "noOftrades": 2381,

        "smartContract": {

          "contractType": "DEX",

          "protocolType": "Balancer v2"

        }

      },

      {

        "noOftrades": 1529,

        "smartContract": {

          "contractType": "DEX",

          "protocolType": "Uniswap v2"

        }

      },

      {

        "noOftrades": 1519,

        "smartContract": {

          "contractType": "DEX",

          "protocolType": "Uniswap v2"

        }

      },

      {

        "noOftrades": 1352,

        "smartContract": {

          "contractType": "DEX",

          "protocolType": "Uniswap v2"

        }

      },

      {

        "noOftrades": 1276,

        "smartContract": {

          "contractType": "DEX",

          "protocolType": "Uniswap v2"

        }

      },

      {

        "noOftrades": 1230,

        "smartContract": {

          "contractType": "DEX",

          "protocolType": "Uniswap v2"

        }

      }

    ]

  }

}

2.Latest Trades of a Specific Currency Pair on a DEX Protocol

Now let’s look at the latest trade for SHIBA INU currency exchanged for ELON. In the buyCurrency and sellCurrency fields we include the ERC20 smart contract addresses for the respective coins. Let’s set the Limit to 1 as an example.


query MyQuery

{

  ethereum(network: ethereum) {

    dexTrades(options: {limit: 1, desc: ["block.height", "tradeIndex"]},

      buyCurrency: {is: "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce"},

      sellCurrency: {is: "0x761d38e5ddf6ccf6cf7c55759d5210750b5d60f3"}) {

      block {

        height

      }

     

      tradeIndex

      buyCurrency {

        symbol

        address

      }

      buyAmount

      sellCurrency {

        symbol

        address

      }

      sellAmount

      maker {

        address

        annotation

      }

      taker {

        address

        annotation

      }

      protocol

      smartContract {

        contractType

      }

    }

  }

}


Here's how a sample response would look:

{

  "ethereum": {

    "dexTrades": [

      {

        "block": {

          "height": 15882729

        },

        "tradeIndex": "5",

        "buyCurrency": {

          "symbol": "SHIB",

          "address": "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce"

        },

        "buyAmount": 8764577.259475216,

        "sellCurrency": {

          "symbol": "ELON",

          "address": "0x761d38e5ddf6ccf6cf7c55759d5210750b5d60f3"

        },

        "sellAmount": 225712672.7571007,

        "maker": {

          "address": "0x1111111254fb6c44bac0bed2854e76f90643097d",

          "annotation": null

        },

        "taker": {

          "address": "0xe40bca0dbe12d1fbd601ed26e7deb7b46373db77",

          "annotation": null

        },

        "protocol": "Uniswap v2",

        "smartContract": {

          "contractType": "Token"

        }

      }

    ]

  }

}

Analysing An Address

Navigate to the Ethereum Mainnet dashboard from the explorer.

Under the “Transactions” tab, you will find the sender’s address listed. Let us pick one such address and investigate it.

Now click on the “Money Flow” tab to visualize the transfer of one currency from other addresses to the current.

  • Using the Detail Level slider, you can adjust the count of inbound flows.

  • With the Depth Level “inbound”/“outbound” selector, you can increase or decrease the depth of transfers from/to the current address.

If you have any questions about our products, ask them on our Telegram channel or email us at hello@bitquery.io. Don’t forget to subscribe to our newsletter to stay updated on the latest news in the cryptocurrency world.

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.