Skip to content

Built a NFT market place in which one can list any digital file, and buy from other creators. Deployed on Polygon Mumbai Testnet

Notifications You must be signed in to change notification settings

somesh-banerjee/Metaverse-Market

Repository files navigation

Metaverse Market for ERC721

The projects creates a simple NFT Marketplace using Nextjs and Solidity which is deployed on Polygon Matic Mumbai Testnet.

Techs used:

  • Nextjs: For building the interface for Marketplace.
  • Solidity: For designing of NFT and Market Smart Contract.
  • IPFS: To store metadata of the NFT
  • Hardhat: To compile and deploy the Solidity contracts.
  • TailWind: For basic styling of the pages.

Project Setup

  1. Clone the repository
git clone 
  1. Install the dependencies
npm install
  1. Create two file and write the respective content of the file:

    • .secret: The private key of your crypto account from which you will deploy the contracts
    • .alchemy_apiKey: API key for your project in Alchemy
  2. Start the local server

npm run dev

Running the local chain using Hardhat

  1. Open two terminals and run
npx hardhat node

This will create 20 accounts with 10000 ETH. The first account will be used for most callings. 2. Run the following to deploy the smart contract in the local chain

npx hardhat run scripts/deploy.js --network localhost

Components

Here is a in brief explanantion of all the functions and dependencies used and their purpose in each component.

Solidity Contracts

There are two contracts one for NFT and another for the Market.

  1. NFT.sol
contract NFT is ERC721URIStorage {
    //Declaring Counter to count tokens in order and assign them token id
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;
    // To store Market contract address
    address contractAddress;

    //Assigning Market address in constructor
    constructor(address marketplaceAddress) ERC721("Somcoin", "SOM") {
        contractAddress = marketplaceAddress;
    }

    //CreateToken fn for minting token; only takes 1 para because rest are defined in contract
    function createToken(string memory tokenURI) public returns (uint) {
        //Increasing the counter and storing it as token id
        //Calling _mint() from ERC72.sol to Mint the token id and assigning msg.sender as seller.
        //setTokenURI from erc721uristorage.sol to set URi for token with given ID
        // Giving all permission to Market contract by calling setApprovalForAll().
        //Returning the Token id
    }
}
  1. Market.sol

About

Built a NFT market place in which one can list any digital file, and buy from other creators. Deployed on Polygon Mumbai Testnet

Resources

Stars

Watchers

Forks