Create your first query
How to write a query to find out the monthly $ gas spent for your wallet
New to Dune? Embark on your analytical adventure with us! In this guide, we provide a detailed walkthrough to craft your inaugural query, revealing your wallet’s monthly gas spent in USD.
Here is a visual click-through version if you are more of a visual learner. Below is a written version.
Getting Started
Initiate a New Query: Begin by selecting “Create New Query”. Start laying the basic structure of your query.
Choosing the Right Table
-
Determine Your Data Source: Instead of delving into the intricate raw blockchain tables to fetch gas expenditures for your wallet, utilize the pre-built, analytics-ready Spell table named
gas.fees
. This table facilitates an effortless aggregation of gas expenses across eight EVM chains specifically for your wallet. -
What’s the Spellbook? Think of Spellbook as a transformative layer that aggregates and standardizes blockchain data, both raw and decoded. With thousands of models both contributed by our active community and curated by the Dune team, it’s an invaluable resource. For a deeper dive into Spellbook, explore here.
Crafting Your Query
-
Identify Your Columns: Once you’ve zeroed in on the right table, pinpoint the
tx_fee_usd
column to track USD gas expenditures. To specify the wallet you’re examining, use thetx_sender
field. For demonstration purposes, we’ll be using Vitalik’s wallet (0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045). -
Aggregation & Time Period: Our goal is to get monthly gas spendings, so we need to truncate the
block_date
to month and applying theSUM()
function, then group by each month go derive the results.
Sum of sum was applied to get the cumulatively gas spendings.
Here is the link to demo query.
Boost Flexibility with Parameters
In the example, you’ll see tx_sender = \{\{Your Wallet Address}} -- default is vitalik.eth
. This denotes the use of the parameter feature, enhancing the query’s flexibility. To mark a field as a parameter, wrap it in "". Alternatively, activate the “Add Parameter” button.
Execute & Fetch the Result
All set! Click “Run” and behold the outcome. Kudos on crafting your first query! 🎉
Now that you have successfully run your query, you can go ahead and save it so you can keep monitoring your gas usage going forward. To save, click Save in the upper right part of the screen.
Was this page helpful?