Last active
June 12, 2022 18:46
-
-
Save cryptonomicon46/400a291db606bf63aee8e59ce5f0fc76 to your computer and use it in GitHub Desktop.
This will allow you to mint multiple copies of a single tokenID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mintSingle(uint256 _id, uint256 _amount) | |
external | |
payable | |
mintTimedTransitions() | |
atMintStage(MintStage.MintLive){ | |
if (msg.sender == address(0)) revert InvalidAddress(); | |
require(_amount<= maxMintAmount && balanceOf(msg.sender,_id) <= maxMintAmount,"There's a limit to minting per address"); | |
// require(msg.sender != owner && msg.sender != beneficiary && msg.sender != devAddress,"Owner, beneficiary and devs cannot bid on this auction"); | |
uint256 _idx; | |
_idx = _idToidx[_id]; | |
uint256 price; | |
uint256 royaltyFees; | |
uint256 ownerPayment; | |
uint256 nftReserves; | |
price = nftInfo[_idx].price; | |
nftReserves = nftInfo[_idx].reserves; | |
require( nftReserves >= _amount,"ERC1155: Sorry, this NFT's sold out!"); | |
require(price.mul(_amount) <= msg.value,"ERC1155: You don't have enough funds."); | |
//Update NFT Reserves | |
_updateReserves(_idx,_amount); | |
//Mint to the calling account address | |
_mint(msg.sender,_id,_amount,""); //Will update the user balances and enumerations | |
//Calculate and Pay Royalty Fee to owner/platform | |
royaltyFees = (msg.value*_royaltyFee)/100; | |
//Owner withdraws the balance funds | |
ownerPayment = msg.value-royaltyFees; | |
//Using the pendingWithdrawal method | |
pendingWithdrawal[devAddress] = pendingWithdrawal[devAddress]+ royaltyFees; | |
pendingWithdrawal[beneficiary] = pendingWithdrawal[beneficiary] +ownerPayment; | |
} | |
function _updateReserves(uint256 _idx,uint256 amount) internal { | |
if (nftInfo[_idx].reserves < amount) revert ErrorNFTReserves(); | |
nftInfo[_idx].reserves -= amount; | |
emit NFTReservesUpdated(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment