Skip to content

A Decentralized Library, that allows users to upload files, retrieve files, share files with other users, and remove files from the service

Notifications You must be signed in to change notification settings

taofeek-ob/NestDrive

 
 

Repository files navigation

NestDrive Dapp

Table of contents

Overview

You got hired by a Web3 startup trying to build a novel solution to file sharing and storage.

They would like to build a proof of concept (POC) to pitch to investors. The POC will be a Decentralized Library, that allows users to upload files, retrieve files, share files with other users from the service.

These files could be articles, books or similar. The default permission for uploads shhould be public.

Project Features

  • Upload files.

  • Retrieve files.

  • Share files to other users

Technologies

Stack Usage
Solidity Smart contract
React JS Frontend

Repo Setup

To setup the repo, first fork the TeamResilient NestDrive repo, then clone the forked repository to create a copy on the local machine.

$ git clone https://github.com/pauline-banye/NestDrive.git

Change directory to the cloned repo and set the original NestDrive repository as the "upstream" and your forked repository as the "origin" using gitbash.

$ git remote add upstream https://github.com/TeamResilient/NestDrive.git

Requirements

  • Hardhat
  • Alchemy key
  • Metamask key
  • Etherscan.io API Url
  • Node JS

Setup the Project

*Note:

This project was setup on a windows 10 system using the gitbash terminal. Some of the commands used may not work with the VScode terminal, command prompt or powershell.

The steps involved are outlined below:-

Install Hardhat

The first step involves cloning and installing hardhat.

$ cd NestDrive

$ npm i -D hardhat

$ npm install

$ npm install --save-dev "@nomiclabs/hardhat-waffle" "ethereum-waffle" "chai" "@nomiclabs/hardhat-ethers" "ethers" "web3" "@nomiclabs/hardhat-web3" "@nomiclabs/hardhat-etherscan" "@openzeppelin/contracts" "dotenv"

# If you encounter errors installing the dependencies above, delete the old package-lock.json and run the `npm install --save-dev` command again

Env Setup

Next create a .env file by using the sample.env. Retrieve your information from the relevant sites and input the information where needed in the .env file.

To retrieve your metamask private key.

  • Open your account details by clicking on the three dots on the metamask extension on your chrome browser
  • Click on export private key
  • Verify your password
  • Copy your private key and place it in the .env file

metamask

To retrieve your alchemy key.

  • Login to your account on https://www.alchemy.com/
  • Once youre redirected to your dashboard, click on create app.
  • Fill in the relevant details especially the chain and network
  • Once the app has been created, click on view key.
  • Copy the HTTP and place it in the .env file.

alchemy

To retrieve your etherscan key.

  • Login to etherscan and hover over the dropdown arrow for your profile on the navbar.
  • Click on API keys and add to create a new project (optional step).
  • Once the project has been created, click on the copy button to copy the API key.
  • Paste it in the .env file

etherscan key

Setup Hardhat.config

Below is the setup for the hardhat.config.json

hardhat

Create the SmartContract

  • First write the Smartcontract codes within the contracts folder.
  • The next step involves the compilation, deployment and verification of the contract on the testnet.

Compile

  • To compile the smartcontract before deployment:
$ npx hardhat compile

Deploy

  • To deploy the smartcontract:
$ npx hardhat run scripts/deploy.js --network rinkeby

Verify

  • To verify the smartcontract:
$ npx hardhat verify 0x459eBd3d66cfBfC118e8a20c4F16Fc75B376253d --network rinkeby

Setup the Frontend

  • First run the frontend on your local server to ensure it's fully functional before building for production.

Install Dependencies

  • Setup and install dependencies
$ cd frontend

$ npm install

$ npm install react-scripts@latest

Start Server

  • Start the server on localhost
$ npm run start

Build the Frontend

  • Create an optimized production build, which can be hosted on sites like Heroku, Netlify, Surge etc.
$ npm run build

Testing the Smartcontract

  • Coverage is used to view the percentage of the code required by tests and unittests were implemented to ensure that the code functions as expected

Coverage Test

  • To test the smartcontract, first open a terminal and run the following command:

  • First install Solidity Coverage

  $ npm i solidity-coverage
  • Add require('solidity-coverage') to hardhat.config.json

  • Install Ganache

  $ npm i ganache-cli
  • Run coverage
$ npx hardhat coverage --network localhost

# if you get errors and you want to trace the error in the terminal
$ npx hardhat coverage --network localhost --show-stack-traces

coverage tests

NestDrive Contract Address

Live Link

  • nestdrive.surge.sh

Contributors

This Project was created by the members of TeamResilient during the Blockgames Internship.

teamresilient

Contributing to the project

If you find something worth contributing, please fork the repo, make a pull request and add valid and well-reasoned explanations about your changes or comments.

Before adding a pull request, please note:

  • This is an open source project.
  • Your contributions should be inviting and clear.
  • Any additions should be relevant.
  • New features should be easy to contribute to.

All suggestions are welcome!

README Created by Pauline Banye for TeamResilient

About

A Decentralized Library, that allows users to upload files, retrieve files, share files with other users, and remove files from the service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 80.7%
  • Solidity 8.8%
  • SCSS 6.2%
  • CSS 3.2%
  • Other 1.1%