<?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>Developers Forum for XinFin XDC Network: Bobby Jonas</title>
    <description>The latest articles on Developers Forum for XinFin XDC Network by Bobby Jonas (@bobby_jonas_cfc8fb6699f6c).</description>
    <link>https://www.xdc.dev/bobby_jonas_cfc8fb6699f6c</link>
    <image>
      <url>https://www.xdc.dev/images/IGTpoKD6I9eBpnrmGGePtX1eMI4ewgf_MqNeX7m5sfk/rs:fill:90:90/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL3VzZXIvcHJv/ZmlsZV9pbWFnZS8x/NjU2L2FiYjI1Zjc1/LThiMzAtNDFmZS1i/NDA4LTAzMWNhNzQ4/OWMyYi5wbmc</url>
      <title>Developers Forum for XinFin XDC Network: Bobby Jonas</title>
      <link>https://www.xdc.dev/bobby_jonas_cfc8fb6699f6c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://www.xdc.dev/feed/bobby_jonas_cfc8fb6699f6c"/>
    <language>en</language>
    <item>
      <title>Issues subscribing to newBlockHeaders event using web3 npm module</title>
      <dc:creator>Bobby Jonas</dc:creator>
      <pubDate>Tue, 18 Apr 2023 08:40:03 +0000</pubDate>
      <link>https://www.xdc.dev/bobby_jonas_cfc8fb6699f6c/issues-subscribing-to-newblockheaders-event-using-web3-npm-module-4lcd</link>
      <guid>https://www.xdc.dev/bobby_jonas_cfc8fb6699f6c/issues-subscribing-to-newblockheaders-event-using-web3-npm-module-4lcd</guid>
      <description>&lt;p&gt;I'm having issues subscribing to newBlockHeaders event using web3 npm module.&lt;/p&gt;

&lt;p&gt;Here's some basic code I'm running,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
const web3 = new Web3(new Web3.providers.WebsocketProvider('wss://ws.xinfin.network'));
 web3.eth.subscribe('newBlockHeaders', (error, result) =&amp;gt; {
    if (error) {
      console.error(error);
    } else {
      console.log(result);
    }
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I get this error in the console. Using ReactJS btw:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dex.js:262 Uncaught Error: Given address "xdc0000000000000000000000000000000000000000" is not a valid Ethereum address.
    at Object.toChecksumAddress (index.js:262:1)
    at Object.outputBlockFormatter [as outputFormatter] (formatters.js:283:1)
    at push../node_modules/web3-core-subscriptions/lib/subscription.js.Subscription._formatOutput (subscription.js:102:1)
    at subscription.js:235:1
    at Array.forEach (&amp;lt;anonymous&amp;gt;)
    at Object.callback (subscription.js:234:1)
    at WebsocketProvider.data (index.js:99:1)
    at WebsocketProvider.emit (index.js:181:1)
    at index.js:104:1
    at Array.forEach (&amp;lt;anonymous&amp;gt;)
    at push../node_modules/web3-providers-ws/lib/index.js.WebsocketProvider._onMessage (index.js:102:1)
t
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tried with both web3 module version 1.5.2 and 1.6.1&lt;/p&gt;

</description>
      <category>xdc</category>
      <category>web3</category>
      <category>websocket</category>
      <category>subscribe</category>
    </item>
  </channel>
</rss>
