<?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: Pranshu Mishra</title>
    <description>The latest articles on DEV Community by Pranshu Mishra (@pranshumishra).</description>
    <link>https://dev.to/pranshumishra</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%2F4121013%2F3ad1114a-2007-42a9-8e94-c7023d146dd4.png</url>
      <title>DEV Community: Pranshu Mishra</title>
      <link>https://dev.to/pranshumishra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pranshumishra"/>
    <language>en</language>
    <item>
      <title>Building a DeFi Staking Platform with Solidity, Foundry, and Next.js on Ethereum Sepolia</title>
      <dc:creator>Pranshu Mishra</dc:creator>
      <pubDate>Fri, 11 Sep 2026 13:32:47 +0000</pubDate>
      <link>https://dev.to/pranshumishra/building-a-defi-staking-platform-with-solidity-foundry-and-nextjs-on-ethereum-sepolia-25g6</link>
      <guid>https://dev.to/pranshumishra/building-a-defi-staking-platform-with-solidity-foundry-and-nextjs-on-ethereum-sepolia-25g6</guid>
      <description>&lt;h1&gt;
  
  
  Building a DeFi Staking Platform with Solidity, Foundry, and Next.js on Ethereum Sepolia
&lt;/h1&gt;

&lt;p&gt;As part of my EtherAuthority Web3 Training, I built a full-stack &lt;strong&gt;DeFi Staking Platform&lt;/strong&gt; to gain practical experience in smart contract development, ERC-20 tokens, blockchain testing, and Web3 frontend integration.&lt;/p&gt;

&lt;p&gt;The project was developed and deployed on the &lt;strong&gt;Ethereum Sepolia testnet&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Objective
&lt;/h2&gt;

&lt;p&gt;The main objective was to build a decentralized staking application where users can connect their wallet, approve and stake ERC-20 tokens, withdraw their staked tokens, and claim rewards generated according to the staking contract's APR.&lt;/p&gt;

&lt;p&gt;The project also gave me hands-on experience with Foundry-based testing and integrating deployed Solidity contracts with a Next.js frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technologies Used
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Solidity&lt;/li&gt;
&lt;li&gt;Foundry&lt;/li&gt;
&lt;li&gt;OpenZeppelin&lt;/li&gt;
&lt;li&gt;Next.js&lt;/li&gt;
&lt;li&gt;TypeScript&lt;/li&gt;
&lt;li&gt;ethers.js&lt;/li&gt;
&lt;li&gt;MetaMask&lt;/li&gt;
&lt;li&gt;Ethereum Sepolia&lt;/li&gt;
&lt;li&gt;Vercel&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Smart Contracts
&lt;/h2&gt;

&lt;p&gt;The project contains three main Solidity contracts.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. StakeToken
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;StakeToken.sol&lt;/code&gt; is an ERC-20 token named &lt;strong&gt;Stake Token (STK)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The contract mints an initial supply of &lt;strong&gt;100,000 STK&lt;/strong&gt; to the deploying account.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. RewardToken
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;RewardToken.sol&lt;/code&gt; is an ERC-20 token named &lt;strong&gt;Reward Token (RWD)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The contract mints an initial supply of &lt;strong&gt;1,000,000 RWD&lt;/strong&gt; to the deploying account.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Staking
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Staking.sol&lt;/code&gt; manages the staking process and reward calculation.&lt;/p&gt;

&lt;p&gt;The main functions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;stake()&lt;/code&gt; — deposits STK into the staking contract.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Withdraw()&lt;/code&gt; — withdraws previously staked STK.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;claimRewards()&lt;/code&gt; — claims accumulated RWD rewards.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;setAPR()&lt;/code&gt; — allows the owner to update the APR.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pause()&lt;/code&gt; / &lt;code&gt;unpause()&lt;/code&gt; — allows the owner to pause and resume staking-related operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The contract also uses OpenZeppelin components such as &lt;code&gt;SafeERC20&lt;/code&gt;, &lt;code&gt;Ownable&lt;/code&gt;, &lt;code&gt;Pausable&lt;/code&gt;, and &lt;code&gt;ReentrancyGuard&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Staking Works
&lt;/h2&gt;

&lt;p&gt;The user first connects their MetaMask wallet to the application.&lt;/p&gt;

&lt;p&gt;Before staking, the user approves the staking contract to spend a selected amount of STK tokens.&lt;/p&gt;

&lt;p&gt;The user can then stake the approved amount.&lt;/p&gt;

&lt;p&gt;The staking contract records the user's staked balance and updates the reward calculation based on the amount staked, the configured APR, and the time elapsed.&lt;/p&gt;

&lt;p&gt;Users can later withdraw their staked tokens or claim their accumulated rewards.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frontend
&lt;/h2&gt;

&lt;p&gt;The frontend was built using &lt;strong&gt;Next.js, TypeScript, and ethers.js&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The application connects to MetaMask through the browser wallet provider and reads blockchain data directly from the deployed contracts.&lt;/p&gt;

&lt;p&gt;The dashboard displays:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;STK wallet balance&lt;/li&gt;
&lt;li&gt;Staked STK&lt;/li&gt;
&lt;li&gt;Pending rewards&lt;/li&gt;
&lt;li&gt;RWD wallet balance&lt;/li&gt;
&lt;li&gt;Current APR&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The application also displays transaction hashes after blockchain transactions so that transactions can be verified on the Sepolia network.&lt;/p&gt;

&lt;h2&gt;
  
  
  Foundry Testing
&lt;/h2&gt;

&lt;p&gt;I used Foundry to test the staking contracts before working with the deployed application.&lt;/p&gt;

&lt;p&gt;The tests cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Constructor token addresses&lt;/li&gt;
&lt;li&gt;Successful staking&lt;/li&gt;
&lt;li&gt;Successful withdrawal&lt;/li&gt;
&lt;li&gt;Zero-amount staking&lt;/li&gt;
&lt;li&gt;Withdrawal greater than the staked balance&lt;/li&gt;
&lt;li&gt;Claiming without rewards&lt;/li&gt;
&lt;li&gt;Reward claiming&lt;/li&gt;
&lt;li&gt;Owner APR updates&lt;/li&gt;
&lt;li&gt;Non-owner APR restrictions&lt;/li&gt;
&lt;li&gt;Contract pause&lt;/li&gt;
&lt;li&gt;Contract unpause&lt;/li&gt;
&lt;li&gt;Invalid zero APR&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These tests helped verify the core contract behavior and important edge cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ethereum Sepolia Deployment
&lt;/h2&gt;

&lt;p&gt;The contracts were deployed on Ethereum Sepolia.&lt;/p&gt;

&lt;h3&gt;
  
  
  Contract Addresses
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Staking Contract&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0x1873eca046e15b910da2ea9ad50fce9fd695b0a7&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stake Token (STK)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0xaba6599a21cf3fa1bcf4038eb225f829bdb17cf5&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reward Token (RWD)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0x36070c3ad6efa8045d87e97e627dcb0eced73279&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenges
&lt;/h2&gt;

&lt;p&gt;One of the practical challenges was ensuring that the frontend correctly interacted with the deployed contracts and displayed the connected wallet's blockchain data.&lt;/p&gt;

&lt;p&gt;I also worked through the complete approval → staking → withdrawal/reward flow and verified transactions on the Sepolia testnet.&lt;/p&gt;

&lt;p&gt;Another important part of the project was testing contract behavior with Foundry before using the deployed contracts through the frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Live Project
&lt;/h2&gt;

&lt;p&gt;The frontend is deployed and available online, and the complete source code is available on GitHub.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub Repository:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/PranshuMishra2004/DeFi-Staking-Platform" rel="noopener noreferrer"&gt;https://github.com/PranshuMishra2004/DeFi-Staking-Platform&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Live Project:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://de-fi-staking-platform-opal.vercel.app/" rel="noopener noreferrer"&gt;https://de-fi-staking-platform-opal.vercel.app/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Building this DeFi Staking Platform gave me practical experience beyond writing individual Solidity contracts. I worked through the complete process of developing smart contracts, testing them with Foundry, deploying them to Ethereum Sepolia, and connecting them to a Web3 frontend using MetaMask and ethers.js.&lt;/p&gt;

&lt;p&gt;This project has strengthened my understanding of Solidity, ERC-20 token interactions, staking mechanisms, smart contract testing, and decentralized application development.&lt;/p&gt;

&lt;h1&gt;
  
  
  EtherAuthority #SecureChain.ai #EtherAuthorityInternship #Web3 #Blockchain #Ethereum #Solidity #SmartContracts #DeFi #Foundry #Web3Development
&lt;/h1&gt;

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