FixedPriceSale
Implementation 0xd97E71DAB49fb20F9b5d12DE3A49ce95fdfD086E · view on evm.now · Ethereum mainnet
Deployed per sale as an EIP-1167 clone of the implementation above through the sale CloneFactory;
launchwires one to each new collection andLaunched.salerecords it. A sale has no canonical address of its own; substitute your sale address for<SALE_ADDRESS>in the examples below.
The v2 sale primitive: one EIP-1167 clone per sale through the sale
CloneFactory, bound to one
Surface (v2) collection at initialize.
It holds this sale's rules and money and nothing about the artwork. Every
mint pays exactly price * quantity; proceeds accrue as pull balances.
Config authority is borrowed from the collection's owner. Before the owner
renounces, every setting is changeable; after, the sale is frozen and
payouts keep flowing. A client that reads a collection's minter() can tell a
canonical sale from a bespoke minter with supportsInterface on the IMinter
interface id and version().
Concepts
Two mint paths
mint(quantity) mints to the caller, pays the referral share to the sale's
fixed defaultReferrer (copied from the launcher at launch) and sends no gate
data. mintWithReferral(to, quantity, referrer, data) is the full path: any
recipient, an explicit referrer, and gate data. Zero, the sale itself, and
the collection address all keep the whole payment for the payout recipient.
The collector pays the same price on both; only the split changes.
The checks, in order
- not closed (
SaleClosed) - inside the window (
MintNotStarted,MintEnded) totalMinted + quantity <= maxMintswhen set (MaxMintsExceeded)- the gate's
checkreturns true when a gate is set (GateRejected) mintedBy[to] + quantity <= walletCapwhen set (WalletCapExceeded)msg.value == price * quantity(WrongPayment)- a contract recipient answers
onERC721Receivedfor every actual id about to be minted, before any exists (ReceiverRejected) - the collection's
mintTo totalMintedandmintedBy[to]grow on every mint, capped or not- settle:
REFERRAL_SHARE_BPS(500, 5%) to an eligible nonzero referrer, the rest topayoutRecipient, both as pull balances
The sale normalizes its own address and the collection address to a zero
referrer before gate checks and settlement. Quantity zero reaches the
collection's ZeroQuantity check if earlier sale checks pass. Receiver
callbacks come from the sale with the payer as operator, zero as sender,
and empty data; they are pre-mint checks, not post-mint notifications.
Referral share
A constant 5%, with no setter. It pays the referrer supplied to the mint. An artist's own site can pass the payout recipient as referrer, so that account receives both shares; anyone can name themselves when minting straight from the contract. It is a host reward, not a protocol fee. The sale and collection addresses cannot earn a referral: those inputs are treated as zero, avoiding an unwithdrawable referral credit. A 0.1 ETH mint credits 0.005 ETH to an eligible referrer and 0.095 ETH to payout; with no eligible referrer all 0.1 ETH accrues to payout. Rounding is downward in wei.
Write functions
mint
function mint(uint256 quantity) external payableAccess: permissionless (the mint checks above)
Mints quantity tokens to the caller with defaultReferrer as referrer and
empty gate data. An AllowlistGate rejects that empty data with GateRejected;
a custom gate decides whether to accept it. Payable; nonReentrant. Emits Sold and, for a nonzero referral amount,
ReferralPaid.
mintWithReferral
function mintWithReferral(address to, uint256 quantity, address referrer, bytes data) external payableAccess: permissionless (the mint checks above)
Mints quantity tokens to to. to is both the recipient and the address
the gate and wallet cap evaluate. referrer receives the referral share
when nonzero and neither the sale nor collection address. data goes to the
gate and nothing else (for
AllowlistGate, an abi-encoded
bytes32[] proof). Payable; nonReentrant.
withdraw
function withdraw(address account) externalAccess: permissionless (funds go only to account)
Sends account its whole owed balance. Reverts ZeroAccount,
NothingToWithdraw, or WithdrawFailed when the transfer fails (the balance
is kept). Emits Withdrawn.
withdrawTo
function withdrawTo(address to) externalAccess: permissionless (the caller's own balance only)
Sends the caller's owed balance to to. Same reverts as withdraw.
setPrice
function setPrice(uint256 price_) externalAccess: owner-only (the collection's owner, borrowed; NotAuthorized)
Sets the price per token in wei. Emits PriceSet.
setMintWindow
function setMintWindow(uint64 start, uint64 end) externalAccess: owner-only (the collection's owner, borrowed; NotAuthorized)
Sets the window. 0 start opens now, 0 end is open-ended; an end at or
before a start reverts BadMintWindow. Emits MintWindowSet.
setMaxMints
function setMaxMints(uint256 maxMints_) externalAccess: owner-only (the collection's owner, borrowed; NotAuthorized)
Sets this sale's ceiling; 0 is unlimited. Emits MaxMintsSet.
setWalletCap
function setWalletCap(uint256 walletCap_) externalAccess: owner-only (the collection's owner, borrowed; NotAuthorized)
Sets the per-recipient cap; 0 is unlimited. Counts every earlier mint.
Emits WalletCapSet.
setPayoutRecipient
function setPayoutRecipient(address payoutRecipient_) externalAccess: owner-only (the collection's owner, borrowed; NotAuthorized)
Sets where the artist share accrues. Rejects zero
(PayoutRecipientRequired). Balances already accrued stay with the old
recipient. Emits PayoutRecipientSet.
setGate
function setGate(address gate_) externalAccess: owner-only (the collection's owner, borrowed; NotAuthorized)
Sets the gate; 0 removes it. A nonzero address without code reverts
NotAContract. Emits GateSet.
close
function close() externalAccess: owner-only (the collection's owner, borrowed; NotAuthorized)
One-way: no mint succeeds afterwards. Another sale needs a new clone and the
collection's setMinter. Emits Closed.
initialize
function initialize(address collection_, uint256 price_, uint64 mintStart_, uint64 mintEnd_, uint256 maxMints_, uint256 walletCap_, address payoutRecipient_, address gate_, address defaultReferrer_) externalAccess: deployer one-shot (initializer, else InvalidInitialization); the collection already names this clone as its minter, or the caller is the collection's owner (NotAuthorized)
Binds the sale to a collection with its price, window, ceiling, wallet cap,
payout recipient, gate and default referrer. Reverts CollectionRequired,
NotAContract (collection or gate without code), PayoutRecipientRequired
and BadMintWindow. Through the factory the caller is the factory, so only
the first authority path applies: grant the predicted address
(predictCreate or predict on the sale factory, both namespaced to the
caller) as minter first, as the launcher does. Emits PriceSet, MintWindowSet,
MaxMintsSet, WalletCapSet, PayoutRecipientSet and GateSet, so the
sale's full initial config is in its logs.
Read functions
closed
function closed() external view returns (bool)Whether close was called.
collection
function collection() external view returns (address)The collection this sale mints.
defaultReferrer
function defaultReferrer() external view returns (address)The referrer mint(quantity) pays. Fixed at initialize; may be zero.
gate
function gate() external view returns (address)The gate consulted before each mint, or zero.
maxMints
function maxMints() external view returns (uint256)This sale's ceiling; 0 is unlimited.
mintedBy
function mintedBy(address) external view returns (uint256)Tokens minted to an address through this sale, counted on every mint.
mintEnd
function mintEnd() external view returns (uint64)Window end in unix seconds; 0 is open-ended.
mintStart
function mintStart() external view returns (uint64)Window start in unix seconds; 0 is open now.
payoutRecipient
function payoutRecipient() external view returns (address)Where the artist share accrues. Never zero.
pendingWithdrawal
function pendingWithdrawal(address account) external view returns (uint256)The owed balance of an address.
price
function price() external view returns (uint256)Price per token in wei.
priceOf
function priceOf(address, uint256 quantity) external view returns (uint256)price * quantity. Does not evaluate the gate or the window.
REFERRAL_SHARE_BPS
function REFERRAL_SHARE_BPS() external view returns (uint16)The referral share, 500 (5%).
supportsInterface
function supportsInterface(bytes4 interfaceId) external pure returns (bool)True for ERC-165 and the IMinter interface id.
totalMinted
function totalMinted() external view returns (uint256)Tokens minted through this sale.
version
function version() external view returns (uint256)2, the implementation lineage marker.
walletCap
function walletCap() external view returns (uint256)The per-recipient cap; 0 is unlimited.
Events
Closed
event Closed()The sale was closed for good.
GateSet
event GateSet(address indexed gate)The gate changed, including at initialize.
Initialized
event Initialized(uint64 version)Standard OpenZeppelin Initializable event, emitted once by initialize.
MaxMintsSet
event MaxMintsSet(uint256 maxMints)The ceiling changed, including at initialize.
MintWindowSet
event MintWindowSet(uint64 mintStart, uint64 mintEnd)The window changed, including at initialize.
PayoutRecipientSet
event PayoutRecipientSet(address indexed payoutRecipient)The payout recipient changed, including at initialize.
PriceSet
event PriceSet(uint256 price)The price changed, including at initialize.
ReferralPaid
event ReferralPaid(address indexed referrer, uint256 amount)A nonzero referral amount accrued to a referrer.
Sold
event Sold(address indexed payer, address indexed to, address indexed referrer, uint256 quantity, uint256 paid, uint256 firstTokenId)One per successful mint: payer, recipient, normalized referrer, quantity, exact payment and first token id. A supplied sale or collection address is recorded as the zero referrer.
WalletCapSet
event WalletCapSet(uint256 walletCap)The wallet cap changed, including at initialize.
Withdrawn
event Withdrawn(address indexed account, address indexed to, uint256 amount)An owed balance was paid out: the account it was owed to, where it went, and the amount.
Errors
BadMintWindow()
A window end at or before its start.
CollectionRequired()
initialize was given a zero collection.
GateRejected()
The gate's check returned false.
InvalidInitialization()
Standard OpenZeppelin Initializable error: initialize on an initialized
clone or on the implementation.
MaxMintsExceeded(uint256 maxMints, uint256 attempted)
The mint would pass this sale's ceiling.
MintEnded()
At or after mintEnd.
MintNotStarted()
Before mintStart.
NotAContract(address account)
A collection or gate address without code.
NotAuthorized()
A setter from someone other than the collection's owner, or an initialize that neither authority path allows.
NothingToWithdraw()
The account has no owed balance.
NotInitializing()
Standard OpenZeppelin Initializable error, unreachable in normal use.
PayoutRecipientRequired()
A zero payout recipient.
ReceiverRejected(address to)
A contract recipient reverted or did not return the ERC721 receiver selector for an actual id about to be minted. Each id is checked before minting.
ReentrancyGuardReentrantCall()
Standard OpenZeppelin ReentrancyGuard error: a reentrant call into a mint or withdrawal.
SaleClosed()
The sale is closed.
WalletCapExceeded(uint256 cap, uint256 attempted)
The mint would pass the recipient's wallet cap.
WithdrawFailed()
The ETH transfer to the recipient failed; the balance is kept.
WrongPayment(uint256 required, uint256 sent)
msg.value is not exactly price * quantity.
ZeroAccount()
A withdrawal to the zero address.