Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to get the total cost of approve() function calls on Ethereum blockchain
-- 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
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