This project contains two separate NFT contracts for the assignment:
SoulboundVisitCardERC721.sol- a soulbound ERC-721 student visit card.GameCharacterCollectionERC1155.sol- an ERC-1155 collection of 10 game characters.
- Uses OpenZeppelin
ERC721URIStorageandOwnable. - Owner/admin can mint with
mintVisitCard(address student, string tokenUri). - Each student wallet can receive exactly one visit card.
- Transfers are disabled by overriding
transferFromandsafeTransferFrom. - Approvals are disabled by overriding
approveandsetApprovalForAll. - Metadata is stored off-chain and returned through
tokenURI.
- Uses OpenZeppelin
ERC1155andOwnable. - Supports 10 token IDs:
1through10. - Owner/admin can assign metadata with
setTokenUri. - Owner/admin can mint one token or batch mint with
mintBatch. - Standard ERC-1155 transfer, approval, and batch transfer behavior remains enabled.
- Metadata is stored off-chain and returned through
uri.
Metadata examples are in the metadata directory.
metadata/visit-card.jsoncontains the ERC-721 visit card metadata withimageand attributes such asstudentName,studentID,course, andyear.metadata/character-1.jsonthroughmetadata/character-10.jsoncontain ERC-1155 marketplace-compatible metadata. Each file has a uniqueimageURI and attributes such ascolor,speed,strength, andrarity.
The current metadata files use public HTTPS image URLs for a quick classroom/demo setup. The mint script points token metadata to the raw GitHub URLs under metadata/, so the JSON files become reachable after this repository is pushed. If strict IPFS hosting is required, upload the images and JSON metadata to IPFS and replace the metadata/image values with ipfs://... links.
Install dependencies:
npm installCompile:
npm run compileRun tests:
npm testOn Windows PowerShell, if npx is blocked by execution policy, use:
npx.cmd hardhat testCreate a .env file:
SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_KEY
PRIVATE_KEY=YOUR_PRIVATE_KEYDo not commit .env.
Deploy both contracts:
npx hardhat run scripts/deploy.js --network sepoliaDeploy only the ERC-1155 contract:
npx hardhat run scripts/deploy-erc1155.js --network sepoliaAfter deployment, update the contract addresses in:
scripts/mint.jsscripts/batch-transfer.js
Run:
npx hardhat run scripts/mint.js --network sepoliaThe script:
- Mints one soulbound ERC-721 visit card to the student wallet.
- Sets metadata URIs for all 10 ERC-1155 character IDs.
- Batch mints 10 ERC-1155 NFTs to the owner wallet.
- Batch transfers token IDs
1and2to the student wallet. - Prints transaction hashes for the ERC-721 mint, ERC-1155 URI updates, ERC-1155 batch mint, and ERC-1155 batch transfer.
To use a specific student wallet, set STUDENT_WALLET in scripts/mint.js.
Run:
npx hardhat run scripts/batch-transfer.js --network sepoliaThis demonstrates ERC-1155 batch transfer efficiency by transferring token IDs 1 and 2 in a single transaction.
Add the actual deployed transaction hashes or screenshots after running the scripts on Sepolia:
- ERC-721 visit card mint transaction:
- ERC-1155 batch mint transaction:
- ERC-1155 batch transfer transaction:
- Screenshot/link showing student wallet owns one soulbound visit card:
- Screenshot/link showing student wallet received 1 or 2 ERC-1155 game characters:
Local proof from tests:
npx.cmd hardhat test
8 passing