13web3の世界 / The World of web3

【目次/TOC】

  1. オンチェーン分析:信頼と透明性の礎
    On-Chain Analysis: Cornerstone of Trust and Transparency
  2. ブロックチェーンの信頼性
    Reliability of Blockchain
  3. ブロックチェーンデータを触ってみよう
    Let's Experience the Blockchain Data

1. オンチェーン分析:信頼と透明性の礎/On-Chain Analysis: Cornerstone of Trust and Transparency

本ウェブページは『超入門 はじめてのAI・データサイエンス』第13章に記載されたコードを埋め込んでいます。書籍の第13章前半では,データサイエンティストの活躍が期待されるweb3の世界を紹介しています。

This webpage corresponds to Session 13 of the English website. The world of web3, where data scientists are expected to play an active role, is introduced in the first half of Session 13.

2.ブロックチェーンの信頼性/Blockchain Reliability

書籍のこの部分では,重要なブロックチェーンの信頼性について考察しています。

The important issues of reliability and trust concerning blockchain are discussed in this section of Session 13.

3. ブロックチェーンデータを触ってみよう/Let's Touch the Blockchain Data

それでは本章のコードのパートです。まずは下記コード1で必要なモジュールをインストールしておきます。

Here is the section for the codes for this session. First, let's install necessary modules with code-1.

!pip install google-cloud-bigquery

下記コード2でオンチェーン分析を実行します。コード内のyour-project-idとは,Google Cloudの中の個人のプロジェクトIDを指します。簡単に新規プロジェクトを作成できるので,作成方法はGoogleのHPをチェックしてみてください。ChatGPT等に聞いてみても良いですね。

You can perform on-chain analysis with code-2. "Your-project-id" in the code refers to your personal project ID in Google Cloud. You can easily create a new project, so check Google's website for how to create one. Or you can ask ChatGPT, etc.

from google.cloud import bigquery 
from google.colab import auth 
import pandas as pd

# Google Cloud プロジェクト ID
# Google Cloud Project ID
project_id = "your-project-id"

# 認証
# Authentication
auth.authenticate_user()

# BigQuery クライアントの初期化
# Initializing BigQuery Client
client = bigquery.Client(project=project_id)

# クエリの作成
# Creating a Query
query = """
SELECT *
FROM "bigquery -public -data.bitcoin_blockchain.transactions"
LIMIT 10
"""

# クエリの実行
# Executing Query
query_job = client.query(query)

# 結果を Pandas DataFrame に格納
# Storing the Result in Pandas DataFrame
df = query_job.to_dataframe()