<?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: Fuzz</title>
    <description>The latest articles on Developers Forum for XinFin XDC Network by Fuzz (@dazraf).</description>
    <link>https://www.xdc.dev/dazraf</link>
    <image>
      <url>https://www.xdc.dev/images/rWDrWmRxuL_FA0HLa_rQU3mmMo8p_mGfV_LJznVcq2I/rs:fill:90:90/mb:500000/ar:1/aHR0cHM6Ly93d3cu/eGRjLmRldi91cGxv/YWRzL3VzZXIvcHJv/ZmlsZV9pbWFnZS80/Mi9iZTU0YWQ0ZS1l/M2Q3LTRjZWItODIy/ZC0xMGFiODVhYjA3/NmYuanBlZw</url>
      <title>Developers Forum for XinFin XDC Network: Fuzz</title>
      <link>https://www.xdc.dev/dazraf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://www.xdc.dev/feed/dazraf"/>
    <language>en</language>
    <item>
      <title>(Closed)Has anyone deployed an Upgradeable Contract?</title>
      <dc:creator>Fuzz</dc:creator>
      <pubDate>Sun, 18 Dec 2022 22:17:21 +0000</pubDate>
      <link>https://www.xdc.dev/dazraf/has-anyone-deployed-an-upgradeable-contract-51ab</link>
      <guid>https://www.xdc.dev/dazraf/has-anyone-deployed-an-upgradeable-contract-51ab</guid>
      <description>&lt;p&gt;Hi, &lt;/p&gt;

&lt;p&gt;I'm using the OpenZeppelin base contracts with their transparent proxy feature. &lt;/p&gt;

&lt;p&gt;The deployment of the proxy is successful but when it comes to verification on the &lt;a href="https://explorer.xinfin.network"&gt;explorer&lt;/a&gt; the verification fails.&lt;/p&gt;

&lt;p&gt;Without using the upgradeable proxy, the contract can be successfully verified. Does anyone have any experience with upgradeable contracts using OpenZeppelin? &lt;/p&gt;

&lt;p&gt;Thank you.&lt;/p&gt;

</description>
      <category>upgradeable</category>
      <category>proxy</category>
      <category>openzeppelin</category>
      <category>explorer</category>
    </item>
    <item>
      <title>Debugging &amp; Solving Hardhat Flattening Issues</title>
      <dc:creator>Fuzz</dc:creator>
      <pubDate>Sun, 18 Dec 2022 19:55:54 +0000</pubDate>
      <link>https://www.xdc.dev/dazraf/debugging-solving-hardhat-flattening-issues-10ke</link>
      <guid>https://www.xdc.dev/dazraf/debugging-solving-hardhat-flattening-issues-10ke</guid>
      <description>&lt;p&gt;Hello! &lt;/p&gt;

&lt;p&gt;I've discovered a few tricks to validate contracts, built and flattened by Hardhat, on the XDC blockchain explorer.&lt;/p&gt;

&lt;h1&gt;
  
  
  TL;DR
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Don't turn on the XDC Explorer's &lt;code&gt;optimization&lt;/code&gt; flag. &lt;/li&gt;
&lt;li&gt;Remove the &lt;code&gt;config: {...}&lt;/code&gt; preamble in the flattened file.&lt;/li&gt;
&lt;li&gt;In the flattened file, replace all &lt;code&gt;SPDX-License-Identifiers&lt;/code&gt; with &lt;code&gt;SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  How it started ...
&lt;/h1&gt;

&lt;p&gt;This is a brief description of a problem I ran into this week while using &lt;a href="https://hardhat.org/"&gt;Hardhat&lt;/a&gt; version &lt;code&gt;2.12.4&lt;/code&gt; with &lt;code&gt;solc&lt;/code&gt; &lt;code&gt;0.8.17&lt;/code&gt; and the current version of the XDC Explorer (for both Apothem and Mainnet). &lt;/p&gt;

&lt;p&gt;I've been developing an XRC20 compliant Token using Open Zeppelin's &lt;a href="https://www.openzeppelin.com/contracts"&gt;contracts&lt;/a&gt; with several of the supporting interfaces such as &lt;code&gt;ERC20Burnable&lt;/code&gt; and &lt;code&gt;Pausable&lt;/code&gt;. The contract was compiled with the optimizer enabled and set to &lt;code&gt;200&lt;/code&gt; runs. &lt;/p&gt;

&lt;p&gt;Deploying the contract to Apothem went smoothly. I then flattened the contract using a technique that's been documented in the &lt;a href="https://docs.xdc.community/learn/how-to-articles/create-and-deploy-your-first-smart-contract-on-the-xdc-network-using-openzeppelin-and-hardhat#flattening-the-smart-contract"&gt;XDC docs&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hardhat flatten ./contracts/FuzzTest.sol &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ./contracts-flattened/FuzzTest.sol
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;... and then attempted to verify the contract on the &lt;a href="https://explorer.apothem.network/"&gt;Apothem Explorer&lt;/a&gt;. Every approach I tried failed either with an immediate non-descriptive error or a timeout (HTTP 524)!&lt;/p&gt;

&lt;h1&gt;
  
  
  The Quest ...
&lt;/h1&gt;

&lt;p&gt;After &lt;a href="https://discord.com/channels/1002620393032519790/1015312032540667914/1054018652715876402"&gt;a very useful conversation&lt;/a&gt; on the XDC Discord (thanks &lt;a class="mentioned-user" href="https://www.xdc.dev/menezesphill"&gt;@menezesphill&lt;/a&gt; !) I went back to basics and setup the contract in Remix using &lt;a href="https://docs.xdc.community/learn/how-to-articles/create-and-deploy-your-first-your-first-smart-contract-on-the-xdc-network-using-openzepplin"&gt;this guide&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;I diff'd the output of the Flattener Remix plugin and through a process of experimentation I discovered three key steps for solving this issue.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Answer
&lt;/h1&gt;

&lt;h3&gt;
  
  
  1. Hardhat's config preamble needs to be removed
&lt;/h3&gt;

&lt;p&gt;Hardhat emits this in the flattened file and it's not recognised by the XDC Explorer - it needs to be deleted before being uploaded:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;config:
{"solidity":{"version":"0.8.17","settings":{"optimizer":{"enabled":true,"runs":200}}},"networks":{"xinfin":{"url":"https://erpc.apothem.network","accounts":["xxx"]}}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. &lt;code&gt;SPDX-License-Identifiers&lt;/code&gt; have to be replaced
&lt;/h3&gt;

&lt;p&gt;Replace &lt;code&gt;SPDX-License-Identifiers&lt;/code&gt; with &lt;code&gt;SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. XDC Explorer's Optimizer Flag
&lt;/h3&gt;

&lt;p&gt;When uploading your flattened file, do not enable the &lt;code&gt;Optimization&lt;/code&gt; flag. &lt;/p&gt;

&lt;p&gt;That's it! Hope you find this post useful. Happy holidays and merry coding! &lt;/p&gt;

</description>
      <category>hardhat</category>
      <category>explorer</category>
      <category>verification</category>
      <category>flatten</category>
    </item>
  </channel>
</rss>
