Skip to content

cupid20103/minenations-contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

minenations-contract

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.

Overview

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

Pricing and limits

Tier Price per token Max per wallet
Whitelisted 0.05 wETH 2
Public 0.06 wETH 5

Contract API

Public

  • mintItem(uint256 _count, uint256 _amount) - Mints _count tokens to the caller. _amount must equal _count * price for the caller's tier, and the caller must have approved the contract to spend at least _amount wETH beforehand. Reverts if _count is 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.

Owner only

  • 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.

Minting flow

  1. The buyer approves the contract to spend wETH: wETH.approve(contractAddress, amount).
  2. The buyer calls mintItem(count, amount) with amount = count * price.
  3. The contract pulls amount wETH via safeTransferFrom and mints count tokens to the buyer.

Security notes

  • wETH transfers use OpenZeppelin's SafeERC20, so failed transfers revert.
  • mintItem is protected by ReentrancyGuard (nonReentrant), since _safeMint calls back into the recipient via onERC721Received.
  • Owner-only actions are gated by OpenZeppelin's Ownable.

Development

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.0

License

MIT

About

ERC-721 NFT minting smart contract for MineNations, paid in wETH with whitelisted and public mint tiers.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors