<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Oleg on Web3</title>
        <link>https://paragraph.com/@oleg-on-web3</link>
        <description>Senior Software Everything ◦ 3x CTO &amp; founder◦ 10+ years as a full-stack dev ◦ Web3 novice</description>
        <lastBuildDate>Thu, 16 Apr 2026 12:10:45 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>Oleg on Web3</title>
            <url>https://storage.googleapis.com/papyrus_images/ab6557597bf2d81fc96f9c3939b4b7be6ff83852fda0eb844b737c6f2d4639c3.png</url>
            <link>https://paragraph.com/@oleg-on-web3</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[JavaScript to retrieve Ethereum blockchain data]]></title>
            <link>https://paragraph.com/@oleg-on-web3/javascript-to-retrieve-ethereum-blockchain-data</link>
            <guid>izpBDaAUJSVCMyDqVzQB</guid>
            <pubDate>Fri, 09 Sep 2022 09:33:42 GMT</pubDate>
            <description><![CDATA[This post is for you if you are making your way to Web3 as a JavaScript developer and are searching for a starting point. As such, let&apos;s dive into the ethers.js library with this tutorial. You&apos;ll learn how to find out how much ETH is in different Ethereum wallets.What is Ethereum blockchain?Ethereum is a public, decentralized platform for developers to deploy and execute computer code in the form of "contracts." Both the code and the data generated by running it are stored on the bl...]]></description>
            <content:encoded><![CDATA[<p>This post is for you if you are making your way to Web3 as a JavaScript developer and are searching for a starting point. As such, let&apos;s dive into the ethers.js library with this tutorial. You&apos;ll learn how to find out how much ETH is in different Ethereum wallets.</p><h1 id="h-what-is-ethereum-blockchain" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">What is Ethereum blockchain?</h1><p>Ethereum is a public, decentralized platform for developers to deploy and execute computer code in the form of &quot;contracts.&quot; Both the code and the data generated by running it are stored on the blockchain, a distributed database. Like every Ethereum user, every contract has a wallet address. The book &quot;Mastering Ethereum&quot; contains additional information if you want to learn more about it.</p><h1 id="h-retrieving-cryptopunks-contracts-balance" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Retrieving CryptoPunks contract&apos;s balance</h1><p>CryptoPunks is a famous collection of 10,000 unique 8-bit characters stored on the Ethereum blockchain as NFTs. The contract acts as a middleman between the seller and the buyer, protecting both sides. You may examine this contract and related transactions by using tools like Etherscan.</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://etherscan.io/contractdiffchecker?a1=0x16f5a35647d6f03d5d3da7b35409d65ba03af3b2">https://etherscan.io/contractdiffchecker?a1=0x16f5a35647d6f03d5d3da7b35409d65ba03af3b2</a></p><p>To get a contract&apos;s balance, you should first install the ethers package with npm.</p><pre data-type="codeBlock" text="npm install --save ethers
"><code>npm install <span class="hljs-operator">-</span><span class="hljs-operator">-</span>save ethers
</code></pre><p>In your preferred IDE, create a file called <code>getbalance.js</code>. Add some code to the top of the file to use ethers.</p><pre data-type="codeBlock" text="const ethers = require(&quot;ethers&quot;);
"><code>const <span class="hljs-attr">ethers</span> = require(<span class="hljs-string">"ethers"</span>)<span class="hljs-comment">;</span>
</code></pre><p>Next step is to get a provider, which is an abstraction of a connection to the Ethereum platform.</p><pre data-type="codeBlock" text="const ethers = require(&quot;ethers&quot;);

const provider = ethers.getDefaultProvider();
"><code>const <span class="hljs-attr">ethers</span> = require(<span class="hljs-string">"ethers"</span>)<span class="hljs-comment">;</span>

const <span class="hljs-attr">provider</span> = ethers.getDefaultProvider()<span class="hljs-comment">;</span>
</code></pre><p>Add a constant <code>CRYPTO_PUNKS</code> with a contract&apos;s address. Because data in a blockchain is never changed, you can safely copy and paste it from this article.</p><pre data-type="codeBlock" text="const ethers = require(&quot;ethers&quot;);

const provider = ethers.getDefaultProvider();

CRYPTO_PUNKS = &quot;0x16F5A35647D6F03D5D3da7b35409D65ba03aF3B2&quot;
"><code>const <span class="hljs-attr">ethers</span> = require(<span class="hljs-string">"ethers"</span>)<span class="hljs-comment">;</span>

const <span class="hljs-attr">provider</span> = ethers.getDefaultProvider()<span class="hljs-comment">;</span>

<span class="hljs-attr">CRYPTO_PUNKS</span> = <span class="hljs-string">"0x16F5A35647D6F03D5D3da7b35409D65ba03aF3B2"</span>
</code></pre><p>You&apos;re almost there! Create an async function called <code>getBalance</code> to acquire the current balance of a wallet by its address.</p><pre data-type="codeBlock" text="async function getBalance(address) {
  const balanceBigNumber = await provider.getBalance(address);
}
"><code>async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getBalance</span>(<span class="hljs-params"><span class="hljs-keyword">address</span></span>) </span>{
  const balanceBigNumber <span class="hljs-operator">=</span> await provider.getBalance(<span class="hljs-keyword">address</span>);
}
</code></pre><p>Ethereum&apos;s default currency is Wei, which is quite small in comparison to ETH. To make the output more readable, use the <code>ethers.utils.formatEther</code> function to convert the value and print the result to the console in &quot;ETH&quot; currency.</p><pre data-type="codeBlock" text="async function getBalance(address) {
  const balanceBigNumber = await provider.getBalance(address);
  console.log(ethers.utils.formatEther(balanceBigNumber), &quot;ETH&quot;);
}
"><code>async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getBalance</span>(<span class="hljs-params"><span class="hljs-keyword">address</span></span>) </span>{
  const balanceBigNumber <span class="hljs-operator">=</span> await provider.getBalance(<span class="hljs-keyword">address</span>);
  console.log(ethers.utils.formatEther(balanceBigNumber), <span class="hljs-string">"ETH"</span>);
}
</code></pre><p>The final step is to add <code>getBalance(CRYPTO_PUNKS);</code> to the end of the file and check the results. Your <code>getbalance.js</code> file should look something like this by now:</p><pre data-type="codeBlock" text="const ethers = require(&quot;ethers&quot;);

const provider = ethers.getDefaultProvider();

const CRYPTO_PUNKS = &quot;0x16F5A35647D6F03D5D3da7b35409D65ba03aF3B2&quot;;

async function getBalance(address) {
  const balanceBigNumber = await provider.getBalance(address);
  console.log(ethers.utils.formatEther(balanceBigNumber), &quot;ETH&quot;);
} 

getBalance(CRYPTO_PUNKS);
"><code>const ethers <span class="hljs-operator">=</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">"ethers"</span>);

const provider <span class="hljs-operator">=</span> ethers.getDefaultProvider();

const CRYPTO_PUNKS <span class="hljs-operator">=</span> <span class="hljs-string">"0x16F5A35647D6F03D5D3da7b35409D65ba03aF3B2"</span>;

async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getBalance</span>(<span class="hljs-params"><span class="hljs-keyword">address</span></span>) </span>{
  const balanceBigNumber <span class="hljs-operator">=</span> await provider.getBalance(<span class="hljs-keyword">address</span>);
  console.log(ethers.utils.formatEther(balanceBigNumber), <span class="hljs-string">"ETH"</span>);
} 

getBalance(CRYPTO_PUNKS);
</code></pre><p>Run your code to see the current balance of the CryptoPunks NFT contract.</p><pre data-type="codeBlock" text="node getbalance.js
"><code>node getbalance.js
</code></pre><p>You&apos;ll most likely get the same result as seen below:</p><pre data-type="codeBlock" text="0.0 ETH
"><code></code></pre><p>If the contract&apos;s balance is zero, it means that no one is trading NFTs through it. This is a regular occurrence for collections as rare as CryptoPunks, so don&apos;t worry, we&apos;ll discover another wallet with some ETH on it.</p><h1 id="h-retrieve-a-persons-wallet-balance" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Retrieve a person&apos;s wallet balance</h1><p>You may also get the balance of any person&apos;s wallet because it is public information. To see the current balance of one of Ethereum&apos;s oldest wallets, add the following code to the end of <code>getbalance.js</code>.</p><pre data-type="codeBlock" text="getBalance(&quot;0x87885AaEEdED51C7e3858a782644F5d89759f245&quot;);
"><code><span class="hljs-built_in">getBalance</span>("<span class="hljs-number">0</span>x87885AaEEdED51C7e3858a782644F5d89759f245");
</code></pre><p>This wallet was created by Vitalik Buterin, who was the first to describe the Ethereum concept in a document known as the Yellow Paper.</p><p>At the time of this writing, the following results of code execution were obtained:</p><pre data-type="codeBlock" text="40.039662359041694731 ETH
"><code></code></pre><h1 id="h-exceeding-request-rate" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Exceeding Request-Rate</h1><p>You will likely see this notice regarding excessive code executions. This is nothing more than a reminder to create an API key you can use with <code>getDefaultProvider</code> function. This step can be ignored if you wait a minute or so to run your code again.</p><pre data-type="codeBlock" text="========= NOTICE =========
Request-Rate Exceeded  (this message will not be repeated)

The default API keys for each service are provided as a highly-throttled,
community resource for low-traffic projects and early prototyping.

While your application will continue to function, we highly recommended
signing up for your own API keys to improve performance, increase your
request rate/limit and enable other perks, such as metrics and advanced APIs.

For more details: https://docs.ethers.io/api-keys/
==========================
"><code><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> NOTICE <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span>
Request<span class="hljs-operator">-</span>Rate Exceeded  (<span class="hljs-built_in">this</span> message will not be repeated)

The default API keys <span class="hljs-keyword">for</span> each service are provided <span class="hljs-keyword">as</span> a highly<span class="hljs-operator">-</span>throttled,
community resource <span class="hljs-keyword">for</span> low<span class="hljs-operator">-</span>traffic projects and early prototyping.

While your application will <span class="hljs-keyword">continue</span> to <span class="hljs-function"><span class="hljs-keyword">function</span>, <span class="hljs-title">we</span> <span class="hljs-title">highly</span> <span class="hljs-title">recommended</span>
<span class="hljs-title">signing</span> <span class="hljs-title">up</span> <span class="hljs-title"><span class="hljs-keyword">for</span></span> <span class="hljs-title">your</span> <span class="hljs-title">own</span> <span class="hljs-title">API</span> <span class="hljs-title">keys</span> <span class="hljs-title">to</span> <span class="hljs-title">improve</span> <span class="hljs-title">performance</span>, <span class="hljs-title">increase</span> <span class="hljs-title">your</span>
<span class="hljs-title">request</span> <span class="hljs-title">rate</span>/<span class="hljs-title">limit</span> <span class="hljs-title">and</span> <span class="hljs-title">enable</span> <span class="hljs-title">other</span> <span class="hljs-title">perks</span>, <span class="hljs-title">such</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">metrics</span> <span class="hljs-title">and</span> <span class="hljs-title">advanced</span> <span class="hljs-title">APIs</span>.

<span class="hljs-title">For</span> <span class="hljs-title">more</span> <span class="hljs-title">details</span>: <span class="hljs-title">https</span>:<span class="hljs-comment">//docs.ethers.io/api-keys/</span>
==========================
</span></code></pre><h1 id="h-summary" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Summary</h1><p>You&apos;ve learned how to use ethers.js to read Ethereum blockchain data to retrieve any wallet&apos;s balance. As a more advanced usage, you can also execute contracts and change data with it. Read the official documentation for more details and code examples.</p><h1 id="h-summary" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Summary</h1><p>You&apos;ve learned how to use ethers.js to read Ethereum blockchain data to retrieve any wallet&apos;s balance. As a more advanced usage, you can also execute contracts and change data with it. Read the official documentation for more details and code examples <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.ethers.io/v5/">https://docs.ethers.io/v5/</a></p><p>If you&apos;re a ReactJS developer who wants to use Ethereum as a backend and build a frontend for your app, you&apos;ll probably like to check out WAGMI: React Hooks for Ethereum built on top of ethers.js.</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://wagmi.sh/">https://wagmi.sh/</a></p><p>Ethers.js is not the only node package to read data from Ethereum. As an alternative, you can use web3.js a collection of Ethereum libraries</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://web3js.readthedocs.io/en/">https://web3js.readthedocs.io/en/</a></p><p>And finally, you can avoid using any middleware and send HTTP requests directly to Ethereum JSON RPC API.</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ethereum.org/en/developers/docs/apis/json-rpc/">https://ethereum.org/en/developers/docs/apis/json-rpc/</a></p><p>All of the tools above are in a constant development state, so don&apos;t hesitate to send your feedback to the authors. Whatever way you choose, it&apos;s easier to build web3 together with the intention of helping each other.</p>]]></content:encoded>
            <author>oleg-on-web3@newsletter.paragraph.com (Oleg on Web3)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/12991497fe4a163d2006ae79f02d50c56dd371ad9e0d16b9798245882cbb5845.png" length="0" type="image/png"/>
        </item>
    </channel>
</rss>