DAPPCON 2019: Workshop - Analyze Ethereum Data & Share Your Results w/ Fredrik Haga (Dune Analytics)

DappCon 2019 · August 2019 · 15:00

At a DappCon 2019 workshop, Fredrik Haga of Dune Analytics teaches attendees how to query on-chain Ethereum data and share the resulting dashboards with the community. He walks through Dune's SQL-based approach to turning raw blockchain data, including DeFi and smart contract activity, into shareable analytics. The session gives developers practical tools for building public data reports from the Ethereum blockchain.

Speakers

Topics

From DappCon 2019, hosted by Dappcon Berlin.

Transcript

I'm gonna go to a few quick slides I'm Fredrik by the way from dear Mott's my co-founder is also here so you can ask him as well later so I'm going to go through a few quick slides to give you an overview and then we'll hopefully spend most of the time with you getting your hands dirty so so what's dune analytics basically we have decoded smart contract data we have a querying interface where you can query the etherium data with Postgres you can then visualize the query results into nice graphs and then you can share and share the analysis and explore explore what

other people have been doing so well first take a look at what you can make with this data then we'll take a look at actual data tables I'll do a live example to give you a feel for how to work with the data and then it's your turn we'll spend most of the time on that you guys creating interesting stuff so here are some examples so this one we recently featured in the token economy newsletter so here we have a bunch of text metrics we have the total volume for this year USD volume for various different Dix's we have that over time

we see how many trades were done last week and how many traders there were for instance so this is one example another example it's the touch exchange Dao where they did a period where you can stake and lock up your friends to participate so here we have various metrics for how people participated the the different methods which tokens they used things like that recently there's also some metrics for 0ex retention for instance so you can do pretty detailed

analysis beyond like same four simple metrics so here you can see how many users came in a given week how many users came back the week after and the week after that and so forth so you can do pretty deep like product analysis here for instance so that's some of the examples so the data itself is mostly theorem events and contract calls we also have USD prices so you can get the USD volumes of different actions and we also have the ROI here iam blockchain in there so and of course just stop me if

there's anything that's not clear any questions so I'm gonna do a quick example and then we're gonna get you guys going so let's create a new query here so this is the interface you can create a user afterwards so on the left here we have different smart contract data so let's search for uni swap for instance you see the project name first then the contract name so and then whether it's an event or a contract call so for instance we have here the unit's pop exchange contract and the event each purchase here we have the various columns so if we just select everything

from this table here and let's limit that to 10mm so if we get this you can now see this table here you see which address was the buyer how many tokens were sold how much it was bought and the transaction address you also here see the the address for where this happens so each market is its own address that you can read in the address field so all of these have an address field which tells you which address was like which smart contract this is so we have this so now we can look at for instance

how much it has been bought on on you nice pop so then you just some eat you divide it by power of 18 and we do it like this gives you all eat bought on unit swap so remember that on you swap you can vote by eat or token so if you combine these two events you get the tote will eat volume on on unisport for instance so that's just summing these things is extremely easy queries obviously then we can make it a little more interesting and say we want to do this over time so what you typically do

then is you use the it right here iam data so we have the transactions table which is all the same transactions so if we want to get get a time component into this this data we can do with let's call it transactions as and we select we take the transaction hash we take the block time and we take that from the ATM transactions table and to avoid there being a lot of data here we want to limit the time so let's say we call this one connections and we say I don't need

to do that we say we're locked time is bigger than the last 7 days so interval 7 days so now we should have the last the blocks from the transactions from the last 7 days and then we join this with the unit swap event so here we we take join this on transaction hash so we take the transaction hash on from the we take

the transaction table here and we get the hash so and then we want to have so this is a neat function where you used to date trunk we want to have the day and we take that from transaction table and we the block time so with this then we group that by day the first one here and if I'm not mistaken this should work didn't it never does on the first hit let's see here any solutions I didn't

specify what [Music] oh yeah I only TX oops this may be see yes so now we have the and let's order this as well so now we have how the each volume per per day the last seven day

seven days on the eat both side of units pop so this is a nice little table here then we can do whistle whistle station of this so you can do different types let's do a bar chart we want to have the date as the X column and then some as the Y column and here we have this visualized and now we can also say we want to get the users user number so if we go in again into back into this table we used each purchase we see there's a buyer field here so let's also count distinct buyer

here and see if we get that number as well so that would be basically unique users to do and we look at the table we got here now we have that as well so then we can add that to our visualization we want also to do the number of users here and then we can for instance split the the axis oops and let's see if we can do it the other way around so we do one bar in one line chart and here you now have on the left hand side you have the amount of eat

that was traded in that day and you on the right hand side side you have the unique addresses so you can save that and now what you can do you can save this so let's say eat buying Eunice WAP and now you can also create a dashboard so you knees what it's got that and then you can add your query you can use the short you made and then this is a dashboard you can add thousands of other things so you can

find what other people are doing as well so let's say we want to add unique senders of dye to this dashboard you can do that as well so we can pick and choose different things that people done and then you can save that and you can publish it and then you can go ahead and share it with people so that's a very quick run-through of how it works and obviously we have a bunch of other data as well so if you just browse or search for a different project here you will find lots of more data view tricks that's alright to keep in mind you

almost always want to divide by one to the power of 18 a nice thing to do is to join on join the transaction hash the event table and the transaction table to get the time component you need to format if you want to filter on address you form it like this you just replace the zero with a backslash other neat thing you can do is group by token if you want to do use token amounts so now we're gonna spend the next 45 minutes letting you guys play around with this so you can go to genetics comm you will

see the exact same thing that I showed you now and you can do queries create visualizations and go ahead and share them afterwards we have some ideas for things you might want to look into so we recently decoded the malocchio data data we put up the gas station network data and we put up some air swap data which could be fun but you decide and there are obviously more sophisticated things you can do but we think maybe the most fun thing is to get do something that's somewhat useful within the time we have now so maybe just count users over time take the amount over time if you feel like you

are not challenged enough you can get the USD price ask us and we can help you multiply the unchain volumes with the USD market price over time we can also you can look at like distribution across users so if you group amount sent by users you can see who are the most active users or who has the most volume for instance so yep that's all I plan to say if there are any questions please go ahead right now or we're of course gonna hang around and help you guys yeah sure now so you you have to use it through

the interface so that's how it's exposed yeah one yeah yeah so you can like the pricing plans yeah so that basically depends so that's so we have the free open interface that you can use and we're happy to talk if you're interested in having the direct data access plan for for the what do you mean plan like oh yeah yeah we don't have

like clear specifics on that right now okay clear enough also just ask if you want ideas for what to what to work on