<?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: Sanskar Singh</title>
    <description>The latest articles on DEV Community by Sanskar Singh (@sanskar_singh_js).</description>
    <link>https://dev.to/sanskar_singh_js</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%2F1975287%2Fd258b163-fd6f-47ff-a934-19b67ef2c0f9.jpg</url>
      <title>DEV Community: Sanskar Singh</title>
      <link>https://dev.to/sanskar_singh_js</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sanskar_singh_js"/>
    <language>en</language>
    <item>
      <title>What ERC-20 and OpenZeppelin Solve for You!</title>
      <dc:creator>Sanskar Singh</dc:creator>
      <pubDate>Wed, 05 Feb 2025 17:22:00 +0000</pubDate>
      <link>https://dev.to/sanskar_singh_js/what-erc-20-and-openzeppelin-solve-for-you-2661</link>
      <guid>https://dev.to/sanskar_singh_js/what-erc-20-and-openzeppelin-solve-for-you-2661</guid>
      <description>&lt;p&gt;What ERC-20 and OpenZeppelin Solve for You!&lt;/p&gt;

&lt;p&gt;While exploring how to build my own custom tokens, I discovered ERC-20, and it completely changed my perspective.&lt;/p&gt;

&lt;p&gt;First, What Is a Custom Token?&lt;br&gt;
A custom token should have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Name, Symbol, and an Owner&lt;/li&gt;
&lt;li&gt;The Owner can mint tokens for themselves&lt;/li&gt;
&lt;li&gt;The Owner can also mint tokens for others&lt;/li&gt;
&lt;li&gt;Tokens can be transferred between users&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are the basic functions every custom token needs. I even tried writing one myself—around 50–60 lines of Solidity code. (Check it out here: &lt;a href="https://gist.github.com/ThakurSanskarSingh/c69179832907208fb9053e8dd6d57e28" rel="noopener noreferrer"&gt;customToken.sol&lt;/a&gt;&lt;br&gt;
But Here’s the Problem…&lt;br&gt;
If everyone writes their custom tokens differently, how will wallets recognize and support them?&lt;/p&gt;

&lt;p&gt;This is where ERC-20 comes in. It provides a standard structure that ensures tokens are compatible with wallets, exchanges, and dApps. ERC-20 defines a set of rules for building tokens so they can interact seamlessly within the Ethereum ecosystem.&lt;/p&gt;

&lt;p&gt;However… It’s Still a Lot of Work&lt;br&gt;
Even with ERC-20, you still need to write a lot of code.&lt;/p&gt;

&lt;p&gt;What if there are bugs? (Trust me, that’s almost guaranteed.)&lt;br&gt;
What about the security of my contract?&lt;br&gt;
Enter OpenZeppelin&lt;br&gt;
OpenZeppelin offers secure, audited ERC-20 contracts that you can simply extend and customize to fit your needs.&lt;/p&gt;

&lt;p&gt;✅ Less Code, More Security&lt;br&gt;
✅ Community-Tested and Audited&lt;br&gt;
✅ Reduced Risk of Vulnerabilities&lt;/p&gt;

&lt;p&gt;Here’s how easy it is to create tokens with OpenZeppelin: &lt;a href="https://gist.github.com/ThakurSanskarSingh/e90f7cee8a422ad99defc1c3a4afa906" rel="noopener noreferrer"&gt;openzippelin.sol&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What’s Next?&lt;br&gt;
I’m now diving into other standards like ERC-721 (for NFTs) and IERC. I’ll definitely share more updates soon!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The $150 Million DAO Heist: The Hack That Split Ethereum in Two</title>
      <dc:creator>Sanskar Singh</dc:creator>
      <pubDate>Fri, 30 Aug 2024 06:39:41 +0000</pubDate>
      <link>https://dev.to/sanskar_singh_js/the-150-million-dao-heist-the-hack-that-split-ethereum-in-two-1879</link>
      <guid>https://dev.to/sanskar_singh_js/the-150-million-dao-heist-the-hack-that-split-ethereum-in-two-1879</guid>
      <description>&lt;p&gt;While I was learning blockchain basics, I got to know about very interesting and shocking incident that took place in 2017.This was about multi-million-dollar heist related to Ethereum, which led to the split between &lt;strong&gt;Ethereum (ETH)&lt;/strong&gt; and &lt;strong&gt;Ethereum Classic (ETC)&lt;/strong&gt;. This event is one of the most significant moments in blockchain history, often referred to as &lt;strong&gt;"The DAO Hack."&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What was DAO
&lt;/h2&gt;

&lt;p&gt;The DAO(Decentralized Autonomous Organization) was launched on April 2016 after raising &lt;strong&gt;$150 million in Ether&lt;/strong&gt;, making it one of the largest crowdfunding campaigns at that time. The DAO was designed to allow participants to invest in projects by voting on proposals. &lt;/p&gt;

&lt;h2&gt;
  
  
  Smart Contract Flaw
&lt;/h2&gt;

&lt;p&gt;The DAO’s smart contract had a vulnerability in its code, specifically a &lt;strong&gt;“recursive call”&lt;/strong&gt; issue. This allowed an attacker to repeatedly withdraw funds from the DAO before the contract could update its balance, effectively draining the funds.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hack
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;On June 17, 2016,&lt;/strong&gt; an unknown attacker exploited this vulnerability and managed to drain approximately 3.6 million Ether, which was worth around $50 million at the time. &lt;br&gt;
The stolen Ether became stuck in a child DAO-a subdivision of the parent DAO-it gave the community a time window to decide on a response.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Choice for the Community
&lt;/h2&gt;

&lt;p&gt;The Ethereum community was in dilemma. It could decide either to put up with this hack and let the attacker enjoy the Ether he hacked, thereby following the &lt;strong&gt;"code is law"&lt;/strong&gt; argument, or interfere with it to restore such funds to their rightful owners.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hard Fork
&lt;/h2&gt;

&lt;p&gt;The Ethereum community, after much debate, decided to implement a hard fork. This hard fork rewound the blockchain back to a point before the attack, effectively returning the stolen Ether to the DAO participants. This was done in a move to protect the integrity of the network and not allow an attacker to profit through theft.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Split
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Ethereum (ETH):&lt;/strong&gt; In regards to the hard fork, the majority in the Ethereum community voted for it; the resulting consequences are what form the Ethereum blockchain today. This continued as Ethereum (ETH), where the &lt;strong&gt;history of the DAO hack was removed from its block.&lt;/strong&gt; Just like nothing happened.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ethereum Classic (ETC):&lt;/strong&gt; A minority within the community felt that the blockchain should be immutable, meaning &lt;strong&gt;history regarding the hack shouldn't be touched&lt;/strong&gt;. This group opted to continue on the original blockchain, now called Ethereum Classic (ETC). They retained most of the principles of &lt;strong&gt;"code is law,"&lt;/strong&gt; in that flawed code also shouldn't be changed retroactively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Significance
&lt;/h2&gt;

&lt;p&gt;The DAO hack and the later split between Ethereum and Ethereum Classic cast light on a very serious &lt;strong&gt;philosophical divide&lt;/strong&gt; within the blockchain community. It brought up questions as to what to make of immutability, what exactly the role of developers was supposed to be in the governance of blockchain networks, and how to handle critical vulnerabilities in decentralized systems.&lt;/p&gt;

&lt;p&gt;This is a very critical chapter in the records of blockchain technology, which underlines both the potential and the risks in a decentralized system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/The_DAO" rel="noopener noreferrer"&gt;Wikepedia&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.coindesk.com/consensus-magazine/2023/05/09/coindesk-turns-10-how-the-dao-hack-changed-ethereum-and-crypto/" rel="noopener noreferrer"&gt;Coindesk&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blockchain</category>
      <category>ethereum</category>
      <category>cryptocurrency</category>
      <category>bitcoin</category>
    </item>
    <item>
      <title>No need of Try-Catch!! Javascript introduced new safe assignment operator✌</title>
      <dc:creator>Sanskar Singh</dc:creator>
      <pubDate>Sun, 25 Aug 2024 06:25:33 +0000</pubDate>
      <link>https://dev.to/sanskar_singh_js/no-need-of-try-catch-javascript-introduced-new-safe-assignment-operator-bko</link>
      <guid>https://dev.to/sanskar_singh_js/no-need-of-try-catch-javascript-introduced-new-safe-assignment-operator-bko</guid>
      <description>&lt;p&gt;If you are a javascript developer then you definitely know about &lt;code&gt;try-catch&lt;/code&gt; block which is used to deal with errors. But now you can use new Safe Assignment operator proposal &lt;code&gt;(?=)&lt;/code&gt;&lt;br&gt;
&lt;code&gt;try-catch&lt;/code&gt; blocks lead to nested code making it harder to read and maintain. &lt;br&gt;
&lt;code&gt;?=&lt;/code&gt; operator reduces nesting and it gives result of function into &lt;a href="https://www.techtarget.com/whatis/definition/tuple#:~:text=In%20mathematics%2C%20a%20tuple%20is,square%20brackets%20or%20angle%20brackets." rel="noopener noreferrer"&gt;tuple&lt;/a&gt;. &lt;br&gt;
If an error occurs, it returns &lt;code&gt;[error,null]&lt;/code&gt;otherwise it returns &lt;code&gt;[null, result]&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example-
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function fetchData() {
     const [error, response] ?= await fetch("https://api.example.com/data");
     if (error) return handleError(error);
     return response;
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Better Error Handling
&lt;/h2&gt;

&lt;p&gt;Placing the error first in the &lt;code&gt;[error, data]&lt;/code&gt; &lt;code&gt;?=&lt;/code&gt; structure ensures that errors are handled before processing data, reducing the risk of ignoring errors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [error, data] ?= await fetch("https://api.example.com");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Inspired from Rust
&lt;/h2&gt;

&lt;p&gt;The pattern of &lt;code&gt;?=&lt;/code&gt; is inspired from Rust which have more structured error handling. &lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The Safe Assignment Operator &lt;code&gt;(?=)&lt;/code&gt; is a game-changer for JavaScript error handling, promising to reduce the need for clunky &lt;code&gt;try-catch&lt;/code&gt; blocks and make your code cleaner and more secure.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>news</category>
    </item>
  </channel>
</rss>
