// SPDX-License-Identifier: MITpragmasolidity ^0.8.21;structBasicMintConfiguration {
/// @notice Purchase cost per token.uint256 price;
/// @notice UNIX timestamp of mint start.uint64 mintStart;
/// @notice UNIX timestamp of mint end, or zero if open-ended.uint64 mintEnd;
/// @notice Maximum token purchase limit per wallet, or zero if no limit.uint32 maxPerWallet;
/// @notice Maximum tokens mintable per transaction, or zero if no limit.uint32 maxPerTransaction;
/// @notice Maximum tokens mintable by this module, or zero if no limit.uint32 maxForModule;
/// @notice Maximum tokens that can be minted in total, or zero if no max.uint32 maxSupply;
}
Contract Source Code
File 2 of 8: BasicMintModule.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.21;import {IBasicMintModule, IConfigurable} from"create/interfaces/v1/IBasicMintModule.sol";
import {IMintPayout} from"create/interfaces/v1/IMintPayout.sol";
import {IMintContract} from"create/interfaces/v1/IMintContract.sol";
import {BasicMintConfiguration} from"create/interfaces/v1/BasicMintConfiguration.sol";
import {Version} from"create/contracts/v1/Version.sol";
contractBasicMintModuleisIBasicMintModule, Version{
IMintPayout publicimmutable mintPayout;
mapping(address=> BasicMintConfiguration) private _configurations;
mapping(address=>mapping(address=>uint256)) private _mintedByAddress;
mapping(address=>uint256) public mintedByContract;
/// @notice Emitted when quantity is zero.errorInvalidQuantity();
/// @notice Emitted if the collector is minting too many tokens per transaction.errorTooManyTokensPerTransaction();
/// @notice Emitted if the collector is minting too many tokens per wallet.errorTooManyTokensPerCollector();
/// @notice Emitted if the collector is minting more tokens than this module is allowed to mint.errorTooManyTokensForModule();
/// @notice Emitted if the mint has not started yet.errorMintNotStarted();
/// @notice Emitted if the mint has ended.errorMintEnded();
/// @notice Emitted when the value sent is incorrect.errorIncorrectPayment();
/// @notice Emitted when the max supply is reached.errorMaxSupplyReached();
constructor(address _mintPayout) Version(1) {
mintPayout = IMintPayout(_mintPayout);
}
/// @inheritdoc IConfigurablefunctionupdateConfiguration(bytescalldata args) externaloverride{
BasicMintConfiguration memory _config =abi.decode(args, (BasicMintConfiguration));
_configurations[msg.sender] = _config;
emit ConfigurationUpdated(msg.sender, _config);
}
/// @inheritdoc IBasicMintModulefunctionconfiguration(address _contract) externalviewreturns (BasicMintConfiguration memory) {
return _configurations[_contract];
}
/// @inheritdoc IBasicMintModulefunctionmint(address _contract, address _to, address _referrer, uint256 _quantity) externalpayable{
_mint(_contract, _to, _referrer, _quantity);
}
/// @inheritdoc IBasicMintModulefunctionmint_efficient_7e80c46e(address _contract, address _to, address _referrer, uint256 _quantity)
externalpayable{
_mint(_contract, _to, _referrer, _quantity);
}
/// @notice The implementation of the mint function./// @dev This is implemented as an internal function to share the logic between the `mint` and `mint_efficient_7e80c46e` functions./// See the documentation for those functions for information on the parameters.function_mint(address _contract, address _to, address _referrer, uint256 _quantity) internal{
BasicMintConfiguration memory config = _configurations[_contract];
if (_quantity ==0) revert InvalidQuantity();
if (config.maxPerTransaction >0&& _quantity > config.maxPerTransaction) revert TooManyTokensPerTransaction();
if (config.maxPerWallet >0) {
if (_mintedByAddress[_contract][_to] + _quantity > config.maxPerWallet) {
revert TooManyTokensPerCollector();
}
}
if (config.maxForModule >0&& mintedByContract[_contract] + _quantity > config.maxForModule) {
revert TooManyTokensForModule();
}
if (block.timestamp< config.mintStart) revert MintNotStarted();
if (config.mintEnd >0&&block.timestamp> config.mintEnd) revert MintEnded();
uint256 protocolFee = mintPayout.protocolFee();
if (msg.value!= (config.price + protocolFee) * _quantity) revert IncorrectPayment();
if (config.maxSupply >0&& IMintContract(_contract).totalMinted() + _quantity > config.maxSupply) {
revert MaxSupplyReached();
}
_mintedByAddress[_contract][_to] += _quantity;
mintedByContract[_contract] += _quantity;
mintPayout.mintDeposit{value: msg.value}(_contract, msg.sender, _referrer, _quantity);
IMintContract(_contract).mint(_to, _quantity);
}
}
Contract Source Code
File 3 of 8: IBasicMintModule.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.21;import {BasicMintConfiguration} from"create/interfaces/v1/BasicMintConfiguration.sol";
import {IConfigurable} from"create/interfaces/v1/IConfigurable.sol";
interfaceIBasicMintModuleEvents{
/// @notice Emitted when a contract's basic mint configuration is updated./// @param _contract The address of the contract being configured./// @param _config The new configuration.eventConfigurationUpdated(addressindexed _contract, BasicMintConfiguration _config);
}
interfaceIBasicMintModuleisIConfigurable, IBasicMintModuleEvents{
/// @notice Retrieves the basic minting configuration for a contract./// @param _contract The address of the contract./// @return The current minting configuration.functionconfiguration(address _contract) externalviewreturns (BasicMintConfiguration memory);
/// @notice Mints tokens for a NFT contract to a recipient./// @dev Reverts if the mint does not work in the current configuration./// @param _contract The address of the contract to mint for./// @param _to The recipient of the tokens./// @param _referrer The referrer of this mint, or the zero address if none./// @param _quantity The quantity of tokens to mint.functionmint(address _contract, address _to, address _referrer, uint256 _quantity) externalpayable;
/// @notice Mints tokens for a NFT contract to a recipient./// @dev Reverts if the mint does not work in the current configuration./// This function is preferred over `mint` because the four byte signature is 0x00000000 which is cheaper to call./// The implementation is identical to `mint`./// @param _contract The address of the contract to mint for./// @param _to The recipient of the tokens./// @param _referrer The referrer of this mint, or the zero address if none./// @param _quantity The quantity of tokens to mint.functionmint_efficient_7e80c46e(address _contract, address _to, address _referrer, uint256 _quantity)
externalpayable;
}
Contract Source Code
File 4 of 8: IConfigurable.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.21;interfaceIConfigurable{
/// @notice Updates the configuration for the calling contract./// @param data The configuration data.functionupdateConfiguration(bytescalldata data) external;
}
Contract Source Code
File 5 of 8: IMetadataRenderer.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.21;interfaceIMetadataRenderer{
/// @notice Retrieves the token URI for the specified token ID./// @param tokenId The ID of the token./// @return uri The URI of the token.functiontokenURI(uint256 tokenId) externalviewreturns (stringmemory uri);
}
Contract Source Code
File 6 of 8: IMintContract.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.21;import {IMetadataRenderer} from"create/interfaces/v1/IMetadataRenderer.sol";
interfaceIMintContractEvents{
/// @notice Emitted when the royalty is updated.eventRoyaltyUpdated(uint256 bps);
/// @notice Emitted when a new mint module is added.eventModuleAdded(address module);
/// @notice Emitted when a mint module is removed.eventModuleRemoved(address module);
/// @notice Emitted when the metadata renderer is updated.eventMetadataRendererUpdated(address renderer);
}
interfaceIMintContractisIMintContractEvents{
/// @notice Mints tokens using approved mint modules./// @param to The address receiving the minted tokens./// @param quantity The quantity of tokens to mint.functionmint(address to, uint256 quantity) external;
/// @notice Mints tokens, callable only by the contract owner./// @param to The address receiving the minted tokens./// @param quantity The quantity of tokens to mint.functionadminMint(address to, uint256 quantity) external;
/// @notice Retrieves the payout recipient address for this mint contract./// @return recipient address of the payout recipient.functionpayoutRecipient() externalviewreturns (address recipient);
/// @notice Returns the total number of tokens minted./// @return total number of tokens minted.functiontotalMinted() externalviewreturns (uint256 total);
/// @notice Adds a new mint module as an approved minter./// @dev Can only be executed by the owner of the contract./// Must be approved in the MintModuleRegistry./// @param mintModule The contract address of the mint module.functionaddMintModule(address mintModule) external;
/// @notice Removes a mint module as an approved minter./// @dev Can only be executed by the owner of the contract./// @param mintModule The contract address of the mint module.functionremoveMintModule(address mintModule) external;
/// @notice Returns whether a mint module is approved./// @param mintModule The contract address of the mint module./// @return isApproved Whether the mint module is approved.functionisMintModuleApproved(address mintModule) externalviewreturns (bool isApproved);
/// @notice Updates configuration located in an external contract./// @dev Can only be executed by the owner of the contract./// The cardinality of `configurables` and `configData` must be the same./// @param configurables The contract addresses to configure./// @param configData The configuration data for the contracts.functionupdateExternalConfiguration(address[] calldata configurables, bytes[] calldata configData) external;
/// @notice Sets the metadata renderer./// @dev This will not request a metadata refresh. If needed, call `refreshMetadata`./// @param renderer The new metadata renderer.functionsetMetadataRenderer(IMetadataRenderer renderer) external;
/// @notice Returns the metadata renderer for this contract./// @return metadataRenderer The metadata renderer.functionmetadataRenderer() externalreturns (IMetadataRenderer metadataRenderer);
/// @notice Triggers a batch metadata update.functionrefreshMetadata() external;
/// @notice Updates the royalty for this contract./// @dev Can only be called by the contract owner./// Emits a `RoyaltyUpdated` event./// @param bps The new royalty.functionsetRoyalty(uint256 bps) external;
/// @notice Returns the royalty for this contract./// @return bps The royalty.functionroyaltyBps() externalreturns (uint256 bps);
}
Contract Source Code
File 7 of 8: IMintPayout.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.21;interfaceIMintPayoutEvents{
/// @notice Emitted when a deposit has been made./// @param from The depositor's address./// @param to The address receiving the deposit./// @param reason The reason code for the deposit./// @param amount The deposit amount.eventDeposit(addressfrom, address to, bytes4 reason, uint256 amount);
/// @notice Emitted when a withdrawal has been made./// @param from The address withdrawing./// @param to The address receiving the withdrawn funds./// @param amount The withdrawal amount.eventWithdraw(addressfrom, address to, uint256 amount);
/// @notice Emitted during a mint deposit to provide additional context./// @param depositedBy The address of the mint initiator./// @param mintContract The mint contract address this mint deposit refers to./// @param minter The address of the person minting./// @param referrer The address of the referrer, or the zero address for no referrer./// @param creator The address of the contract creator, or the protocol fee recipient if none./// @param creatorPayout The amount being paid to the creator./// @param referralPayout The amount being paid to the referrer./// @param protocolPayout The amount being paid to the protocol./// @param totalAmount The total deposit amount./// @param quantity The number of tokens being minted./// @param protocolFee The per-mint fee for the protocol.eventMintDeposit(address depositedBy,
address mintContract,
address minter,
address referrer,
address creator,
uint256 creatorPayout,
uint256 referralPayout,
uint256 protocolPayout,
uint256 totalAmount,
uint256 quantity,
uint256 protocolFee
);
/// @notice Emitted when the protocol fee is updated./// @param fee The new protocol fee.eventProtocolFeeUpdated(uint256 fee);
}
interfaceIMintPayoutisIMintPayoutEvents{
functionbalanceOf(address owner) externalviewreturns (uint256);
functiontotalSupply() externalviewreturns (uint256);
/// @notice The current protocol fee per-mint.functionprotocolFee() externalviewreturns (uint256 fee);
/// @notice Sets the protocol fee per-mint./// @dev Only callable by the owner./// @param fee The new protocol fee.functionsetProtocolFee(uint256 fee) external;
/// @notice Magic value used to represent the fees belonging to the protocol.functionprotocolFeeRecipientAccount() externalviewreturns (address);
/// @notice Withdraws from the protocol fee balance./// @dev Only callable by the owner./// @param to The address receiving the withdrawn funds./// @param amount The withdrawal amount.functionwithdrawProtocolFee(address to, uint256 amount) external;
/// @notice Deposits ether for a mint./// @dev Ensure that `quantity` is > 0. The `protocolFee` should be per-mint, not the total taken./// Will trigger a `MintDeposit` event, followed by `Deposit` events for:/// creator payout, protocol payout, and referrer payout (if a referrer is specified)./// @param mintContract The mint contract address this mint deposit refers to./// @param minter The address of the minter./// @param referrer The address of the referrer, or the zero address for no referrer./// @param quantity The amount being minted.functionmintDeposit(address mintContract, address minter, address referrer, uint256 quantity) externalpayable;
/// @notice Deposits ether to an address./// @param to The address receiving the deposit./// @param reason The reason code for the deposit.functiondeposit(address to, bytes4 reason) externalpayable;
/// @notice Deposits ether to multiple addresses./// @dev The length of `recipients`, `amounts`, and `reasons` must be the same./// @param recipients List of addresses receiving the deposits./// @param amounts List of deposit amounts./// @param reasons List of reason codes for the deposits.functiondepositBatch(address[] calldata recipients, uint256[] calldata amounts, bytes4[] calldata reasons)
externalpayable;
/// @notice Withdraws ether from the `msg.sender`'s account to a specified address./// @param to The address receiving the withdrawn funds./// @param amount The withdrawal amount.functionwithdraw(address to, uint256 amount) external;
/// @notice Withdraws all ether from the `msg.sender`'s account to a specified address./// @param to The address receiving the withdrawn funds.functionwithdrawAll(address to) external;
}
Contract Source Code
File 8 of 8: Version.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.21;abstractcontractVersion{
/// @notice The version of the contract.uint32publicimmutable contractVersion;
constructor(uint32 _contractVersion) {
contractVersion = _contractVersion;
}
}