A fully functional NFT Marketplace smart contract deployed on ethereum testnet (Sepolia). This application allows users, to mint, list and trade nfts.
Deployed Contract address: 0x078101bC59Ec52547C0a5E270b1695e84151861C
EtherScan link: https://sepolia.etherscan.io/address/0x078101bC59Ec52547C0a5E270b1695e84151861C
- Ethereum
- Solidity
- Hardhat
- Ethers.js
- IPFS
- NFT Minting
- NFT Listing for sale
- NFT Purchase
- NFT Sales
- In your terminal (Integrated Visual Studio Code terminal or command prompt), run:
git clone https://github.com/Bishopukpai/Nft-smartcontract.git
- Navigate into the cloned repository with:
cd Nft-smartcontract
- Then install all dependencies with:
npm install
There two ways you can interact with this smart contract. You can either redeploy the smart contract or you can use the deployed contract's address.
Option A: Use the already deployed contract's address
- Go to https://remix.ethereum.org/ in your browser
- Navigate into the file explorer tab
- Then select
contractsfolder - Then click on the create new file icon
- Then enter the name of the file (NftMarketplace.sol) and save the file
- Copy the code from the
Nftmarketplace.solinside thecontractsfolder in the cloned repository and paste it inside theNftMarketplace.solfile in the Remix IDE - Now you can compile and start testing the smart contract
-
Under the
ENVIRONMENTSSection, select Browser Extension -> Inject Provider -> Metamask -
In the
At Addressinput box, paste the deployed contract address [0x078101bC59Ec52547C0a5E270b1695e84151861C] -
Click on the Compile button at the top of your Remix IDE's workspace
-
Or if this does not work, Go to the compiler tab in your Remix IDE, Select the right compiler version (the same version with your smart contract). Then Click on the
Compile NftMarketplace.solbutton. This will compile your smart contract and you will be able to click on theAt Addressbutton to deploy your smart contract. Check under the deployed Contract section in the Deploy and run tab and you will see your deployed contract -
You can start interacting with the smart contract.
Option B: Reploy the smart contract to get another deployed address
If you like you can redeploy the smart contract to another address. To do this:
- Create a
.envfile in the root of the cloned repository. Your.envfile should be in the level with yourhardhat.config.jsfile
- Then add these variables in it
- PRIVATE_KEY=your_sepolia_wallet_private_key
- INFURA_PROJECT_ID=your_infura_project_id.
Note: Do not Use real wallet private key, to avoid spending real ethers. Also do not share your private key with the public by pushing the .env file with other codes to Github. Always add your .env file in the gitignore file
- Deploy the smart contract by running
npx hardhat run scripts/deploy.js --network Sepolia. And your smart contract will be deployed. - Follow the steps in option A, but replace the ddeployed Address with yours. Now you can start Interacting with the smart contract.
Minting NFTs
-
Locate the createToken() function under the deployed smart contract section

-
Enter a random string as the tokenURI and then the token price in wei (preferrably 10000000000000000 wei)
-
Then set the transaction value to be 15000000000000000( Ensure that you have 0.0015 Eth in your Sepolia wallet)

-
Click on
transact. This will create the NFT token and place in the market for sale. You can see the newly created NFT token, by calling thefetchItemsListedfunction
Selling NFTs To sell your NFT:
- Locate the
createMarketSalefunction - Enter 1 as the tokenId
- Click on transact and the nft gets sold. You will get a confirmation of this transaction in your meta mask wallet.

