Top 100 Users
Its helpful to see who has been interacting with a contract (even if they don't call this contract directly, but instead through traces). We can see their ENS, as well as NFT/DEX activity (improvements coming soon!).
Sometimes it won't be helpful at all, but it never hurts to skim this! I would click around at top users and see:
- are they a power user of any other protocols?
- what's the average wallet age and token holdings of top users?
What are the most popular function calls and events emitted, and how are the two linked together?
The two tables below serve to show you this data lineage in Dune, and easily show all the events a function emits (or all functions that emit a specific event) - as well as how often they're called. Usually, you'd use something like a call graph visualizer to get this, but those can still make it hard to figure out which functions are important and how they're tied to events.
Caveat, sometimes you'll need to modify these query to use "traces" instead of "transactions" in case of things like governance contract calling an updateParameter function. That function won't appear because it was never invoked by a EOA /user.
Contract Metadata
This pulls from our contracts table which tracks the decoding pipeline, I've added some extra logic to let you know if it fits into any token standards.
Contract Usage Over Time (Events)
This shows the number of times different events were emitted (it is not representative of the number of transactions). It helps us see when there was a spike or drop in certain events (such as liquidations).
You can take this a step further by figuring out how to add values like ETH or ERC20 amount to events but looking at what variables are in the parameters (ABI table).
Protocol Integrations Trending Over Time
See which contracts are calling this one the most.
Note that sometimes arb bots will write custom contracts or use some multicall contract to interact more efficiently.
modify parameter affects this table
Top 100 Contracts This One Uses
Now let's look at which other contracts are interacted with downstream. I've added a general filter to allow you to toggle if you want to show tokens.
A good intuition to build is that higher-level contracts manage liquidity more granularly in lower-level contracts, so the farther you go down the stack the more you can see how concepts like prices, royalities/revenue splits, and liquidity mining rewards are managed.
modify parameter affects this table.
Contract Usage Over Time (Calls)
This is here in case the contract has no events. Usually, looking at function call usage is convoluted because most contracts will have many functions tied to the same event, such as different token swap calculations/logic for a single Swap() event.
modify parameter affects this table.
Top 100 Contracts Using This One
Here we check for contracts that call this one by function in "traces". Flow goes caller -> caller function -> callee -> callee function, where callee is the address you put in the param at the top.
This can be the start of a proxy for market share or user analysis, to help you figure out which aggregators or vertical protocols are driving the most volume and users. You could pick an event/function and then analyze market/user share over time.
modify parameter affects this table.
Contract Functions Dive
We use "traces" to get the function signatures (first 8 characters of "traces.input") and generate decoded tables using the ABI.
Take a look at the most commonly called functions, and start your analysis there. Look to the connected events tables to help fill in any missing data points.
Contract ABI Events
Same as above, try and see what variables show up consistently. Pay attention to if variables show up in both event and input, or event and output - this will tell you that something (like swap price) was adjusted and calculated within this function.
Contract Events Dive
Here we go the other way around, starting from the "logs" table to decode topics into event names before joining on "transactions" to get all the functions that emit this event.
Some functions may not be tied in if they were only ever called in traces. Functions called by governance contracts are a good example of this. I can't make that link yet because we don't support trace <> log indexing connections.
Contract ABI Functions
The functions listed here are all external, meaning they can be called by other contracts or users. "view" or "pure" functions act as getters, and don't modify the state at all. "payable" allows ETH to be transferred, "nonpayable" does not.
I would skim the inputs and outputs of payable/nonpayable functions to get a sense of what variables show up the most - these are likely the ones you'll need to aggregate across decoded tables in your queries.
Choose your chain and contract address, then hit "apply all parameters" or "command + enter" to start running the queries.
Some queries in the second two sections take up to 5-10 minutes, so go grab a coffee and come back!
โ Not sure what contract to analyze? Check out 0xKofi'strending contracts dashboard and pick one from there.
Or try one of these other contracts/tokens:
- Aave v2 (lendingpool at 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
- Uniswap V2 (Router02 0x7a250d5630b4cf539739df2c5dacb4c659f2488d, Factory 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, WBTC/ETH pair 0xbb2b8038a1640196fbe3e38816f3e67cba72d940)
- Lido (stETH at 0xae7ab96520de3a18e5e111b5eaab095312d7fe84)
- Lens Protocol (LensHub on Polygon at 0xdb46d1dc155634fbc732f92e853b10b288ad5a1d)
Contract Analysis Quickstart
๐ง Be sure to follow our list of educational wizards on Twitter for more Duniveristy content!
The original Tweet thread explaining this dashboard is here, with a write up and youtube video as well.
๐ข Do you have a contract address from a protocol or token, but aren't sure how to start analyzing it? This dashboard will give you an overview of how any contract address works - so you'll know what function/event tables (or other contracts/addresses) to query next!
To continue your analysis, go to the address balances and flows quickstart dashboard.
๐ All Function/Event Name columns have links to an example transaction!
๐ if you find a bug/edge-case, please screenshot it and dm me so I can fix it.
New/Old Wallets Over Time
See how many new or old wallets call this contract directly or indirectly (cause an event to emit) over time.
The next level for this is doing actual retention metrics, so splitting into monthly/weekly new users and seeing how many weeks in a row they come back.
Contract Overview
The contract must be decoded for this section of the dashboard to work. You can run your contract address to see if it's ready or not.
This section provides you with basic contract metadata and a high-level view of all external functions and events, as well as their input or output parameters from the ABI. You can read more about function state mutability here.
Dune takes raw blockchain data (i.e. function signatures and event topics from transactions, traces, and logs tables) and uses the ABI above to get you decoded tables that follow a specific schema. You'll find the signature <> ABI linkage in the next section.
Who and how is this contract being used?
Composability is one of the most used words in web3 - this section takes a deeper look at how this contract is used. We look at events emitted by this contract when another contract is called, and also events emitted by contracts that this one calls. For example, an NFT marketplace contract will be called by some set of aggregator or bot contracts, and likely calls some set of allowlist or price oracle contracts. I've filtered out ERC20, ERC721, and ERC1155 contracts in the callee table.
Looking at wallets (EOAs which invoke the calls also tells us who some of the top users might be, we have a labels table in spellbook which we use to provide us more enhanced metadata around the user addresses.
Same caveat as the last section, you'd maybe want to take a traces approach to all of this to get function usage instead of event usage. You can find an example here that takes much longer to run.
I've also added a modify_only filter which removes view functions from any of the function-based charts (usage) - view functions are pretty much only useful to analyze for something like oracles.
The months_ago filter is for you to make queries more performant. Querying on too many months will crash.