Query editor
-- DUNE Query to fetch daily average gas (in USD) used for different types of Ethereum, Optimism, and Arbitrum transactions--> Transaction identified :---- 1) Transfer of coins on their blackchain (ETH, OP, ARB)--------Differentiator: The 'to' field is a regular Ethereum address, and the 'data' field is typically empty or just contains "0x".---- 2) Deployement of smart contract--------Differentiator: The 'to' field is empty (because the contract address is not known until after deployment), and the 'data' field contains the bytecode of the contract to be deployed.---- 3) DeFi Interaction (like ERC20 swap, transfer, ..)--------Differentiator: The 'to' field contains the address of the contract being called, and the 'data' field contains the function signature and encoded arguments for the function being called.--> Reveals the costs associated with specific activities like smart contract interactions, token swaps, or liquidity provisions.--> Developers can prioritize optimizations for more expensive operations, and DeFi users can strategize their interactions based on transaction types.-- Fetch the latest Ethereum price in USD.WITH eth_price_usd AS (SELECTpriceFROM prices.usdWHEREsymbol = 'ETH'ORDER BYminute DESCLIMIT 1),-- Fetch the latest Optimism price in USD.op_price_usd AS (SELECT priceFROM prices.usdWHERE symbol = 'OP'ORDER BY minute DESCLIMIT 1),-- Fetch the latest Arbitrum price in USD.arb_price_usd AS (SELECT priceFROM prices.usdWHERE symbol = 'ARB'ORDER BY minute DESCLIMIT 1),-- CTE for average gas used in deploying Ethereum smart contracts in USD.eth_deploy AS (SELECTDATE_TRUNC('day', block_time) AS day,AVG((gas_price / 1e18) * gas_used) * (SELECT price FROM eth_price_usd LIMIT 1) AS eth_deploy_gasFROM ethereum.transactionsWHEREblock_time >= CURRENT_TIMESTAMP - INTERVAL '30' DAYAND value = 0AND to IS NULLAND data IS NOT NULLGROUP BYDATE_TRUNC('day', block_time)),-- CTE for average gas used in deploying Optimism smart contracts in USD.op_deploy AS (SELECTDATE_TRUNC('day', block_time) AS day,