- A user puts an item for sale, the ownership of the item will be transferred from the creator to the marketplace.
- A user purchases an item, the purchase price will be transferred from the buyer to the seller and the item will be transferred from the marketplace to the buyer.
- The marketplace owner will be able to set a listing fee. This fee will be taken from the seller and transferred to the contract owner upon completion of any sale, enabling the owner of the marketplace to earn recurring revenue from any sale transacted in the marketplace.
- NFT Contract - This contract allows users to mint unique digital assets.
- Marketplace Contract - This contract allows users to put their digital assets for sale on an open market.
- This project was inspired by this documentation: https://dev.to/edge-and-node/building-scalable-full-stack-apps-on-ethereum-with-polygon-2cfb
- Web application framework - Next.js
- Solidity development environment - Hardhat
- File Storage - IPFS
- Ethereum Web Client Library - Ethers.js
- Node.js installed on your machine
- Metamask wallet extension installed as a browser extension
"Polygon is a protocol and a framework for building and connecting Ethereum-compatible blockchain networks. Aggregating scalable solutions on Ethereum supporting a multi-chain Ethereum ecosystem."
To run this project locally, follow these steps.
- Clone the project locally, change into the directory, and install the dependencies:
git clone https://github.com/Margotte83/Kryptopixel-marketplace.git
cd Kryptopixel-marketplace
# install using NPM or Yarn
npm install
# or
yarn
- Start the local Hardhat node
npx hardhat node
- With the network running, deploy the contracts to the local network in a separate terminal window
npx hardhat run scripts/deploy.js --network localhost
- Start the app
npm run dev
To deploy to Polygon test or main networks, update the configurations located in hardhat.config.js to use a private key and, optionally, deploy to a private RPC like Infura.
require("@nomiclabs/hardhat-waffle");
const fs = require('fs');
const privateKey = fs.readFileSync(".secret").toString().trim() || "";
// infuraId is optional if you are using Infura RPC
const infuraId = fs.readFileSync(".infuraid").toString().trim() || "";
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 1337
},
mumbai: {
// Infura
// url: `https://polygon-mumbai.infura.io/v3/${infuraId}`
url: "https://matic-mumbai.chainstacklabs.com",
accounts: [privateKey]
},
matic: {
// Infura
// url: `https://polygon-mainnet.infura.io/v3/${infuraId}`,
url: "https://rpc-mainnet.maticvigil.com",
accounts: [privateKey]
}
},
solidity: {
version: "0.8.4",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
};
If using Infura, update .infuraid with your Infura project ID.
π¨ Be sure to never commit any private keys to Git. To be extra safe, consider storing these values in temporary environment variables when working with wallets that contain real tokens. To omit from Git, add .secret to your .gitignore file.
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, a sample script that deploys that contract, and an example of a task implementation, which simply lists the available accounts.
npx hardhat accounts
npx hardhat compile
npx hardhat clean
npx hardhat test
npx hardhat node
node scripts/sample-script.js
npx hardhat help