Skip to content

shubhamprajapati241/lendhub

Repository files navigation

Table of Contents

Get FREE Sepolia ETH for testing the App

Test Tokens on Sepolia

Introduction

LendHub is a comprehensive DeFi Lending & Borrowing decentralized application (DApp) operating on Ethereum's Sepolia Testnet. The platform facilitates lending and borrowing of various crypto assets, while offering opportunities to earn passive income as interest on deposited funds.

This fully on-chain DeFi app allows users to effortlessly deposit their coins (ETH) or tokens into the smart contract, and receive rewards based on the amount of tokens they supply. In addition, LendHub enables users to borrow tokens, making it a versatile and user-friendly platform for all crypto enthusiasts.

Technology Stack

  • Built on Ethereum Blockchain
  • Solidity
  • Javascript
  • Typescript
  • Chainlink Price Oracles
  • Openzeppelin (ERC20 Tokens, Ownable, Reentrancy Guards)
  • Hardhat
  • Etherjs
  • Metamask
  • Infura Web3API
  • Next JS
  • Tailwind CSS
  • HTML
  • Slither, Mythril, Echidna

Project Layout

Top Level folders

  1. /components - contains the front-end application
  2. /context - contains the front-end application wrapper javascript
  3. /contracts - contains the solidity contract
  4. /scripts - deployment scripts
  5. /pages - Next Js Main rendering pages and components
  6. /tests - contains tests for the solidity contracts

Important Files

  1. package.json - node modules to be installed, etc.
  2. hardhat.config.js - solidity version and run information, deployment network configuration
  3. addresses.js - addresses exported for use use with hardhat local installed contracts
  4. .env - To store Infura/Alchemy API keys and your private key

Using & Testing LendHub on Sepolia

  1. Metamask : Install Metamask wallet extension on your browser ( Chrome recommended ) - The App will prompt you to install one if it is not.

    Click to Download and install Metamask on your browser

  2. Add Sepolia Testnet to MetaMask

    To add the Sepolia testnet to MetaMask, click the network button at the top of your wallet and click “Add Network”

    Under the Networks, at the bottom of the page, click “Add a network manually”

    Add network configuration details along with the following information

    Network name : Sepolia test network
    New RPC URL : https://sepolia.infura.io/v3/
    Chain ID : 11155111
    Currency symbol : SepoliaETH
    Block explorer URL : https://sepolia.etherscan.io
    

    See image below for reference

    image

  3. Get Some Sepolia ETH from the Faucets below for testing the App

  1. If you need DAI, LINK & USDC tokens for testing email our admin

  2. Using/Testing the App

image

Cloning and Deploying the Dapp on Sepolia Testnet

  1. Clone this repo :
git clone https://github.com/shubhamprajapati241/lendhub.git
  1. Go to the root directory and install all node packages
cd lendhub
npm install
  1. Infura API key Follow this article to get Infura API key

    Select Sepolia testnet and copy the url

    image

  2. Get Your Metamask wallet private key : https://support.metamask.io/hc/en-us/articles/360015289632

  3. Create a new .env file in the root directory

    Paste the Infura Sepolia API key and your metmask accounts private key into .env file

    env

  4. Deploy the Dapp on Sepolia Testnet

npx hardhat run scripts/deploy-sepolia.js --network sepolia
  1. Add the sepolia deploy addresses into address.js file

addresses-sepolia

  1. Start NextJs Node Server
npm run dev

Bootsrapping & running this project on your localhost using Hardhat

Following steps show to get this project on to your machine and bring it up:

  1. Metamask : Install Metamask wallet extension on your browser ( Chrome recommended ) - The App will prompt you to install one if it is not.

    Click to Download and install Metamask on your browser

  2. Clone this repo :

git clone https://github.com/shubhamprajapati241/lendhub.git
  1. Go to the root directory and install dependent node packages
cd lendhub
npm install
  1. Compile, Test and Run the hardhat node
 npx hardhat compile
 npx hardhat test
 npx hardhat node
  1. Deploy on the Hardhat localhost
npx hardhat run scripts/deploy.js --network localhost
  1. Add the localhost deploy addresses into address.js file

addresses

  1. Start the NextJs Node Server. Open http://localhost:3000 to view it in your browser.
npm run dev
  1. To run hardhat tests to verify the working of Dapp, run the script below
npx hardhat test