<?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>Seshanth</title>
        <link>https://paragraph.com/@seshanth</link>
        <description>Smartcontract Developer at Daoventures, Singapore</description>
        <lastBuildDate>Thu, 21 May 2026 13:11:07 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>Seshanth</title>
            <url>https://storage.googleapis.com/papyrus_images/5ab9afc8bf87bb4021d14ad6414a2581273b6768e29d05bee75f5d37aa07b344.png</url>
            <link>https://paragraph.com/@seshanth</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[Huff Challenge #1]]></title>
            <link>https://paragraph.com/@seshanth/huff-challenge-1</link>
            <guid>hKrPEODnx8Q7GCmf37zy</guid>
            <pubDate>Sun, 21 Aug 2022 12:39:24 GMT</pubDate>
            <description><![CDATA[I recently got to know about a new programming language called Huff. Huff is a low-level programming language to write EVM smartcontracts directly in opcodes. With Huff one can write more optimised smartcontracts as It doesn’t abstract anything from the devs and gives complete control over the stack. I’m learning huff to get to know more about the EVM. Huff’s official Twitter has recently started posting challenges. I’ll try to solve them and document it here :).Challenge #1challenge #1Huff C...]]></description>
            <content:encoded><![CDATA[<p>I recently got to know about a new programming language called Huff. Huff is a low-level programming language to write EVM smartcontracts directly in opcodes. With Huff one can write more optimised smartcontracts as It doesn’t abstract anything from the devs and gives complete control over the stack.</p><p>I’m learning huff to get to know more about the EVM.</p><p>Huff’s official Twitter has recently started posting challenges. I’ll try to solve them and document it here :).</p><h2 id="h-challenge-1" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Challenge #1</h2><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/huff_language/status/1559658361469095936?s=20&amp;t=QtLjoQz1gyVX6cL7nMzb9w">challenge #1</a></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/15b80e4d25bb8f0934947a991d3ec18206b7505d3bbbab286036a77e39e5149d.png" alt="Huff Challenge #1" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Huff Challenge #1</figcaption></figure><p>As the challenge description says, the target is to write as little huff code as possible to return the current block number.</p><h2 id="h-solution" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Solution</h2><pre data-type="codeBlock" text="#define macro MAIN() = takes(0) returns(0) {
  number              //[blockNumber]
  0x00                //[0x00, blockNumber]
  mstore              //saves blockNumber to mem offset 0x00
                      //[]

  0x20                //[0x20]
  0x00                //[0x00]
  return              //returns 
}
"><code><span class="hljs-selector-id">#define</span> macro <span class="hljs-selector-tag">MAIN</span>() = <span class="hljs-built_in">takes</span>(<span class="hljs-number">0</span>) <span class="hljs-built_in">returns</span>(<span class="hljs-number">0</span>) {
  number              <span class="hljs-comment">//[blockNumber]</span>
  <span class="hljs-number">0</span>x00                <span class="hljs-comment">//[0x00, blockNumber]</span>
  mstore              <span class="hljs-comment">//saves blockNumber to mem offset 0x00</span>
                      <span class="hljs-comment">//[]</span>

  <span class="hljs-number">0</span>x20                <span class="hljs-comment">//[0x20]</span>
  <span class="hljs-number">0</span>x00                <span class="hljs-comment">//[0x00]</span>
  return              <span class="hljs-comment">//returns </span>
}
</code></pre><p>Huff code always starts from the <code>MAIN()</code> macro.</p><p><code>takes(0) returns(0)</code> means that this macro doesn’t take any data from the stack and doesn’t push any data to the stack upon completion.</p><p>The following snippet gets the blockNumber and saves it to memory at offset 0.</p><pre data-type="codeBlock" text="number
0x00
mstore
"><code><span class="hljs-built_in">number</span>
<span class="hljs-number">0x00</span>
mstore
</code></pre><p>First, the <code>NUMBER</code> opcode is executed, which pushes the current block number to the stack.</p><p>Our target is to return the block number. To return any data, we need to use the <code>RETURN</code> opcode. The <code>RETURN</code> opcodes takes input from the memory, so the block number should be stored in the memory.</p><p>Followed by <code>NUMBER</code> is, <code>0x00</code> which pushes <strong>0</strong> to the stack. So the stack looks like <strong>[0x00, blockNumber]</strong>.</p><p><code>MSTORE</code> opcode stores the input(block number) to the memory. It takes 2 args,</p><ol><li><p>The memory offset,</p></li><li><p>The data to store.</p></li></ol><p>Here, <strong>0x00</strong> is the memory offset and <strong>blockNumber</strong> is the data. The BlockNumber is saved to the memory at offset 0.</p><p>As mentioned before, The <code>RETURN</code> opcode is used to return the data.</p><pre data-type="codeBlock" text="0x20 
0x00 
return
"><code><span class="hljs-number">0x20</span> 
<span class="hljs-number">0x00</span> 
<span class="hljs-keyword">return</span>
</code></pre><p><code>RETURN</code> takes 2 inputs,</p><ol><li><p>The memory offset to start reading from,</p></li><li><p>The size in bytes.</p></li></ol><p>First, the byte size <code>0x20</code>(32 bytes) is pushed into the stack. Followed by the memory offset <code>0x00</code>.</p><p>The stack now looks like, <strong>[0x00, 0x20]</strong></p><p>The <code>RETURN</code> opcode is then pushed to the stack, which reads 32 bytes**(0x20)** starting from the memory offset <strong>0</strong> and returns it.</p>]]></content:encoded>
            <author>seshanth@newsletter.paragraph.com (Seshanth)</author>
        </item>
    </channel>
</rss>