This project consists of two repositories:
- blockchain (Backend) - Handles smart contract deployment and interaction.
- ui (Frontend) - A Svelte-based web interface for users to mint NFTs.
- Connect MetaMask: Users can connect their MetaMask wallet to interact with the blockchain.
- Select Network: Users can switch between Ethereum (Sepolia) and Polygon (Amoy) testnets.
- Mint NFTs: Users enter a metadata URI, specify the number of NFTs, and mint them using the connected wallet.
- Svelte: Frontend framework for the UI.
- Ethers.js: Blockchain interaction.
- MetaMask: Wallet authentication.
- Hardhat: Smart contract deployment.
- Solidity: Smart contract development.
Ensure you have Node.js and npm installed, then run:
npm installPRIVATE_KEY=""
PUBLIC_KEY="your-wallet-address"
BASE_URI="https://your-metadata-uri.com/"
INFURA_PROJECT_ID="your-infura-id"cd blockchain
npx hardhat compile
npx hardhat run scripts/deploy.ts --network sepoliaFor Polygon Amoy:
npx hardhat run scripts/deploy.ts --network amoycd ui
npm run devThe app should now be available at:
http://localhost:8080
- Open MetaMask.
- Switch to Sepolia or Amoy testnet.
- Click "Connect MetaMask" in the DApp.
- Enter a Metadata URI (e.g.,
https://your-metadata-uri.com/1.json). - Specify the Amount of NFTs to mint.
- Click "Mint NFT".
- Confirm the transaction in MetaMask.
The mintNFT function interacts with the smart contract:
const handleMintNFT = async () => {
await mintNFT(
_wallet?.address!,
amount,
metadataURI,
)
};The mint function inside the contract:
function mintNFT(uint256 amount, string memory metadataURI) public {
require(amount > 0, "Must mint at least 1 copy");
uint256 tokenId = nextTokenId;
nextTokenId++;
_mint(msg.sender, tokenId, amount, "");
_setURI(tokenId, metadataURI);
emit NFTMinted(msg.sender, tokenId, amount, metadataURI);
}- Add NFT metadata preview before minting.
- Support more blockchain networks beyond Ethereum and Polygon.
- Enable resale functionality directly on OpenSea.
To properly test, you're going to need test coins from a faucet. You can get test coins from:
Sepolia ETH Faucet: https://sepoliafaucet.com/
Polygon Amoy Faucet: https://www.alchemy.com/faucets/polygon-amoy
Make sure your MetaMask wallet is connected to the correct testnet before requesting funds.
To mint an NFT, you'll need a metadata URL that points to the metadata JSON file containing information about your NFT. You can store your metadata on a decentralized storage provider such as:
ArDrive (Arweave-based storage): https://ardrive.io/
IPFS (via Pinata or NFT.Storage): https://www.pinata.cloud/ or https://nft.storage/
Once you have uploaded your metadata, copy the URL and paste it into the form when minting.
MIT License