<?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: dkirva</title>
    <description>The latest articles on DEV Community by dkirva (@dkirva).</description>
    <link>https://dev.to/dkirva</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4249091%2F31d23b32-cc6a-48b0-96c1-afc6431c1192.png</url>
      <title>DEV Community: dkirva</title>
      <link>https://dev.to/dkirva</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dkirva"/>
    <language>en</language>
    <item>
      <title>5 Critical Smart Contract Checks Before Mainnet Deployment (Solidity &amp; Foundry)</title>
      <dc:creator>dkirva</dc:creator>
      <pubDate>Tue, 17 Nov 2026 07:01:08 +0000</pubDate>
      <link>https://dev.to/dkirva/5-critical-smart-contract-checks-before-mainnet-deployment-solidity-foundry-3jp6</link>
      <guid>https://dev.to/dkirva/5-critical-smart-contract-checks-before-mainnet-deployment-solidity-foundry-3jp6</guid>
      <description>&lt;p&gt;During high-volatility market swings—like the recent geopolitical shocks pushing $BTC and $ETH through heavy liquidation cascades—DeFi protocols face extreme on-chain stress. Even minor logic assumptions in Solidity contracts can lead to critical fund loss.&lt;/p&gt;

&lt;p&gt;Before pushing any smart contract to mainnet or submitting code for an external audit, run through these 5 essential security checks:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. ERC-4626 First-Depositor Share Inflation
&lt;/h3&gt;

&lt;p&gt;If your vault calculates shares using raw &lt;code&gt;totalAssets() / totalSupply()&lt;/code&gt;, an attacker can deposit &lt;code&gt;1 wei&lt;/code&gt;, donate tokens directly to the vault, and manipulate the share price to round subsequent deposits down to zero.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fix:&lt;/strong&gt; Implement OpenZeppelin's virtual shares/assets offset or mint dead shares on initialization.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Read-Only Reentrancy on View Functions
&lt;/h3&gt;

&lt;p&gt;Adding &lt;code&gt;nonReentrant&lt;/code&gt; to &lt;code&gt;deposit()&lt;/code&gt; and &lt;code&gt;withdraw()&lt;/code&gt; is not enough if an external protocol reads your vault's share price (&lt;code&gt;getPricePerFullShare()&lt;/code&gt;) mid-execution while balances are temporarily out of sync.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fix:&lt;/strong&gt; Ensure state updates happen strictly before external calls (Checks-Effects-Interactions) or lock view getters during active state transitions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Stale Chainlink Oracle Data &amp;amp; L2 Sequencer Uptime
&lt;/h3&gt;

&lt;p&gt;Calling &lt;code&gt;latestRoundData()&lt;/code&gt; without validation exposes your lending or perp protocol to stale prices during network congestion.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fix:&lt;/strong&gt; Always verify &lt;code&gt;updatedAt &amp;gt; 0&lt;/code&gt;, enforce a strict heartbeat threshold (&lt;code&gt;block.timestamp - updatedAt &amp;lt;= MAX_DELAY&lt;/code&gt;), and check the L2 Sequencer Uptime Feed on Arbitrum/Optimism/Base.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Non-Standard ERC-20 Edge Cases
&lt;/h3&gt;

&lt;p&gt;Not every token behaves like standard OpenZeppelin ERC-20:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fee-on-transfer tokens:&lt;/strong&gt; Always measure &lt;code&gt;balanceAfter - balanceBefore&lt;/code&gt; instead of trusting the input &lt;code&gt;amount&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Missing return booleans (e.g., USDT):&lt;/strong&gt; Always use &lt;code&gt;SafeERC20&lt;/code&gt; (&lt;code&gt;safeTransfer&lt;/code&gt;, &lt;code&gt;safeTransferFrom&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Stateful Invariant Fuzzing Over Unit Tests
&lt;/h3&gt;

&lt;p&gt;Unit tests only check paths you already thought of. Stateful invariant testing in &lt;strong&gt;Foundry&lt;/strong&gt; throws thousands of randomized multi-actor sequences at your protocol to verify that core solvency rules never break.&lt;/p&gt;




&lt;h3&gt;
  
  
  Need a Complete Pre-Audit Workflow?
&lt;/h3&gt;

&lt;p&gt;To streamline pre-deployment reviews, I compiled a &lt;strong&gt;45-Point Smart Contract Pre-Audit Checklist&lt;/strong&gt; alongside a ready-to-use &lt;strong&gt;Foundry Vault Invariant &amp;amp; Solvency Test Template (&lt;code&gt;VaultInvariant.t.sol&lt;/code&gt;)&lt;/strong&gt; using ghost variables.&lt;/p&gt;

&lt;p&gt;You can grab the full kit here:&lt;br&gt;
👉 &lt;strong&gt;&lt;a href="https://framer.website" rel="noopener noreferrer"&gt;ZeroCentPlus Smart Contract Pre-Audit &amp;amp; Foundry Security Kit ($29)&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>solidity</category>
      <category>web3</category>
      <category>blockchain</category>
      <category>security</category>
    </item>
  </channel>
</rss>
