An ERC-721 NFT minting contract (MineNationsMint) where mints are paid in wETH (an ERC-20 token) instead of native ETH. It supports a whitelist tier with discounted pricing and lower per-wallet limits.
The contract is built on OpenZeppelin 4.x and lives in a single file, Mint.sol.
- Name / symbol:
MineNations/MNT - Max supply: 10,000 tokens
- Payment token: wETH at
0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889 - Metadata:
https://ipfs.io/ipfs/QmcnforHyWMorTv437YMXQ9594TuG7JsfyTaDFSVdLX9Z1/<tokenId>.json
| Tier | Price per token | Max per wallet |
|---|---|---|
| Whitelisted | 0.05 wETH | 2 |
| Public | 0.06 wETH | 5 |
mintItem(uint256 _count, uint256 _amount)- Mints_counttokens to the caller._amountmust equal_count * pricefor the caller's tier, and the caller must have approved the contract to spend at least_amountwETH beforehand. Reverts if_countis 0, the supply cap would be exceeded, or the per-wallet limit would be exceeded.totalSupply()- Returns the number of tokens minted so far.tokenURI(uint256 tokenId)- Returns the IPFS metadata URI for a token.ownWallet(address)- Number of tokens minted by an address.whitelisted(address)- Whether an address is on the whitelist.
addWhitelistUser(address _user)- Adds an address to the whitelist.removeWhitelistUser(address _user)- Removes an address from the whitelist.withdraw()- Transfers the contract's entire wETH balance to the owner.
- The buyer approves the contract to spend wETH:
wETH.approve(contractAddress, amount). - The buyer calls
mintItem(count, amount)withamount = count * price. - The contract pulls
amountwETH viasafeTransferFromand mintscounttokens to the buyer.
- wETH transfers use OpenZeppelin's
SafeERC20, so failed transfers revert. mintItemis protected byReentrancyGuard(nonReentrant), since_safeMintcalls back into the recipient viaonERC721Received.- Owner-only actions are gated by OpenZeppelin's
Ownable.
There is no build toolchain checked into this repository yet. The contract targets Solidity ^0.8.0 and depends on @openzeppelin/contracts (4.x). To compile and test it, set up a project with a tool such as Foundry or Hardhat and install OpenZeppelin:
npm install @openzeppelin/contracts@^4.9.0MIT