<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Building a DeFi Staking Platform with Solidity, Foundry, and Next.js on Ethereum Sepolia]]></title><description><![CDATA[Building a DeFi Staking Platform with Solidity, Foundry, and Next.js on Ethereum Sepolia
As part of my EtherAuthority Web3 Training, I built a full-stack DeFi S]]></description><link>https://ethereum-development.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1593680282896/kNC7E8IR4.png</url><title>Building a DeFi Staking Platform with Solidity, Foundry, and Next.js on Ethereum Sepolia</title><link>https://ethereum-development.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 22:00:27 GMT</lastBuildDate><atom:link href="https://ethereum-development.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Building a DeFi Staking Platform with Solidity, Foundry, and Next.js on Ethereum Sepolia]]></title><description><![CDATA[As part of my EtherAuthority Web3 Training, I built a full-stack DeFi Staking Platform to gain practical experience in smart contract development, ERC-20 tokens, blockchain testing, and Web3 frontend ]]></description><link>https://ethereum-development.hashnode.dev/defi-staking-platform-solidity-foundry-nextjs</link><guid isPermaLink="true">https://ethereum-development.hashnode.dev/defi-staking-platform-solidity-foundry-nextjs</guid><category><![CDATA[Web3]]></category><category><![CDATA[ethereum smart contracts]]></category><category><![CDATA[etherium sepolia]]></category><category><![CDATA[ERC20]]></category><category><![CDATA[defi]]></category><dc:creator><![CDATA[pranshu952876]]></dc:creator><pubDate>Fri, 11 Sep 2026 13:13:32 GMT</pubDate><content:encoded><![CDATA[<p>As part of my EtherAuthority Web3 Training, I built a full-stack <strong>DeFi Staking Platform</strong> to gain practical experience in smart contract development, ERC-20 tokens, blockchain testing, and Web3 frontend integration.</p>
<p>The project was developed and deployed on the <strong>Ethereum Sepolia testnet</strong>.</p>
<h2>Project Objective</h2>
<p>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.</p>
<p>The project also gave me hands-on experience with Foundry-based testing and integrating deployed Solidity contracts with a Next.js frontend.</p>
<h2>Technologies Used</h2>
<ul>
<li>Solidity</li>
<li>Foundry</li>
<li>OpenZeppelin</li>
<li>Next.js</li>
<li>TypeScript</li>
<li>ethers.js</li>
<li>MetaMask</li>
<li>Ethereum Sepolia</li>
<li>Vercel</li>
</ul>
<h2>Smart Contracts</h2>
<p>The project contains three main Solidity contracts.</p>
<h3>1. StakeToken</h3>
<p><code>StakeToken.sol</code> is an ERC-20 token named <strong>Stake Token (STK)</strong>.</p>
<p>The contract mints an initial supply of <strong>100,000 STK</strong> to the deploying account.</p>
<h3>2. RewardToken</h3>
<p><code>RewardToken.sol</code> is an ERC-20 token named <strong>Reward Token (RWD)</strong>.</p>
<p>The contract mints an initial supply of <strong>1,000,000 RWD</strong> to the deploying account.</p>
<h3>3. Staking</h3>
<p><code>Staking.sol</code> manages the staking process and reward calculation.</p>
<p>The main functions include:</p>
<ul>
<li><code>stake()</code> — deposits STK into the staking contract.</li>
<li><code>Withdraw()</code> — withdraws previously staked STK.</li>
<li><code>claimRewards()</code> — claims accumulated RWD rewards.</li>
<li><code>setAPR()</code> — allows the owner to update the APR.</li>
<li><code>pause()</code> / <code>unpause()</code> — allows the owner to pause and resume staking-related operations.</li>
</ul>
<p>The contract also uses OpenZeppelin components such as <code>SafeERC20</code>, <code>Ownable</code>, <code>Pausable</code>, and <code>ReentrancyGuard</code>.</p>
<h2>How Staking Works</h2>
<p>The user first connects their MetaMask wallet to the application.</p>
<p>Before staking, the user approves the staking contract to spend a selected amount of STK tokens.</p>
<p>The user can then stake the approved amount.</p>
<p>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.</p>
<p>Users can later withdraw their staked tokens or claim their accumulated rewards.</p>
<h2>Frontend</h2>
<p>The frontend was built using <strong>Next.js, TypeScript, and ethers.js</strong>.</p>
<p>The application connects to MetaMask through the browser wallet provider and reads blockchain data directly from the deployed contracts.</p>
<p>The dashboard displays:</p>
<ul>
<li>STK wallet balance</li>
<li>Staked STK</li>
<li>Pending rewards</li>
<li>RWD wallet balance</li>
<li>Current APR</li>
</ul>
<p>The application also displays transaction hashes after blockchain transactions so that transactions can be verified on the Sepolia network.</p>
<h2>Foundry Testing</h2>
<p>I used Foundry to test the staking contracts before working with the deployed application.</p>
<p>The tests cover:</p>
<ul>
<li>Constructor token addresses</li>
<li>Successful staking</li>
<li>Successful withdrawal</li>
<li>Zero-amount staking</li>
<li>Withdrawal greater than the staked balance</li>
<li>Claiming without rewards</li>
<li>Reward claiming</li>
<li>Owner APR updates</li>
<li>Non-owner APR restrictions</li>
<li>Contract pause</li>
<li>Contract unpause</li>
<li>Invalid zero APR</li>
</ul>
<p>These tests helped verify the core contract behavior and important edge cases.</p>
<h2>Ethereum Sepolia Deployment</h2>
<p>The contracts were deployed on Ethereum Sepolia.</p>
<h3>Contract Addresses</h3>
<p><strong>Staking Contract</strong></p>
<p><code>0x1873eca046e15b910da2ea9ad50fce9fd695b0a7</code></p>
<p><strong>Stake Token (STK)</strong></p>
<p><code>0xaba6599a21cf3fa1bcf4038eb225f829bdb17cf5</code></p>
<p><strong>Reward Token (RWD)</strong></p>
<p><code>0x36070c3ad6efa8045d87e97e627dcb0eced73279</code></p>
<h2>Challenges</h2>
<p>One of the practical challenges was ensuring that the frontend correctly interacted with the deployed contracts and displayed the connected wallet's blockchain data.</p>
<p>I also worked through the complete approval → staking → withdrawal/reward flow and verified transactions on the Sepolia testnet.</p>
<p>Another important part of the project was testing contract behavior with Foundry before using the deployed contracts through the frontend.</p>
<h2>Live Project</h2>
<p>The frontend is deployed and available online, and the complete source code is available on GitHub.</p>
<p><strong>GitHub Repository:</strong>
<a href="https://github.com/PranshuMishra2004/DeFi-Staking-Platform">https://github.com/PranshuMishra2004/DeFi-Staking-Platform</a></p>
<p><strong>Live Project:</strong>
<a href="https://de-fi-staking-platform-opal.vercel.app/">https://de-fi-staking-platform-opal.vercel.app/</a></p>
<h2>Conclusion</h2>
<p>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.</p>
<p>This project has strengthened my understanding of Solidity, ERC-20 token interactions, staking mechanisms, smart contract testing, and decentralized application development.</p>
<p>#EtherAuthority #SecureChain.ai #EtherAuthorityInternship #Web3 #Blockchain #Ethereum #Solidity #SmartContracts #DeFi #Foundry #Web3Development</p>
]]></content:encoded></item></channel></rss>