Skip to content

Instantly share code, notes, and snippets.

@PhABC
Last active November 12, 2018 17:41
Show Gist options
  • Select an option

  • Save PhABC/60f0e8cee8c4a37ada9be5e28089620c to your computer and use it in GitHub Desktop.

Select an option

Save PhABC/60f0e8cee8c4a37ada9be5e28089620c to your computer and use it in GitHub Desktop.

Revisions

  1. PhABC revised this gist Nov 12, 2018. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions totalTxFeeEthereum.sql
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,6 @@ NOTE: Need to divide gas_price by 10 to prevent overflow in BigQuery.
    SELECT
    SUM(gas_price/10 * receipt_gas_used) / POWER(10, 17) * 492
    FROM
    `bigquery-public-data.ethereum_blockchain.logs` AS logs JOIN UNNEST(topics) AS topic,
    `bigquery-public-data.ethereum_blockchain.transactions` AS transactions
    WHERE TRUE
    AND transactions.hash = logs.transaction_hash
    and transactions.block_number >= 2912407
  2. PhABC revised this gist Nov 12, 2018. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions totalTxFeeEthereum.sql
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,10 @@
    /*
    Calculate the total amount of transaction fee since January 1st 2017 (block 2912407), with weithed
    average price of Ether as 492.
    NOTE: Need to divide gas_price by 10 to prevent overflow in BigQuery.
    */

    SELECT
    SUM(gas_price/10 * receipt_gas_used) / POWER(10, 17) * 492
    FROM
  3. PhABC created this gist Nov 12, 2018.
    8 changes: 8 additions & 0 deletions totalTxFeeEthereum.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    SELECT
    SUM(gas_price/10 * receipt_gas_used) / POWER(10, 17) * 492
    FROM
    `bigquery-public-data.ethereum_blockchain.logs` AS logs JOIN UNNEST(topics) AS topic,
    `bigquery-public-data.ethereum_blockchain.transactions` AS transactions
    WHERE TRUE
    AND transactions.hash = logs.transaction_hash
    and transactions.block_number >= 2912407