Skip to content

BigQuery, Google Cloud and dbt to analyze and visualize data from the Bitcoin Cash cryptocurrency blockchain. SQLFluff is also implemented in the Github workflow

Notifications You must be signed in to change notification settings

clementmariebrisson/bitcoin-cash-challenge

Repository files navigation

Bitcoin Cash Challenge - Astrafy

Bitcoin Cash is a cryptocurrency that allows more bytes to be included in each block relative to its common ancestor Bitcoin. There is a public dataset on BigQuery that contains the blockchain data in their entirety (dataset ID: bigquery-public-data.crypto_bitcoin_cash) with data pre-processed to be human-friendly and to support common use cases such as auditing, investigating, and researching the economic and financial properties of the system.

Project Overview

In this project, we will create staging table from the raw table "transactions" that only selects the last three months of data from this raw table. Then we will, materialize a datamart table that gives the current balance for all addresses and exclude addresses that had at least one transaction on Coinbase. Finally we will display a graph of daily transactions. We will use dbt cloud to materialize the two tables aforementioned and a Google colab notebook using Python to plot the chart of daily transactions from last 3 months.

Prerequisites

  • A Google Cloud account with access to BigQuery and Cloud Storage.
  • A dbt Cloud account.

Getting Started

To get started with this project, follow these steps:

  1. Create a new Google Cloud project.
  2. Configure your Google Cloud and dbt Cloud
  3. Use dbt Cloud to materialize the staging and datamart tables.
  4. Create a notebook to plot the transactions of last 3 months.

dbt

To Run staging table model on dbt Cloud
dbt run --models STG_bitcoin_cash_transactions_3M

To Run datamart model

dbt run --models DTM_bitcoin_cash_transactions_3M

Drizly's SQLFluff

SQLFluff is a SQL linter and auto-formatter that can help you catch errors and enforce consistent style in your SQL code. It supports a variety of SQL dialects and can be easily integrated into your workflow using Github Actions.

To use SQLFluff on Github Actions, you need to create a new workflow file in your repository like this one lint_sqlfluff.yml


This workflow uses the sqlfluff package to lint any SQL files in your /models directory that have been added or modified in the latest push or pull request on the main branch. It also uses the yuzutech/annotations-action to annotate your Github pull request with any lint errors found by SQLFluff.

To use this workflow in your own repository, you need to make sure to update the file paths and any other parameters such as --dialect bigquery to match your specific project.

Terraform

Terraform is an open-source infrastructure as code (IaC) tool that allows you to manage your infrastructure, with the possibility to works with many popular cloud providers, including AWS, Azure, Google Cloud Platform. If you want to set up a Terraform based infrastucture you can follow these 2 steps:
  1. Install Terraform
  2. Terraform - Get Started with GCP
  3. Add Terraform to your path
  4. Create a terraform.tfvar file and replace GCP project ID and the path to your key file:
project                  = "<PROJECT_ID>"
credentials_file         = "<FILE>"
  1. Go to terraform-docker-container/ and execute ./setup.bash
  2. Anytime you modify your configuration execute terraform apply

Once you are finished with Terraform, don't forget to terminate resources by executing terraform destroy

The amount of transactions

As we are dealing with transactions, we have some incomes and somes outcomes. This is why I decided to plot 3 graphs : incomes, outcomes and the global balance.

INCOMES

OUTCOMES

TOTAL

References

About

BigQuery, Google Cloud and dbt to analyze and visualize data from the Bitcoin Cash cryptocurrency blockchain. SQLFluff is also implemented in the Github workflow

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages