<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dat Nguyen on Medium]]></title>
        <description><![CDATA[Stories by Dat Nguyen on Medium]]></description>
        <link>https://medium.com/@dattnguyen82?source=rss-8d244947c0c9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pY0bqZfGBUBAcC8CX7sWNw.jpeg</url>
            <title>Stories by Dat Nguyen on Medium</title>
            <link>https://medium.com/@dattnguyen82?source=rss-8d244947c0c9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 02:51:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dattnguyen82/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Smart Contract Events with Infura.io]]></title>
            <link>https://medium.com/@dattnguyen82/smart-contract-events-with-infura-io-2451f3b3e3a3?source=rss-8d244947c0c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2451f3b3e3a3</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Dat Nguyen]]></dc:creator>
            <pubDate>Thu, 30 Aug 2018 22:02:36 GMT</pubDate>
            <atom:updated>2018-08-30T22:02:36.670Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://www.infura.io/">Infura.io</a> is an excellent resource for Ethereum developers by providing easy, reliable access to the network (or networks). The service allowed developers to get their dApps up and running without having to worry about running their own Ethereum node. Originally, there was huge drawback though: <strong>Events were not supported. </strong>The good news is that since Feb ’18 that has <a href="https://github.com/INFURA/infura/issues/73">changed</a>. The following article is a simple tutorial of how to source Ethereum contract <a href="https://media.consensys.net/technical-introduction-to-events-and-logs-in-ethereum-a074d65dd61e">events</a> as data.</p><p>Before getting started, you should head to <a href="https://www.infura.io/">Infura.io</a> and signup for an account.</p><p>The Infura.io API provides a web-socket interface that can be used as the <a href="https://web3js.readthedocs.io/en/1.0/">web3</a> provider:</p><pre><strong>let </strong>web3 = <strong>new </strong>Web3(&#39;wss://ropsten.infura.io/ws&#39;);</pre><p>Once a web3 instance with the <a href="https://www.infura.io/">Infura.io</a> web-socket provider has been created, the smart contract instance can be created as normal:</p><pre><strong>let </strong>contract = <strong>new </strong>web3.eth.Contract(&lt;<em>contract abi</em>&gt;, &lt;<em>contract address</em>&gt;);</pre><p>Then the event subscription needs to be implemented:</p><pre>contract.events.allEvents({<br>      fromBlock: 0<br>   }, (error, event) =&gt; {<br>      console.log(event);<br>   }).on(&#39;data&#39;, (event) =&gt; {<br>      console.log(event);<br>   }).on(&#39;changed&#39;, (event) =&gt; {<br>      console.log(event);<br>   }).on(&#39;error&#39;, (error) =&gt; { <br>      console.error(error);<br>});</pre><p>Finally, past events can also be retrieved as well:</p><pre><strong>let </strong>events = <strong>await </strong>contract.getPastEvents(&lt;<em>event name</em>&gt;, {fromBlock: 0});</pre><p>Download the complete sample code <a href="https://github.com/dattnguyen82/infura-events">here</a>.</p><p>That’s all you need to get started with smart contract events on <a href="https://www.infura.io/">Infura.io</a>. This is a bare-bones example and I would recommend checking out the <a href="https://www.infura.io/docs/wss/introduction">documentation</a> for more robust applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2451f3b3e3a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>