<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: WatchData.io</title>
    <description>The latest articles on DEV Community by WatchData.io (@watchdata).</description>
    <link>https://dev.to/watchdata</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F825514%2Faf945cc4-5aa2-4b96-a35c-6373f3679dad.png</url>
      <title>DEV Community: WatchData.io</title>
      <link>https://dev.to/watchdata</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/watchdata"/>
    <language>en</language>
    <item>
      <title>How eth_getLogs works?</title>
      <dc:creator>WatchData.io</dc:creator>
      <pubDate>Fri, 04 Mar 2022 18:38:49 +0000</pubDate>
      <link>https://dev.to/watchdata/how-ethgetlogs-works-17n4</link>
      <guid>https://dev.to/watchdata/how-ethgetlogs-works-17n4</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jhm5bmoQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oh3zjsg89xc6qt76xhca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jhm5bmoQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oh3zjsg89xc6qt76xhca.png" alt="Image description" width="880" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hello everyone 🖖
&lt;/h2&gt;

&lt;p&gt;We continue our series of articles about our API and today we want to take a look at the often used &lt;strong&gt;eth_getLogs&lt;/strong&gt;.&lt;br&gt;
eth_getLogs has a lot of useful options that developers often don’t know about. Let’s give you an example of how to work with this query.&lt;br&gt;
For more information about the request/response specifications for &lt;code&gt;eth_getLogs&lt;/code&gt;, see our &lt;a href="https://docs.watchdata.io/blockchain-apis/ethereum-api/eth_getlogs-new"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Logs?
&lt;/h2&gt;

&lt;p&gt;Logs and events are used synonymously — smart contracts generate logs by triggering events, so logs provide insight into the events that occur within a smart contract. Logs can be found on transaction recipes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Query eth_getLogs
&lt;/h2&gt;

&lt;p&gt;When you make a request to &lt;code&gt;eth_getLogs&lt;/code&gt;, all parameters are OPTIONAL, that is, you don't need to specify &lt;code&gt;fromBlock&lt;/code&gt;, &lt;code&gt;toBlock&lt;/code&gt;, &lt;code&gt;address&lt;/code&gt;, &lt;code&gt;topics&lt;/code&gt; or &lt;code&gt;blockHash&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let’s look at an example of a request.&lt;br&gt;
Take the USDT address and limit the search parameters from 10,000,000 block to 10,000,001 block.&lt;br&gt;
Let’s add a topic on event transfers. We’ll describe it in more detail below&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
    "id": 1,&lt;br&gt;
    "method": "eth_getLogs",&lt;br&gt;
    "jsonrpc": "2.0",&lt;br&gt;
    "params": [&lt;br&gt;
        {&lt;br&gt;
    "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", &lt;br&gt;
    "fromBlock": 10000000, &lt;br&gt;
    "toBlock": 10000001,&lt;br&gt;
    "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]&lt;br&gt;
        }&lt;br&gt;
    ]&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In our &lt;code&gt;params&lt;/code&gt; here we have specified the &lt;code&gt;address&lt;/code&gt;, &lt;code&gt;fromBlock&lt;/code&gt; and &lt;code&gt;toBlock&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚠️ We use &lt;code&gt;fromBlock&lt;/code&gt; and &lt;code&gt;toBlock&lt;/code&gt; in our params. It is important to understand that you can use either &lt;code&gt;fromBlock&lt;/code&gt; and &lt;code&gt;toBlock&lt;/code&gt; or &lt;code&gt;blockHash&lt;/code&gt;, not both.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;fromBlock&lt;/code&gt; and &lt;code&gt;toBlock&lt;/code&gt; parameters specify the start and end block numbers to limit the search. The &lt;code&gt;address&lt;/code&gt; field represents the address of the contract that creates the log.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Topics&lt;/code&gt; is an ordered array of data. Notice how the first item in the &lt;code&gt;topics&lt;/code&gt; field above matches the event signature of our &lt;code&gt;Transfer(address,address,uint256)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This means that we specifically request the Transfer event. So I will get all transfers in USDT from 10,000,000 block to 10,000,001 block.&lt;/p&gt;

&lt;p&gt;Now that we have a better understanding of how to make queries, let’s look at the answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Response&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You will get a list of logs in a given range (You will get a response with much more data than the following):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
    "id": 1,&lt;br&gt;
    "jsonrpc": "2.0",&lt;br&gt;
    "result": [&lt;br&gt;
        {&lt;br&gt;
            "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",&lt;br&gt;
            "blockHash": "0xaa20f7bde5be60603f11a45fc4923aab7552be775403fc00c2e6b805e6297dbe",&lt;br&gt;
            "blockNumber": "0x989680",&lt;br&gt;
            "data": "0x00000000000000000000000000000000000000000000000000000000121eac00",&lt;br&gt;
            "logIndex": "0x3",&lt;br&gt;
            "topics": [&lt;br&gt;
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",&lt;br&gt;
                "0x00000000000000000000000039bb7d39a395e0ce36875244ad48bcaec54faf03",&lt;br&gt;
                "0x0000000000000000000000009354de9e63674f3e44303b8cc3853d7f10f97d06"&lt;br&gt;
            ],&lt;br&gt;
            "transactionHash": "0x80e195cabafd0358a35cec5fadc9b304734ac1f0ed6edf607d170dab13f5e069",&lt;br&gt;
            "transactionIndex": "0x7",&lt;br&gt;
            "removed": false&lt;br&gt;
        }&lt;br&gt;
..............................&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The interesting fields to watch out for are &lt;code&gt;data&lt;/code&gt; - which is an unrestricted field for encoding hexadecimal data related to a specific event. By default, if the information is not indexed in the other topics field, it is automatically placed in the data field. This requires more work to analyze the individual hex string information rather than their indexed topics.&lt;/p&gt;

&lt;p&gt;And &lt;code&gt;topics&lt;/code&gt; - can contain up to 4 topics. The first topic is mandatory and will always contain hash keccak 256 event signature. As you may see the example above shows a Transfer event between address 0x39bb7d39a395e0ce36875244ad48bcaec54faf03&lt;br&gt;
and 0x 9354de9e63674f3e44303b8cc3853d7f10f97d06(the second and third topics).&lt;/p&gt;

&lt;p&gt;We can check this data on etherscan&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wL-jgR1R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dcotj1s0iig7n27swi64.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wL-jgR1R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dcotj1s0iig7n27swi64.png" alt="Image description" width="700" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you know a bit more about the eth_getLogs.&lt;/p&gt;




&lt;p&gt;But if you want to receive and process transfers and not spend a lot of time processing logs, you can use our &lt;a href="https://docs.watchdata.io/structured-data/transfers"&gt;watch_getTransfers&lt;/a&gt; method.&lt;/p&gt;

&lt;p&gt;We will tell you about it in one of our next articles, but for now you can read about it in the &lt;a href="https://docs.watchdata.io/introduction/welcome-to-watchdata-docs"&gt;documentation&lt;/a&gt;.&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Join to &lt;a href="https://discord.com/invite/TZRJbZ6bdn"&gt;our Discord server&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Please leave your feedback in the #feedback channel. If you have any problems or you think that some functionality is not working correctly, we are waiting for your feedback.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Want a new feature or you miss some functionality, tell us about it in the #general channel. We are always open to your ideas!&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  HELPFUL LINKS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.watchdata.io/"&gt;WatchData main&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.watchdata.io/raw-data"&gt;Raw Data
&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.watchdata.io/structured-data"&gt;Structured data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://watchdata.notion.site/Metrics-for-analysis-98dea0a697764bc6ae51643828449dc9"&gt;Metrics for analysis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://watchdata.notion.site/For-Miners-70367c9705ae482c90674d070eedea61"&gt;For Miners&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://discord.com/invite/TZRJbZ6bdn"&gt;WatchData Discord&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/Watchdata_web3"&gt;WatchData Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.watchdata.io/introduction/welcome-to-watchdata-docs"&gt;WatchData Docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>web3</category>
      <category>ethereum</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>How can I get all stats by day?</title>
      <dc:creator>WatchData.io</dc:creator>
      <pubDate>Fri, 04 Mar 2022 18:22:04 +0000</pubDate>
      <link>https://dev.to/watchdata/how-can-i-get-all-stats-by-day-1hjo</link>
      <guid>https://dev.to/watchdata/how-can-i-get-all-stats-by-day-1hjo</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sdPHF2DT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4sj377slfyq1k9e3hazq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sdPHF2DT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4sj377slfyq1k9e3hazq.png" alt="Image description" width="880" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hello everyone!&lt;/strong&gt;&lt;br&gt;
We at WatchData are in the business of making life better for developers and the entire crypto community. Our API is a simple and easy way to interact with blockchain and we want to tell and show you what you can get by using WatchData.&lt;/p&gt;

&lt;p&gt;Here is a brief analysis of our endpoints.&lt;/p&gt;

&lt;p&gt;In this series of articles, you can get answers to the following questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is it?&lt;/li&gt;
&lt;li&gt;What is it for?&lt;/li&gt;
&lt;li&gt;What can I do with it?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Today we'll start with &lt;a href="https://docs.watchdata.io/structured-data/stats-new/watch_getstatsbyday"&gt;watch_getStatsByDay&lt;/a&gt;. We added this endpoint recently, but now we want to tell you what its value and usefulness are.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;watch_getStatsByDay - is a set of parameters collected in a single endpoint. This is the statistical data used in the ETH blockchain. By the way, this method will be available for other blockchains in the near future.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With this data you can get all the statistical information for 1 day in 1 click. This removes a headache for many users, because using this method you don't have to collect and process data from different sources.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;3.There are many ways to use and process this data, for example, you can use it in the following cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can build a graph and estimate the statistics, on which day there were more transactions and on which day more commission was paid.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H495A4qs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xnkoiv53qs85bw8rmgpc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H495A4qs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xnkoiv53qs85bw8rmgpc.png" alt="Image description" width="700" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All you have to do is get a key and process the request through any API interaction tool, you can find a detailed guide → &lt;a href="https://docs.watchdata.io/introduction/quick-start-guide-to-watchdata"&gt;here&lt;/a&gt;. In the parameters, select the date you need and get an answer. To convert the unix timestamp you can use &lt;a href="https://www.epochconverter.com/"&gt;https://www.epochconverter.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Example request&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
    "jsonrpc":"2.0",&lt;br&gt;
    "method":"watch_getStatsByDay",&lt;br&gt;
    "params":[1646053739],&lt;br&gt;
    "id":0&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example response&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
    "id": 0,&lt;br&gt;
    "jsonrpc": "2.0",&lt;br&gt;
    "result": {&lt;br&gt;
        "transactionCount": 1108112,&lt;br&gt;
        "averageGasPrice": 74184332107.8433,&lt;br&gt;
        "totalGasUsed": 99340469987,&lt;br&gt;
        "uncleBlockReward": 628250000000000000000,&lt;br&gt;
        "minersReward": 13744624508661043931629,&lt;br&gt;
        "blockCount": 6424&lt;br&gt;
    }&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
Returns explanation&lt;br&gt;
&lt;code&gt;Object&lt;/code&gt; - A block object with the following fields, or null when no block was found:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;transactionCount: QUANTITY — number of transactions per day&lt;/li&gt;
&lt;li&gt;averageGasPrice: QUANTITY, — average gas price per day.&lt;/li&gt;
&lt;li&gt;totalGasUsed: QUANTITY, — total gas used per day&lt;/li&gt;
&lt;li&gt;uncleBlockReward: QUANTITY, — uncle block reward by day&lt;/li&gt;
&lt;li&gt;minersReward: QUANTITY, — miner’s reward per day&lt;/li&gt;
&lt;li&gt;blockCount: QUANTITY, — number of blocks per day&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This way you can collect data for the time period you need. For example&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TSkmxB-F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dpnag6grv2bcoekph17l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TSkmxB-F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dpnag6grv2bcoekph17l.png" alt="Image description" width="557" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using this data, you can build any graphs you want as well as serving specific information. Of course presented here is only a small part, it all depends on your product, you are free to work with any type of data, and we will help you with this!&lt;/p&gt;




&lt;p&gt;This example shows the method, which gives the data within one day, if you need other ranges, please contact us &lt;a href="mailto:marketing@thewatch.io"&gt;marketing@thewatch.io&lt;/a&gt;&lt;br&gt;
Or join &lt;strong&gt;&lt;a href="https://discord.com/invite/TZRJbZ6bdn"&gt;our discord community&lt;/a&gt;&lt;/strong&gt;, there, in the channel #general you can ask any questions that interest you, as well as in the channel #feature-request suggest a feature or statistical information that you need in the first place.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;HELPFUL LINKS&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.watchdata.io/"&gt;WatchData main&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.watchdata.io/raw-data"&gt;Raw Data
&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.watchdata.io/structured-data"&gt;Structured data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://watchdata.notion.site/Metrics-for-analysis-98dea0a697764bc6ae51643828449dc9"&gt;Metrics for analysis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://watchdata.notion.site/For-Miners-70367c9705ae482c90674d070eedea61"&gt;For Miners&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://discord.com/invite/TZRJbZ6bdn"&gt;WatchData Discord&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/Watchdata_web3"&gt;WatchData Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.watchdata.io/introduction/welcome-to-watchdata-docs"&gt;WatchData Docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>web3</category>
      <category>ethereum</category>
      <category>blockchain</category>
      <category>web3dev</category>
    </item>
  </channel>
</rss>
