Created
January 28, 2021 11:47
-
-
Save miohtama/02a72595375b826c53debf4847aaae76 to your computer and use it in GitHub Desktop.
How to get the total cost of approve() function calls on Ethereum blockchain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Web3.utils.keccak256("approve(address,uint256)").slice(0, 10); | |
-- '0x095ea7b3' | |
WITH txdata as ( | |
SELECT tx.hash as txid, cast(tx.receipt_gas_used as numeric) * cast(tx.gas_price as numeric) as cost FROM | |
bigquery-public-data.crypto_ethereum.transactions as tx | |
where | |
tx.input | |
LIKE "0x095ea7b3%") | |
SELECT (SUM(cost) / POWER(10, 18)) as eth_cost from txdata; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment