A simple Ethereum-based NFT Marketplace that allows users to mint NFTs, list them on the marketplace, and buy/sell NFTs with other Ethereum accounts.
Live Deployed Site
Running this project locally
- Node.js >= v14.0
- Metamask Wallet installed in the browser
- Clone this repository and
cdinto the folder:
git clone https://github.com/thryec/nft-marketplace.git cd nft-marketplace npm install
- Change into the hardhat folder and install the required dependencies:
cd hardhat npm install
- Check that contracts properly compile:
npx hardhat compile
- Run tests on both contracts:
npx hardhat test
- To deploy and run contracts locally:
npx hardhat run scripts/run.js
- Start the frontend on localhost:
cd .. cd client npm install npm run dev
To deploy and run contracts on testnet:
Set up Environment Variables:
- Create a
.envfile directly under the Hardhat folder using
- Define your Rinkeby API endpoint and wallet private key in the
.envfile. This is what your
.envfile should look like:
STAGING_RINKEBY_URL=YOUR_RINKEBY_URL_HERE PROD_INFURA_KEY=YOUR_MAINNET_URL_HERE PRIVATE_KEY=YOUR_METAMASK_WALLET_PRIVATE_KEY
hardhat.config.js, ensure the variable names for your API URL and private key correspond to those in
- Create a
Deploy contracts to the Rinkeby testnet:
npx hardhat run scripts/deploy.js --network rinkeby
- This will return you the address of the deployed NFT and Marketplace contracts on Rinkeby printed in the console
- Replace these addresses in the
config.jsfile that is found in the root of the repository
Start the frontend on localhost using the same method outlined above.
Note: Due to some challenges faced when deploying this Next.JS app, if you wish to deploy the frontend of this project, please refer to https://github.com/thryec/marketplace-frontend. It contains the same functionality as the files in this repository, but refactored into React for ease of deployment.
Users are able to mint individual digital files from their local machine by uploading it with a name, description and price. These piece will be stored on IPFS using the Infura IPFS endpoint, and displayed in the Marketplace for other users to view and purchase.
Any item that an account mints will be automatically listed and can be bought by another account at the pre-determined price.
- View Gallery
Users can view all the NFTs they have minted, bought, and sold on the platform.
A percentage of the sale price will go to the marketplace contract whenever a sale occurs. The amount of royalties is declared in the constructor when deploying the marketplace contract.
Public Wallet Address for Certification