Valuable Public Blockchain are Harder to Attack

Using R and Python to visualize the relationship between Market Cap and Hourly Cost to Attack

Image by Author

Overview

In this post, I use Python and R to access, parse, manipulate, then visualize data from Crypto51.app to show the strong relationship between Market Capitalization and Cost to Attack among public crypto networks.

Data

In this post, I query an API endpoint setup at Crypto51.app to get JSON data. Then, I use Python to parse and convert to dataframe. Finally, I use R to wrangle and visualize.

import pandas as pd
import json
import requests
r = requests.get('https://api.crypto51.app/coins.json')
dct = dict()
dct = r.json()
# loop through:
# last_updated
# coins
for x, y in dct.items():
print(x)
type(dct['coins']) # list
len(dct['coins']) # 57 dictionaries in side this list
# convert list of 57 dictionaries into a pandas dataframe
df = pd.DataFrame.from_dict(dct['coins'])
df.head()
df.to_csv('crypto51.csv', index=False)
library(tidyverse)df <- read_csv("crypto51.csv")df %>%
# remove projects with no market_cap
slice(1:38) %>%
filter(attack_hourly_cost != "?") %>%
# change character to numeric
mutate(
attack_hourly_cost = as.numeric(attack_hourly_cost)
) %>%
ggplot(aes(x=market_cap, y=attack_hourly_cost)) +
geom_point(aes(size = log10(market_cap)), color = "white", alpha = 0.8) +
# use log10 transformation to make chart more interpretable
scale_y_log10(label= scales::dollar) +
scale_x_log10(label= scales::dollar) +
theme_minimal() +
theme(
legend.position = 'none',
panel.background = element_rect(fill = "dodger blue"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.background = element_rect(fill = "dodger blue"),
plot.title = element_text(colour = "white", face = "bold", size = 30,
margin = margin(10,0,30,0)),
plot.caption = element_text(color = "white"),
axis.title = element_text(colour = "white", face = "bold"),
axis.title.x = element_text(margin = margin(30,0,10,0)),
axis.text = element_text(colour = "white", face = "bold"),
axis.title.y = element_text(margin = margin(0,20,0,30), angle = 0)
) +
labs(
x = "Market Capitalization",
y = "Attack\nHourly\nCost",
title = "The More a Crypto Network is Worth,\n the Harder it is to Attack.",
caption = "Data: www.crypto51.app | Graphics: @paulapivat"
) +
# annotate instead of geom_text
annotate("text", x = 205174310335, y = 800000, label = "Bitcoin", color = "white") +
annotate("text", x = 30762751140, y = 418437, label = "Ethereum", color = "white")

Implication

The More a Crypto Network is Worth, the Harder it is to Attack

All time high.

Image by Author

References

  1. www.crypto51.app

Data-Informed People Decisions

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store