<?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: Ashutosh Tripathi 🥷</title>
    <description>The latest articles on DEV Community by Ashutosh Tripathi 🥷 (@pythontony).</description>
    <link>https://dev.to/pythontony</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%2F891813%2Ff237e72d-4e31-49ac-9ba4-33db8341daec.jpg</url>
      <title>DEV Community: Ashutosh Tripathi 🥷</title>
      <link>https://dev.to/pythontony</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pythontony"/>
    <language>en</language>
    <item>
      <title>How To Send Notifications From A Subgraph</title>
      <dc:creator>Ashutosh Tripathi 🥷</dc:creator>
      <pubDate>Fri, 12 Aug 2022 13:25:00 +0000</pubDate>
      <link>https://dev.to/pythontony/how-to-send-notifications-from-a-subgraph-1b18</link>
      <guid>https://dev.to/pythontony/how-to-send-notifications-from-a-subgraph-1b18</guid>
      <description>&lt;p&gt;Gm folks ✨&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Graph&lt;/strong&gt; is certainly one of the coolest innovations in Web3 space. With its unique infrastructure, &lt;a href="https://thegraph.com/en/"&gt;Graph Protocol&lt;/a&gt; adds Indexing functionality to the Blockchain ecosystem. It has ridiculously simplified the process of querying data from blockchain networks like &lt;strong&gt;Ethereum&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;Subgraph&lt;/strong&gt; defines which data &lt;strong&gt;The Graph&lt;/strong&gt; will index from a blockchain, and how it will store it. Once deployed, it becomes part of a global graph of blockchain data which you can retrieve using GraphQL.&lt;/p&gt;

&lt;p&gt;In this tutorial, I will show you how to use the EPNS &lt;strong&gt;Helper Function&lt;/strong&gt; to integrate your channel with a Subgraph.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EPNS only supports subgraphs deployed on The Graph Protocol's &lt;strong&gt;Hosted Service&lt;/strong&gt;. The next update would include support for Subgraph Studio.&lt;/p&gt;

&lt;p&gt;Subgraph support is currently available at &lt;a href="https://staging.epns.io/"&gt;Staging&lt;/a&gt; and will be available on &lt;a href="https://app.epns.io"&gt;Prod&lt;/a&gt; following the Protocol v2 audit.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Why use Subgraphs?
&lt;/h1&gt;

&lt;p&gt;Subgraphs are used to retrieve and store data from the blockchain for a specific smart contract. This data can be used to investigate a range of smart contract-related events.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://thegraph.com/hosted-service/subgraph/uniswap/uniswap-v2"&gt;Uniswap Subgraph&lt;/a&gt;, for example, keeps data on total volume across all trading pairs, volume data per trading pair, and even data for a specific token.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How about intelligently retrieving data from a Subgraph and generating helpful alerts?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This can be incredibly beneficial to your dApp's end-users and entities connected to your smart contract, improving the overall user experience.&lt;/p&gt;

&lt;h1&gt;
  
  
  Sending Notifications using EPNS
&lt;/h1&gt;

&lt;p&gt;EPNS has developed an in-house &lt;code&gt;Helper Function&lt;/code&gt; specifically for The Graph Protocol that allows you to read events from the Subgraph and define notifications accordingly. Once defined, they are stored on the Subgraph in a &lt;code&gt;Long String&lt;/code&gt; format.&lt;/p&gt;

&lt;p&gt;Later on, EPNS Push Nodes fetch the notifications defined on the Subgraph and push them accordingly to subscribers of the channel.&lt;/p&gt;

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

&lt;p&gt;In order to integrate EPNS with your Subgraph, you will need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your Subgraph ID&lt;/li&gt;
&lt;li&gt;A channel deployed on EPNS&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In case you don’t have the Subgraph ID, feel free to create your own Subgraph by following the step-by-step guide available here at &lt;a href="https://thegraph.com/docs/en/developer/create-subgraph-hosted/"&gt;Create a Subgraph&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once you have published your Subgraph, you can start sending notifications based on events generated from the Smart Contract to the users.&lt;/p&gt;

&lt;p&gt;Enough talking, let’s get into Building stuff right away!!&lt;/p&gt;

&lt;h1&gt;
  
  
  Setup EPNS with Subgraph
&lt;/h1&gt;

&lt;p&gt;In order to integrate EPNS with your Subgraph, follow the below steps carefully;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;1. Initialize Subgraph with EPNS&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to the Subgraph directory and you’ll find &lt;code&gt;schema.graphql&lt;/code&gt; file. Open in an editor of your choice and include the following EPNS Schema;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;type&lt;/span&gt; &lt;span class="no"&gt;EpnsNotificationCounter&lt;/span&gt; &lt;span class="vi"&gt;@entity&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="ss"&gt;id: &lt;/span&gt;&lt;span class="no"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
  &lt;span class="ss"&gt;totalCount: &lt;/span&gt;&lt;span class="no"&gt;BigInt&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;type&lt;/span&gt; &lt;span class="no"&gt;EpnsPushNotification&lt;/span&gt; &lt;span class="vi"&gt;@entity&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="ss"&gt;id: &lt;/span&gt;&lt;span class="no"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
  &lt;span class="ss"&gt;notificationNumber: &lt;/span&gt;&lt;span class="no"&gt;BigInt&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
  &lt;span class="ss"&gt;recipient: &lt;/span&gt;&lt;span class="no"&gt;String&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
  &lt;span class="ss"&gt;notification: &lt;/span&gt;&lt;span class="no"&gt;String&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In &lt;code&gt;mapping.ts&lt;/code&gt; file under &lt;code&gt;src/&lt;/code&gt; directory, export the Subgraph ID;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Note: EPNS only supports The Graph Hosted Service at present&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;subgraphID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;GithubID/subgraph-slug&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Make sure the above step is complete, as Subgraph ID will be imported in the next step!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a file named &lt;code&gt;EPNSNotification.ts&lt;/code&gt; in the &lt;code&gt;src/&lt;/code&gt; folder. I’ll call it our &lt;strong&gt;Helper File&lt;/strong&gt;. Now, copy the below-provided TypeScript code and paste it into the newly created Helper file;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;log&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@graphprotocol/graph-ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;EpnsNotificationCounter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;EpnsPushNotification&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../generated/schema&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;subgraphID&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./mapping&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;sendEPNSNotification&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;recipient&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;notification&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;id1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="nx"&gt;subgraphID&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;
  &lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;New id of EpnsNotificationCounter is: {}&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;id1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;epnsNotificationCounter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;EpnsNotificationCounter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;epnsNotificationCounter&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;epnsNotificationCounter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;EpnsNotificationCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;epnsNotificationCounter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;totalCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromI32&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;epnsNotificationCounter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;totalCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;epnsNotificationCounter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;totalCount&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;plus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromI32&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;epnsNotificationCounter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;totalCount&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toHexString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;id2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;subgraphID&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;+&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
  &lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;New id of EpnsPushNotification is: {}&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;id2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;epnsPushNotification&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;EpnsPushNotification&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;epnsPushNotification&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;epnsPushNotification&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;EpnsPushNotification&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;epnsPushNotification&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;recipient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;recipient&lt;/span&gt;
  &lt;span class="nx"&gt;epnsPushNotification&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;notification&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;notification&lt;/span&gt;
  &lt;span class="nx"&gt;epnsPushNotification&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;notificationNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;epnsNotificationCounter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;totalCount&lt;/span&gt;

  &lt;span class="nx"&gt;epnsPushNotification&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="nx"&gt;epnsNotificationCounter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In &lt;code&gt;mapping.ts&lt;/code&gt; present in &lt;code&gt;src/&lt;/code&gt;, import the &lt;strong&gt;Helper File;&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;sendEPNSNotification&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./EPNSNotification&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example &lt;code&gt;mapping.ts&lt;/code&gt; file is written in TypeScript. It’s the main script that defines your notification payload and its recipients.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. &lt;strong&gt;Define Payload Items&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In the event handler method of &lt;code&gt;mapping.ts&lt;/code&gt; file, define your notification payload items such as the recipient of the notification, type, title, message, etc. These variables will be used to define our notification variable.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mapping.ts&lt;/code&gt; is present in the &lt;code&gt;epns-graph-integration/src&lt;/code&gt; folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;recipient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0xD8634C39BBFd4033c0d3289C4515275102423681&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Number changed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Number changed from &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; to &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;subject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Number changed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Number changed from &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; to &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;null&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;secret&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;null&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;cta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://epns.io/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It’s highly recommended to take a look at &lt;a href="https://docs.epns.io/developers/developer-zone/sending-notifications/advanced/notification-payload-types"&gt;this documentation&lt;/a&gt; to understand more about payload items and their definitions.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;3. Define Notification&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;notification&lt;/code&gt; variable is defined in the below format 👇🏼&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Format : &lt;code&gt;{"field" : "value"}&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;notification&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`{\"type\": \"&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;\", \"title\": \"&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;\", \"body\": \"&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;\", \"subject\": \"&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;\", \"message\": \"&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;\", \"image\": \"&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;\", \"secret\": \"&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;\", \"cta\": \"&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;cta&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;\"}`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;4. Call the EPNS Helper Function&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Once the above steps are complete, you need to invoke the EPNS helper function and send the response. To call the EPNS Notification helper function, use the below script;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;sendEPNSNotification&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;recipient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;notification&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Connect Subgraph With EPNS Channel
&lt;/h1&gt;

&lt;p&gt;Once you have set up EPNS integration into your subgraph, you must add the subgraph to its channel in order to deliver notifications. You will require a &lt;strong&gt;Subgraph ID,&lt;/strong&gt; which is usually present at the end of the subgraph URL.&lt;/p&gt;

&lt;p&gt;I hope you already created a channel. If you haven’t created one yet, check out this guide to &lt;a href="https://pythontony.hashnode.dev/getting-started-with-web3-notifications-using-epns"&gt;create a channel on EPNS&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;&lt;a href="https://staging.epns.io/"&gt;EPNS dApp&lt;/a&gt;&lt;/strong&gt; → Channel Dashboard → Settings Button → Add Subgraph Details&lt;/li&gt;
&lt;li&gt;Enter your &lt;code&gt;Subgraph ID&lt;/code&gt; and &lt;code&gt;Poll Interval&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;One important thing to note is the Poll Interval. It’s the time (in seconds), which defines the time interval at which Push Nodes shall ping the subgraph for fetching the latest notifications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This is an on-chain transaction that stores the above data to &lt;strong&gt;EPNS Core Contract.&lt;/strong&gt; So it requires $ETH for gas fees&lt;/p&gt;

&lt;p&gt;Once you complete the transaction, you have successfully integrated EPNS into your Subgraph. &lt;strong&gt;Push Nodes&lt;/strong&gt; will start polling the respective subgraph for notifications at regular Poll Intervals.&lt;/p&gt;




&lt;p&gt;Please share this tutorial with your developer community if you found it useful. Also, if you are someone who is building using The Graph Protocol, this could be a great addition to track subgraph events.&lt;/p&gt;

&lt;p&gt;I’ll be back with another awesome blog very soon. Till then, keep building and keep growing 🚀&lt;/p&gt;

&lt;p&gt;Sayonara!!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Sending Notifications Using EPNS Backend SDK</title>
      <dc:creator>Ashutosh Tripathi 🥷</dc:creator>
      <pubDate>Sat, 06 Aug 2022 14:06:33 +0000</pubDate>
      <link>https://dev.to/pythontony/sending-notifications-using-epns-backend-sdk-epa</link>
      <guid>https://dev.to/pythontony/sending-notifications-using-epns-backend-sdk-epa</guid>
      <description>&lt;p&gt;Gm folks ✨&lt;/p&gt;

&lt;p&gt;In my last tutorial, I demonstrated the complete mechanism of &lt;a href="https://pythontony.hashnode.dev/how-to-send-decentralized-notifications-using-epns"&gt;sending notifications from the EPNS dApp&lt;/a&gt;. It’s very useful for sending out broadcast notifications. However, most of the time, we are generating user-specific notifications.&lt;/p&gt;

&lt;p&gt;So how do you deliver multiple notifications (on the scale of hundreds and thousands) at the same time?&lt;/p&gt;

&lt;p&gt;The answer is pretty much obvious. You have to utilize your dApp backend to deliver these custom-tailored notifications. In order to send notifications directly from your backend, EPNS provides you with a backend SDK. This SDK provides a simple and easy-to-implement JavaScript library to send notifications from your dApp to the users.&lt;/p&gt;

&lt;p&gt;Today, I will show you exactly how to use the EPNS backend SDK and send notifications from your dApp. The SDK is very easy to use and widely available on &lt;a href="https://github.com/ethereum-push-notification-service/epns-backend-sdk-staging"&gt;this GitHub repository&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up the backend SDK
&lt;/h2&gt;

&lt;p&gt;To start sending notifications using the EPNS backend SDK, you first need to install its npm package. You need to have Node Package Manager installed in order to accomplish this task.&lt;/p&gt;

&lt;p&gt;Open up your terminal and type the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @epnsproject/backend-sdk-staging
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are using the &lt;strong&gt;Staging SDK&lt;/strong&gt; for now. Prod is very similar, the only difference lies in the environments of execution. Make sure you have already created a channel. In case you haven’t, check out &lt;a href="https://pythontony.hashnode.dev/getting-started-with-web3-notifications-using-epns"&gt;this tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Initializing the SDK
&lt;/h2&gt;

&lt;p&gt;To start utilizing the Backend SDK, I’d recommend you create a separate JavaScript file. Let’s name it “&lt;strong&gt;notify.js&lt;/strong&gt;”. Before initializing the SDK, we must import it into &lt;strong&gt;notify.js&lt;/strong&gt; and fetch our &lt;strong&gt;channel private key&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Import the SDK in notify.js by using this line of code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const EpnsSDK = require("@epnsproject/backend-sdk-staging").default;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember, we also need to establish a connection with our channel. So you have to copy the private key of your channel. In other words, you need the private key of the MetaMask wallet that is linked to your channel. If you face any trouble, check out &lt;a href="https://metamask.zendesk.com/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key"&gt;this guide to fetch the private key&lt;/a&gt; of your &lt;strong&gt;MetaMask&lt;/strong&gt; wallet.&lt;/p&gt;

&lt;p&gt;Once you have the private key, &lt;strong&gt;prepend 0x to your private key&lt;/strong&gt; and insert this line into notify.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const CHANNEL_PK = “0xPrivate_Key_Here”;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we can create an instance of the EPNS backend SDK. To do so, we will use the below snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const epnsSdk = new EpnsSDK(CHANNEL_PK);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Adding notification parameters
&lt;/h2&gt;

&lt;p&gt;Before we send out any notification, we will require certain parameters that will form the notification payload. It includes the &lt;strong&gt;title of notification&lt;/strong&gt;, &lt;strong&gt;message&lt;/strong&gt;, &lt;strong&gt;call to action link&lt;/strong&gt;, and the &lt;strong&gt;type of notification&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Some of the parameters are optional. You can check out the complete documentation available &lt;a href="https://docs.epns.io/developers/developer-tooling/backend-sdk/understanding-and-using-backend-sdk"&gt;here&lt;/a&gt; and customize payloads according to your needs. Also, don’t forget to check out the &lt;a href="https://docs.epns.io/developers/developer-zone/sending-notifications/advanced/notification-payload-types#payload-description"&gt;types of notifications&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once you decide the type of notification and its parameters, store their values in appropriate variables and call the &lt;strong&gt;sendNotification()&lt;/strong&gt; function.&lt;/p&gt;

&lt;p&gt;I have tried sending a notification to one of my other dummy accounts and entered its address in the &lt;strong&gt;recipientAddress&lt;/strong&gt; parameter. Here is the overall code snippet after importing the SDK and inserting parameters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// import required packages
const EpnsSDK = require("@epnsproject/backend-sdk-staging").default;

// connecting to the channel using the private key
const CHANNEL_PK = "0x4968b4cd6ea60a132cdef893320c11f9febd374ae3ccf0ede7820668a431acb8"; // the private key of the channel

(async function Main() {
  // initialise the sdk
  const epnsSdk = new EpnsSDK(CHANNEL_PK);

  const pushNotificationTitle = "Hello There!"; //the title which would appear in a push notification
  const pushNotificationBody = "Welcome to EPNS"; //the body which would be displayed in a push notification

  const notificationTitle = "Hello From EPNS"; //the long version of the title which would be displayed in the dApp
  const notificationBody = `Welcome to EPNS, we are glad to have you onboard`; // the long version of the body to be displayed in the dApp

  const recipientAddress = "0x5b22A6D95EDe615a263BC8e6cD214947c9873133";
  const CTA = "https://epns.io"; // the link to be used as your CTA
  const notificationType = 3; // a notification type of 3, means the notification is a direct message to the specified recipient

  // send the actual notification
  const response = await epnsSdk.sendNotification(
    recipientAddress, //the recipient of the notification
    pushNotificationTitle, //push notification title
    pushNotificationBody, //push notification body
    notificationTitle, //the title of the notification
    notificationBody, //the body of the notification
    notificationType, //notification type
    CTA); //the CTA link of the notification

  console.log({
    response,
    message: "Your notification has been successfully sent"
  });

})();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save this file as &lt;strong&gt;notify.js&lt;/strong&gt; and open the terminal. Navigate to the directory of this file and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node notify.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see a similar result as displayed in below screenshot and your notification will be sent to the specified recipient address.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kwgkALXL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g3eaj0bp7zwjuxkq53ry.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kwgkALXL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g3eaj0bp7zwjuxkq53ry.png" alt="Image description" width="880" height="207"&gt;&lt;/a&gt;&lt;br&gt;
If you found this tutorial useful, please mind sharing it in your social circles. It will help us expand our outreach in building the future of communications.&lt;/p&gt;

&lt;p&gt;Did you know that you could also &lt;strong&gt;send notifications generated from a subgraph&lt;/strong&gt;? No worries, I will show you how to do that in the simplest manner in the next tutorial.&lt;/p&gt;

&lt;p&gt;Till then, Sayonara!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Send Decentralized Notifications Using EPNS</title>
      <dc:creator>Ashutosh Tripathi 🥷</dc:creator>
      <pubDate>Thu, 28 Jul 2022 06:07:43 +0000</pubDate>
      <link>https://dev.to/pythontony/how-to-send-decentralized-notifications-using-epns-1n6j</link>
      <guid>https://dev.to/pythontony/how-to-send-decentralized-notifications-using-epns-1n6j</guid>
      <description>&lt;p&gt;Gm folks ✨&lt;/p&gt;

&lt;p&gt;It's a new wonderful week and I am back again with another quick tutorial. In &lt;a href="https://pythontony.hashnode.dev/getting-started-with-web3-notifications-using-epns"&gt;the last blog&lt;/a&gt;, I shared how to create channels using the &lt;a href="https://staging.epns.io/"&gt;&lt;strong&gt;EPNS staging dApp&lt;/strong&gt;&lt;/a&gt;. Today, I will show you the easiest way to send decentralized notifications using EPNS via the channel dashboard. We will use staging dApp (&lt;a href="https://staging.epns.io"&gt;https://staging.epns.io&lt;/a&gt;) for this purpose.&lt;/p&gt;

&lt;p&gt;The staging environment provides channel testing services on the &lt;strong&gt;Kovan testnet&lt;/strong&gt;. It is completely free to use. In case you run out of Kovan ETH, &lt;strong&gt;Paradigm&lt;/strong&gt; has an amazing &lt;a href="https://faucet.paradigm.xyz/"&gt;faucet&lt;/a&gt; that drops 1 Kovan ETH per day.&lt;/p&gt;

&lt;p&gt;Okay Ashutosh, sounds great! Let's begin 🚀&lt;/p&gt;

&lt;h1&gt;
  
  
  Sending Notifications From Your Channel
&lt;/h1&gt;

&lt;p&gt;To start sending decentralized notifications to wallets, you would be required to set up a channel on EPNS. In case you missed the last tutorial, check it out &lt;a href="https://pythontony.hashnode.dev/getting-started-with-web3-notifications-using-epns"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After you create a channel, you are redirected to the &lt;strong&gt;channel profile page&lt;/strong&gt;. Over there, you can see multiple details associated with your channel that is linked to your wallet.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---sLa7XNg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1658985212305/JHUa5Zp45.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---sLa7XNg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1658985212305/JHUa5Zp45.png" alt="Screenshot 2022-07-28 at 10.43.16 AM.png" width="880" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You would also see some subscribers already opted-in to your channel. They are &lt;strong&gt;EPNS microservices&lt;/strong&gt; that are automatically subscribed when you create a channel.&lt;/p&gt;

&lt;p&gt;In fact, one of the subscribers is your own wallet itself. This helps you in keeping track of all the notifications that have been sent out from your channel.&lt;/p&gt;

&lt;p&gt;At the bottom of your channel profile, you will see a &lt;strong&gt;Send Notification&lt;/strong&gt; section. Here you would find the &lt;strong&gt;Select Type of Notification to Send&lt;/strong&gt; dropdown menu.&lt;/p&gt;

&lt;p&gt;Click on the dropdown button and it shows three options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Broadcast&lt;/strong&gt; (IPFS Payload)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Targeted&lt;/strong&gt; (IPFS Payload)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subset&lt;/strong&gt; (IPFS Payload)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I will now demonstrate sending notifications in all these types directly from the dApp. Btw, it would be really cool if you try out sending notifs on your own 🛠&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Broadcast Notifications Using EPNS
&lt;/h2&gt;

&lt;p&gt;Imagine you are the owner of an EPNS channel that sends notifications to your community about the latest updates. You can utilize broadcast notifications to communicate info to all of your subscribers at once.&lt;/p&gt;

&lt;p&gt;In order to send broadcast notifications, click the drop-down menu next to Send Notifications and choose &lt;strong&gt;Broadcast&lt;/strong&gt;. New input fields similar to the one below will appear (I have included some dummy text in the input areas for your convenience. You can customize the details to fit your needs).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KW1jyg5V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1658985284609/es7V2i3iM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KW1jyg5V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1658985284609/es7V2i3iM.png" alt="Screenshot 2022-07-12 at 1.41.47 PM.png" width="880" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also see the real-time &lt;strong&gt;Notification Preview&lt;/strong&gt; and check out how the notification would appear once delivered to your subscribers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lr5KWa4G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1658985315596/BPINiaZtA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lr5KWa4G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1658985315596/BPINiaZtA.png" alt="2.png" width="880" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By pressing the &lt;strong&gt;Send Notification&lt;/strong&gt; button, a gasless transaction will start on the Kovan Network. The notification will be delivered after you click on the &lt;strong&gt;Sign button in MetaMask&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Targeted Notifications
&lt;/h2&gt;

&lt;p&gt;If you're building a dApp, this is the most important type. It helps you deliver &lt;strong&gt;personalized notifications to your users&lt;/strong&gt;. Many official EPNS channels, such as Uniswap, MakerDAO, and many others, use this type in combination with &lt;strong&gt;&lt;a href="https://docs.epns.io/developers/developer-tooling/backend-sdk"&gt;backend SDK&lt;/a&gt; and &lt;a href="https://docs.epns.io/developers/developer-tooling/showrunners-framework"&gt;Showrunners&lt;/a&gt;&lt;/strong&gt; to send wallet-specific notifications.&lt;/p&gt;

&lt;p&gt;Simply select the &lt;strong&gt;Targeted&lt;/strong&gt; option from the Send Notification panel to send Targeted notifications. Fill in the details and &lt;strong&gt;specify the wallet address&lt;/strong&gt; you want to notify. Consider the following example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--61wt482v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1658985421977/YYzn4ga3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--61wt482v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1658985421977/YYzn4ga3n.png" alt="4.png" width="880" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hit the Send Notification button, &lt;strong&gt;Sign the Payload&lt;/strong&gt;, and your customized notification will be delivered to the specified wallet's inbox.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Subset Notifications
&lt;/h2&gt;

&lt;p&gt;Now let's assume you only want to &lt;strong&gt;notify a group of wallet addresses&lt;/strong&gt;. Probably you need to distribute membership rewards or send notifications only to those with special access, or maybe something secret 🤓&lt;/p&gt;

&lt;p&gt;For such purposes, EPNS allows you to send decentralized notifications to a subset of users. All you need are the wallet addresses of everyone you want to notify.&lt;/p&gt;

&lt;p&gt;Select &lt;strong&gt;Subset&lt;/strong&gt; (IPFS Payload) from the Send Notifications dropdown list. You would see input fields similar to Broadcast notifications. The only difference is that a new field asks for wallet addresses. Note that multiple wallets can be added by entering comma-separated addresses or pressing the enter key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DYz3sQTb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1658985397287/-Fpr4hjbh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DYz3sQTb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1658985397287/-Fpr4hjbh.png" alt="3.png" width="880" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once done, click on the Send Notification button, and it will initiate a gasless signing transaction. Your notification will be sent to the respective wallet addresses upon successful delivery.&lt;/p&gt;




&lt;p&gt;So far, we've learned how to create channels and send Web3-native notifications using EPNS. In the next tutorial, I will guide you on how to &lt;strong&gt;set up the Backend SDK&lt;/strong&gt; and send notifications using the same.&lt;/p&gt;

&lt;p&gt;If you found this tutorial useful, I would really appreciate it if you could share it in your social circles. It will help us expand our outreach in building the future of communications.&lt;/p&gt;

&lt;p&gt;If you'd like to know more about EPNS and decentralized communications, feel free to check out our &lt;a href="https://docs.epns.io/"&gt;Docs&lt;/a&gt; or join our &lt;a href="https://discord.com/invite/YVPB99F9W5"&gt;Discord&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Until next time!&lt;/p&gt;

</description>
      <category>web3</category>
      <category>notification</category>
    </item>
    <item>
      <title>Getting Started With Web3 Notifications Using EPNS</title>
      <dc:creator>Ashutosh Tripathi 🥷</dc:creator>
      <pubDate>Thu, 21 Jul 2022 06:32:17 +0000</pubDate>
      <link>https://dev.to/pythontony/getting-started-with-web3-notifications-using-epns-3f6h</link>
      <guid>https://dev.to/pythontony/getting-started-with-web3-notifications-using-epns-3f6h</guid>
      <description>&lt;p&gt;Gm folks ✨&lt;/p&gt;

&lt;p&gt;This is a quickstart tutorial for developers to start integrating Web3 notifications in their projects using &lt;strong&gt;&lt;a href="https://epns.io/"&gt;Ethereum Push Notification Service (EPNS)&lt;/a&gt;&lt;/strong&gt;, which is the first decentralized protocol to send push notifications for decentralized apps (&lt;strong&gt;dApps&lt;/strong&gt;), &lt;strong&gt;NFTs&lt;/strong&gt;, and &lt;strong&gt;DAOs&lt;/strong&gt; like &lt;strong&gt;Uniswap, MakerDAO, ENS&lt;/strong&gt;, and many more.&lt;/p&gt;

&lt;p&gt;This tutorial will show you all about channels, subscribers, and notifications. You don’t need to have some fancy developer tag to be here. Just your coffee ☕️ and an inquisitive mind 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  Decentralized Push Notifications
&lt;/h2&gt;

&lt;p&gt;Push notifications have become an integral part of our lives, with nearly &lt;strong&gt;&lt;a href="https://blog.avada.io/resources/push-notification-statistics.html"&gt;3 billion active users&lt;/a&gt;&lt;/strong&gt; worldwide in 2021. These notifications are like messages. You can send them to all subscribers or specific users.&lt;/p&gt;

&lt;p&gt;Their arrival on blockchains like &lt;strong&gt;Ethereum&lt;/strong&gt; is imminent and will be extremely beneficial for the growth of the ecosystem.&lt;/p&gt;

&lt;p&gt;At EPNS, we are building the communication layer for Web3, starting out with decentralized push notifications. Any wallet, dApp, smart contract, or backend can create a channel on EPNS.&lt;/p&gt;

&lt;p&gt;Channels are further able to send &lt;strong&gt;gasless notifications&lt;/strong&gt; tied to user wallets. Users can receive these notifications via the Android/iOS app or browser extension.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Channels?
&lt;/h2&gt;

&lt;p&gt;To start sending push notifications in Web3, the easiest way is to set up a channel on EPNS. Channels are a lot like telephone numbers. They're used to &lt;strong&gt;route notifications&lt;/strong&gt; to the right wallets. Your &lt;strong&gt;wallet address&lt;/strong&gt; becomes the destination for receiving those push notifications.&lt;/p&gt;

&lt;p&gt;You must have watched videos from your favorite channels on YouTube. You receive notifications for the latest content when you press the “Subscribe” button on their channel. YouTube uses channels to route these notifications to its subscribers, but these are &lt;strong&gt;centralized&lt;/strong&gt; (i.e. owned by Google) and can be shut down at any time 😨&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EPNS allows you to create your own channels&lt;/strong&gt; leveraging our protocol on decentralized networks. These channels can be subscribed to by users of your dApp and receive push notifications. It creates a secure and verified communication medium for decentralized apps and their users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Channels are decentralized&lt;/strong&gt; and can not be shut down. And above all, it’s extremely easy to use, with a user-friendly interface and simple tools for developers.&lt;/p&gt;

&lt;p&gt;With a channel linked to your wallet on EPNS, you can send out &lt;strong&gt;broadcasts&lt;/strong&gt;, &lt;strong&gt;targeted&lt;/strong&gt;, &lt;strong&gt;subset&lt;/strong&gt;, and even &lt;strong&gt;secret&lt;/strong&gt; notifications. And above all, our dApp makes it super easy to send push notifications. You don't need to know the ins and outs of how it works 😉&lt;/p&gt;

&lt;h2&gt;
  
  
  5 Steps To Create Your Channel
&lt;/h2&gt;

&lt;p&gt;To start with, you can create channels on &lt;strong&gt;&lt;a href="https://app.epns.io"&gt;Prod&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://staging.epns.io"&gt;Staging&lt;/a&gt; dApp&lt;/strong&gt;. If you want to try out how channels work and send notifications, it’s highly recommended for you to try the Staging dApp. All you need is a &lt;strong&gt;&lt;a href="https://metamask.io/"&gt;MetaMask wallet&lt;/a&gt;&lt;/strong&gt; and the &lt;strong&gt;logo of your channel&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For those who are not aware of Metamask, it’s a decentralized wallet provider used to interact with Ethereum. You can download the &lt;a href="https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en"&gt;browser extension&lt;/a&gt; or their Android/iOS application to connect with EPNS dApp.&lt;/p&gt;

&lt;p&gt;Creating a channel takes only a few clicks and you are up and running. And I’ll show you exactly how to do that in 5 easy steps 😉&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1 →&lt;/strong&gt; Go to the EPNS Staging dApp available on &lt;a href="https://staging.epns.io/"&gt;https://staging.epns.io/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rX8G-17N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e59044rx6z2qkn4929ch.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rX8G-17N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e59044rx6z2qkn4929ch.png" alt="Connect MetaMask Wallet to EPNS" width="880" height="434"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;2 →&lt;/strong&gt; Connect your Metamask Wallet with the dApp&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3 →&lt;/strong&gt; Once Connected, go to Create Channel option in the Developer tab. Upload your Channel Logo and don't forget to click on Get Free DAI for Channel. By the way, you won't get the Free DAI option on Prod dApp. You will have to stake real DAI 🙂&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tgoTqLeX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0eztnjrx0srcqy5lx3pw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tgoTqLeX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0eztnjrx0srcqy5lx3pw.png" alt="Get Free DAI" width="880" height="345"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;4 →&lt;/strong&gt; Fill in all relevant Channel Details. Keep the Alias network fields blank 😉 We'll need it only when we create a Channel Alias (Polygon is live on Staging 💜)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w8gnwQ25--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zcwl8k0s7ibimssz53d4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w8gnwQ25--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zcwl8k0s7ibimssz53d4.png" alt="Fill Details" width="880" height="396"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;5 →&lt;/strong&gt; Once all the details are filled, click on Setup Channel. This will initiate two important transactions&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;Approval of DAI *&lt;/em&gt;→ This transaction ensures that your wallet address has successfully approved the EPNSCore contract to use 50 DAI on your behalf.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Channel Creation on EPNS Core&lt;/strong&gt; → Once approved, the 2nd transaction calls the channel creation function on EPNSCore smart contract to create the channel.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--puW8AsGX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jph4izgji79qm419zz33.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--puW8AsGX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jph4izgji79qm419zz33.png" alt="Channel profile page" width="880" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And you are all set up!&lt;/p&gt;

&lt;p&gt;Here is a 3-min video, you can check it out 💻&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/j7dAXXUjvmE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Opt-In To Push Notifications
&lt;/h2&gt;

&lt;p&gt;Any user who owns a Web3 wallet like MetaMask can opt-in to receive notifications from channels. Opting in to any channel is &lt;strong&gt;gasless&lt;/strong&gt; and does not require any fee.&lt;/p&gt;

&lt;p&gt;Once connected, you will see a similar list to the one below 👇🏼&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0slmbdne--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qhp8bw4g7bd27wu1coqk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0slmbdne--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qhp8bw4g7bd27wu1coqk.png" alt="List of Channels on EPNS" width="880" height="459"&gt;&lt;/a&gt;&lt;br&gt;
You can choose to opt-in for channels that can send you push notifications. And by the way, these notifications can be received via our &lt;a href="https://chrome.google.com/webstore/detail/epns-protocol-alpha/lbdcbpaldalgiieffakjhiccoeebchmg"&gt;browser extension&lt;/a&gt; (which works only on Chrome), or native &lt;a href="https://play.google.com/store/apps/details?id=io.epns.epns&amp;amp;hl=en_IN&amp;amp;gl=US"&gt;Android&lt;/a&gt;/&lt;a href="https://apps.apple.com/us/app/ethereum-push-service-epns/id1528614910"&gt;iOS&lt;/a&gt; apps. You can also choose to view the notifications in your &lt;strong&gt;Inbox on EPNS dApp&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;In the next tutorial, we will teach you how to send different types of notifications from the EPNS dApp. We will also cover the integration of EPNS SDK, please stay tuned!&lt;/p&gt;

&lt;p&gt;If you found this tutorial useful, please mind sharing it in your social circles. It will help us expand our outreach in building the future of communications.&lt;/p&gt;

&lt;p&gt;If you’d like to know more about EPNS and decentralized communications, feel free to check out our &lt;a href="https://docs.epns.io"&gt;Docs&lt;/a&gt; or join our &lt;a href="https://discord.com/invite/YVPB99F9W5"&gt;Discord&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Until next time!&lt;/p&gt;

</description>
      <category>web3</category>
      <category>decentralized</category>
      <category>communication</category>
    </item>
  </channel>
</rss>
