使用Python进行智能合约分析

时间:2019-01-25 17:25:51

标签: python google-bigquery ethereum smartcontracts

我想分析一个双重区块链项目的以太坊公共区块链。

例如,在Medicalchain项目(https://medicalchain.com/it/)中,他们使用基于以太坊和Hyperledger许可的公共区块链构建了区块链。 公共区块链上的每笔交易均充当指向已授权交易的指针。

我使用此代码使用Python和BigQuery获取公共区块链的信息

# Start bigquery_query
def export_table_to_gcs(dataset_id, table_id, destination):
    """
    Exports data from BigQuery to an object in Google Cloud Storage.
    For more information, see the README.rst.
    Example invocation:
    $ python export_data_to_gcs.py example_dataset example_table \\
      gs://example-bucket/example-data.csv
   The dataset and table should already exist.
   """

dataset_id = 'bigquery-public-data'
project_id = 'cecitesi1-219209'
table_id= 'ethereum_blockchain'
client = bigquery.Client(credentials= credentials_, project =project_id)
dataset_ref = client.dataset(dataset_id=dataset_id, project=project_id)
table_ref = dataset_ref.table(table_id)

QUERY=("""
#standardSQL
#standardSQL
SELECT
  transactions.hash,
  input,
  token.block_timestamp
FROM
  `bigquery-public-data.ethereum_blockchain.token_transfers` AS token
LEFT JOIN
  `bigquery-public-data.ethereum_blockchain.transactions` AS transactions
ON
  (transactions.hash = token.transaction_hash)
WHERE
  token.token_address = '0x41dbecc1cdc5517c6f76f6a6e836adbee2754de3'  """)

query_job = client.query(QUERY)  # API request

results = query_job.result()  # Waits for job to complete.
# END bigquery_query

# From query to Dataframe - pandas
df = pd.read_gbq(QUERY, project_id=project_id, dialect="standard")
df.columns=['transactions.hash', 'input', ' date']

然后,我有一个DataFrame,它显示事务输入,日期和哈希。 我以为了解交易输入数据中的功能类型可能是我实现目标的答案,但几乎所有人都是Function: transfer(address _to, uint256 _value)

是否有可能了解在交易中写入哪种信息? 否则,我该怎么做定量分析? (我刚刚分析了每个月的交易量,但我不太满意,我想做更多的工作)

0 个答案:

没有答案