// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)pragmasolidity ^0.8.0;/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/libraryCounters{
structCounter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add// this feature: see https://github.com/ethereum/solidity/issues/4637uint256 _value; // default: 0
}
functioncurrent(Counter storage counter) internalviewreturns (uint256) {
return counter._value;
}
functionincrement(Counter storage counter) internal{
unchecked {
counter._value +=1;
}
}
functiondecrement(Counter storage counter) internal{
uint256 value = counter._value;
require(value >0, "Counter: decrement overflow");
unchecked {
counter._value = value -1;
}
}
functionreset(Counter storage counter) internal{
counter._value =0;
}
}
Contract Source Code
File 4 of 16: ERC165.sol
Contract Source Code
File 5 of 16: ERC721.sol
Contract Source Code
File 6 of 16: ERC721Enumerable.sol
Contract Source Code
File 7 of 16: IERC165.sol
Contract Source Code
File 8 of 16: IERC721.sol
Contract Source Code
File 9 of 16: IERC721Enumerable.sol
Contract Source Code
File 10 of 16: IERC721Metadata.sol
Contract Source Code
File 11 of 16: IERC721Receiver.sol
Contract Source Code
File 12 of 16: JustMallards.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.4;// https://ipfs.io/ipfs/QmWnEYforuPHFroBvzQvjjGbwGQMpg4KAmt28HosKPncuq/import"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol";
import"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
import"https://github.com/1001-digital/erc721-extensions/blob/main/contracts/RandomlyAssigned.sol";
import"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
contractJustMallardsisERC721, Ownable, RandomlyAssigned{
usingStringsforuint256;
uint256public currentSupply =0;
boolpublic paused =true;
stringprivate _baseURIextended;
stringpublic baseURI;
mapping (address=>uint) public ownerMallardCount;
constructor () ERC721("Just Mallards", "MALLARDS") RandomlyAssigned(10000,1) {
}
functiondevMint(uint256 _mintAmount) publicpayableonlyOwner{
require( tokenCount() +1<= totalSupply(), "Maximum supply has been reached!");
require( availableTokenCount() -1>=0, "You can't mint more than available token count!");
require( tx.origin==msg.sender, "Looks like you're minting through custom contract!");
for (uint256 a =1; a <= _mintAmount; a++) {
uint256 id = nextToken();
_safeMint(msg.sender, id);
currentSupply++;
}
}
functionmint () publicpayable{
require ( paused ==false, "Contract is paused!");
require( tokenCount() +1<= totalSupply(), "Maximum supply has been reached!");
require( availableTokenCount() -1>=0, "You can't mint more than available token count!");
require( tx.origin==msg.sender, "Looks like you're minting through custom contract!");
if (msg.sender!= owner()) {
require (balanceOf(msg.sender) ==0, "Only 1 mint per wallet! -Quack!");
}
if (msg.sender!= owner()) {
require( msg.value>=0.000ether);
}
uint256 id = nextToken();
ownerMallardCount[msg.sender]++;
_safeMint(msg.sender, id);
currentSupply++;
}
functiontokenURI(uint256 tokenId) publicviewvirtualoverridereturns (stringmemory) {
require(
_exists(tokenId),
"ERC721Metadata: URI query nonexistant token"
);
stringmemory currentBaseURI = _baseURI();
returnbytes(currentBaseURI).length>0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), ".json"))
: "";
}
functionsetBaseURI(stringmemory baseURI_) externalonlyOwner() {
baseURI = baseURI_;
}
function_baseURI() internalviewvirtualoverridereturns (stringmemory) {
return baseURI;
}
functionsetPaused(bool _paused) publiconlyOwner{
paused = _paused;
}
functionwithdraw() publiconlyOwner{
uint balance =address(this).balance;
payable(msg.sender).transfer(balance);
}
}