FixedPriceMinter
Implementation 0x50941e5fd0B177826AB86419502b221049821Ba3 · view on evm.now · Ethereum mainnet
Deployed per collection as an EIP-1167 clone of the implementation above:
createSurfacewires one automatically andSurfaceCreated.primaryMinterrecords it. A minter clone has no canonical address of its own; substitute your collection's minter address for<MINTER_ADDRESS>in the examples below.
Fixed-price minter for a sequential Surface
collection, deployed as one EIP-1167 clone per collection.
createSurface on the factory clones and
grants one; SurfaceCreated.primaryMinter records the address. The clone stores
the sale config (fixed price or an IPriceStrategy, mint window, payout
recipient, per-clone sale ceiling, Merkle allowlist root, per-recipient cap),
takes payment in mint, and calls the collection's mintTo to issue tokens.
Pooled collections assign ids through their own minter, so this minter is
sequential only.
mint requires exact payment on a fixed price, or msg.value at least the
strategy quote with the excess refunded, and pays a referral share
(referralShareBps, initialized to the 10% cap) to the referrer argument
when nonzero, the rest to payoutRecipient. Proceeds accrue as pull-payment balances withdrawn through
withdraw; no ETH is transferred during a mint, so a reverting recipient does
not block minting. price = 0 is valid config; there is no separate free-mint or
owner-mint entrypoint. An owner mint is done by granting a minter on the
collection, calling mintTo, and revoking.
The minter has no owner. Config setters check the collection's owner()/isAdmin,
so a collection ownership transfer also invalidates delegated admin access to the
minter config.
Concepts
Pricing
With no price strategy set, the required payment is price * quantity and
msg.value must equal it (WrongPayment otherwise). With a strategy set, the
quote can change between read and inclusion, so mint requires msg.value at
least the quote (Underpayment otherwise) and credits the excess back to the
payer as a pull-payment balance. The quote is read from the strategy once and
reused for the settle, so the strategy cannot direct more value than the contract
received. priceOf returns the same resolution as a view.
Gates
Two optional gates, both checked in mint and both evaluating the recipient to,
not the payer:
- Merkle allowlist (
allowlistRootnonzero): the caller passes an ABI-encodedbytes32[]proof indata. The leaf is the OpenZeppelin standard-merkle-tree single-address leaf,keccak256(bytes.concat(keccak256(abi.encode(to)))) - per-recipient cap (
walletCapnonzero):mintedBy[to]plus the requested quantity must not exceed the cap; the counter increments after a successful mint
Both are live config. maxMints is a separate ceiling on this clone's own total
sales, distinct from the collection's supply cap, which bounds every minter.
Pull payments
mint credits the referral share and the payout as internal balances rather than
transferring during the call; withdraw(account) sends a balance out.
payoutRecipient is a concrete stored value, enforced nonzero at both
initialize and setPayoutRecipient, so it is never resolved from the
collection's live owner(); a renounced collection keeps paying it. A balance
credited on this clone stays withdrawable after the collection revokes the
minter.
Minting from a frontend
The two mint entrypoints share the same guarded path (_executeMint
internally), so settlement, gates, and reentrancy protection are identical; only
the caller-facing shape differs.
import {fixedPriceMinterAbi} from '@pin/abi';
const required = await client.readContract({
address: minter, // from SurfaceCreated.primaryMinter
abi: fixedPriceMinterAbi,
functionName: 'priceOf',
args: [collector, 1n],
});
// Common case: mint to the caller, no referrer, no gate data.
await walletClient.writeContract({
address: minter,
abi: fixedPriceMinterAbi,
functionName: 'mint',
args: [1n],
value: required,
});
// Full form: a different recipient, a referrer, or allowlist proof data.
await walletClient.writeContract({
address: minter,
abi: fixedPriceMinterAbi,
functionName: 'mint',
args: [collector, 1n, referrer, '0x'], // data carries a Merkle proof when allowlisted
value: required,
});Write functions
mint(address, uint256, address, bytes)
function mint(address to, uint256 quantity, address referrer, bytes data) external payableAccess: permissionless (payable; window, ceiling, gate, and payment checks apply)
Takes payment and mints quantity tokens to to. to is the recipient and the
address the gates evaluate; msg.sender is the payer, and any strategy
overpayment refund is credited to the payer. referrer, when nonzero, receives
the referral share (referralShareBps); zero directs the full amount to
payoutRecipient. data carries the Merkle proof when an allowlist is set and
is used for nothing else: it never reaches the price strategy, whose quote is a
function of (collection, to, quantity) and chain state only.
Checks, in order: ZeroQuantity for quantity == 0, MintNotStarted before
mintStart, MintEnded at or after a nonzero mintEnd, MaxMintsExceeded past
maxMints, NotAllowlisted on a failing proof, WalletCapExceeded past
walletCap, then the payment check (WrongPayment fixed, Underpayment
strategy). The mintTo call can revert ExceedsCap on the collection's supply
cap. On success, credits the referral and payout balances and emits Sold after
the collection's Minted.
mint(uint256)
function mint(uint256 quantity) external payableAccess: permissionless (payable; window, ceiling, gate, and payment checks apply)
Ergonomic overload for the common case: mints quantity tokens to msg.sender
with no referrer and no gate data, equivalent to
mint(msg.sender, quantity, address(0), ""). Same checks, settlement, and
Sold emission as the four-argument form. Use the four-argument form for a
different recipient, a referrer, or allowlist proof data.
withdraw
function withdraw(address account) externalAccess: permissionless (funds go only to account)
Sends account its owed pull-payment balance. Any caller may invoke it; the
transfer goes to account. Reverts ZeroAccount for the zero address,
NothingToWithdraw for a zero balance, and WithdrawFailed if the transfer
reverts, leaving the balance intact. Emits Withdrawn.
setPrice
function setPrice(uint256 price_) externalAccess: collection owner or admin (onlyCollectionOwnerOrAdmin, else NotAuthorized)
Sets the fixed price per token, used when no price strategy is set. Emits
PriceSet.
setPriceStrategy
function setPriceStrategy(address strategy) externalAccess: collection owner or admin (onlyCollectionOwnerOrAdmin, else NotAuthorized)
Sets the price strategy, or zero to use the fixed price. Reverts NotAContract
for a nonzero address with no code. Emits PriceStrategySet.
setMintWindow
function setMintWindow(uint64 start, uint64 end) externalAccess: collection owner or admin (onlyCollectionOwnerOrAdmin, else NotAuthorized)
Sets the sale window. Reverts BadMintWindow unless end is 0 (open-ended) or
strictly after start. Emits MintWindowSet.
setPayoutRecipient
function setPayoutRecipient(address payoutRecipient_) externalAccess: collection owner or admin (onlyCollectionOwnerOrAdmin, else NotAuthorized)
Sets the stored payout address for future mints. Reverts PayoutRecipientRequired
for the zero address. Balances already credited stay at the address they were
credited to. Emits PayoutRecipientSet.
setMaxMints
function setMaxMints(uint256 maxMints_) externalAccess: collection owner or admin (onlyCollectionOwnerOrAdmin, else NotAuthorized)
Sets this clone's sale ceiling (0 = unlimited), checked against totalMinted.
Distinct from the collection's supply cap. Emits MaxMintsSet.
setAllowlistRoot
function setAllowlistRoot(bytes32 root) externalAccess: collection owner or admin (onlyCollectionOwnerOrAdmin, else NotAuthorized)
Sets the Merkle allowlist root, or zero for no allowlist. Emits
AllowlistRootSet.
setWalletCap
function setWalletCap(uint256 cap) externalAccess: collection owner or admin (onlyCollectionOwnerOrAdmin, else NotAuthorized)
Sets the per-recipient cap (0 = unlimited), checked against mintedBy[to].
Counted per recipient on this clone only. Emits WalletCapSet.
setReferralShareBps
function setReferralShareBps(uint16 bps) externalAccess: collection owner or admin (onlyCollectionOwnerOrAdmin, else NotAuthorized)
Sets the referral share in bps. Reverts ReferralShareAboveCap above
MAX_REFERRAL_SHARE_BPS. Emits ReferralShareSet.
rescueStrayETH
function rescueStrayETH(address to) externalAccess: collection owner or admin (onlyCollectionOwnerOrAdmin, else NotAuthorized)
Sends to the ETH balance above the sum of pull-payment balances. Owed balances
are not swept. Reverts ZeroAccount for the zero address, NoStrayETH when the
surplus is zero, and RescueFailed if the transfer reverts. Emits
StrayETHRescued.
initialize
function initialize(FixedPriceMinterInitParams p) externalAccess: deployer one-shot (initializer, else InvalidInitialization)
Sets the collection binding and the sale config once; the collection binding has
no setter. Reverts CollectionRequired for a zero collection, NotAContract for
a collection or nonzero price strategy with no code, BadMintWindow for a
nonzero mintEnd not after mintStart, and PayoutRecipientRequired for a zero
payout recipient. createSurface calls this in the transaction that clones the
token. The implementation constructor disables initializers, so only a clone is
initialized, once. Emits MinterConfigured.
Read functions
allowlistRoot
function allowlistRoot() external view returns (bytes32)The Merkle allowlist root, or zero for no allowlist.
collection
function collection() external view returns (address)The collection this clone sells for. Set at initialize; no setter.
MAX_REFERRAL_SHARE_BPS
function MAX_REFERRAL_SHARE_BPS() external view returns (uint16)Hard ceiling for the referral share: 1000 bps, 10%. setReferralShareBps
rejects anything above it.
maxMints
function maxMints() external view returns (uint256)This clone's sale ceiling (0 = unlimited), checked against totalMinted.
mintedBy
function mintedBy(address) external view returns (uint256)Tokens minted to a recipient through this clone, the counter behind walletCap.
Incremented after a successful mint.
mintEnd
function mintEnd() external view returns (uint64)Sale window end in unix seconds; 0 means open-ended.
mintStart
function mintStart() external view returns (uint64)Sale window start in unix seconds; 0 means open immediately.
payoutRecipient
function payoutRecipient() external view returns (address)The stored artist payout address. Never zero once set: enforced nonzero at both
initialize and setPayoutRecipient, and never derived from the collection's
live owner(), so a renounced collection keeps paying it.
pendingWithdrawal
function pendingWithdrawal(address account) external view returns (uint256)The pull-payment balance in wei owed to an account, withdrawn with withdraw.
price
function price() external view returns (uint256)The fixed price per token in wei, used when priceStrategy is zero.
priceOf
function priceOf(address to, uint256 quantity) external view returns (uint256)The required payment in wei to mint quantity tokens to to: price * quantity, or the strategy quote when one is set. Takes no gate data, since
pricing is a function of (collection, to, quantity) and chain state only. Does
not check the gates or the window. A strategy quote can change between this read
and inclusion.
priceStrategy
function priceStrategy() external view returns (address)The price strategy contract, or zero when the fixed price applies.
referralShareBps
function referralShareBps() external view returns (uint16)The live referral share in bps. Initialized to MAX_REFERRAL_SHARE_BPS;
applied only when a mint's referrer is nonzero. Not a protocol fee.
saleCap
function saleCap() external view returns (uint256)Alias for maxMints: this clone's own sale ceiling, distinct from the
collection's supplyCap.
totalMinted
function totalMinted() external view returns (uint256)Tokens minted through this clone, the counter behind maxMints.
totalMintedByThisMinter
function totalMintedByThisMinter() external view returns (uint256)Alias for totalMinted, under a name a client reading across multiple minters
can use unambiguously: the count minted through this clone, not the
collection's lifetime count.
walletCap
function walletCap() external view returns (uint256)The per-recipient cap (0 = unlimited), checked against mintedBy.
Events
AllowlistRootSet
event AllowlistRootSet(bytes32 root)Emitted when the allowlist root changes with setAllowlistRoot.
Initialized
event Initialized(uint64 version)OpenZeppelin Initializable event, emitted once when the clone is initialized.
MaxMintsSet
event MaxMintsSet(uint256 maxMints)Emitted when the sale ceiling changes with setMaxMints.
MinterConfigured
event MinterConfigured(address indexed collection, uint256 price, address priceStrategy, uint64 mintStart, uint64 mintEnd, address payoutRecipient, uint256 maxMints, bytes32 allowlistRoot, uint256 walletCap)Emitted at initialize with the collection binding and the opening sale config.
Indexed by collection. Each field has its own update event afterward.
MintWindowSet
event MintWindowSet(uint64 mintStart, uint64 mintEnd)Emitted when the window changes with setMintWindow.
PayoutRecipientSet
event PayoutRecipientSet(address indexed payoutRecipient)Emitted when the payout address changes with setPayoutRecipient. Indexed by
payoutRecipient. Affects future accruals.
PriceSet
event PriceSet(uint256 price)Emitted when the fixed price changes with setPrice.
PriceStrategySet
event PriceStrategySet(address indexed strategy)Emitted when the price strategy changes with setPriceStrategy. Indexed by
strategy.
ReferralPaid
event ReferralPaid(address indexed referrer, uint256 amount)Emitted when a nonzero referral cut is credited. Indexed by referrer, with the
amount in wei.
ReferralShareSet
event ReferralShareSet(uint16 bps)Emitted when the referral share changes with setReferralShareBps.
Sold
event Sold(address indexed payer, address indexed to, address indexed referrer, uint256 quantity, uint256 paid, uint256 firstTokenId)Emitted once per mint call. Indexed by payer (msg.sender), to, and
referrer. paid is the settled price, excluding refunded excess;
firstTokenId is the first id of the minted range, matching the collection's
Minted from the same call. The ABI is the same across every clone, so one
indexer handler covers all of them.
StrayETHRescued
event StrayETHRescued(address indexed to, uint256 amount)Emitted when rescueStrayETH sweeps unowed ETH. Indexed by to, with the
amount in wei.
WalletCapSet
event WalletCapSet(uint256 cap)Emitted when the per-recipient cap changes with setWalletCap.
Withdrawn
event Withdrawn(address indexed account, uint256 amount)Emitted when a pull-payment balance is paid out. Indexed by account, with the
amount in wei.
Errors
BadMintWindow()
initialize or setMintWindow was given a nonzero mintEnd not strictly after
mintStart. Use mintEnd = 0 for open-ended.
CollectionRequired()
initialize was given the zero address as the collection.
InvalidInitialization()
OpenZeppelin Initializable error: initialize was called more than once, or on
the implementation whose initializers are disabled.
MaxMintsExceeded(uint256 maxMints, uint256 attempted)
The call would cross this clone's maxMints ceiling.
MintEnded()
mint was called at or after a nonzero mintEnd.
MintNotStarted()
mint was called before mintStart.
NoStrayETH()
rescueStrayETH found no ETH above the owed balances.
NotAContract(address account)
initialize or setPriceStrategy was given a nonzero address with no code where
a contract is required (the collection, or a price strategy).
NotAllowlisted()
An allowlist root is set and the proof in data does not prove to is on the
list. Pass the recipient's proof as an ABI-encoded bytes32[].
NotAuthorized()
A config setter or rescueStrayETH was called by an address that is neither the
collection's owner nor one of its admins.
NothingToWithdraw()
withdraw was called for an account with a zero balance.
NotInitializing()
OpenZeppelin Initializable error: an onlyInitializing step ran outside an active
initialization.
PayoutRecipientRequired()
initialize or setPayoutRecipient was given the zero address. Both write
points reject zero, so _settle never has to resolve a fallback.
ReentrancyGuardReentrantCall()
OpenZeppelin ReentrancyGuard error: a nonReentrant function was re-entered.
ReferralShareAboveCap(uint16 requested, uint16 cap)
setReferralShareBps was given a share above MAX_REFERRAL_SHARE_BPS.
RescueFailed()
The transfer in rescueStrayETH reverted.
Underpayment(uint256 required, uint256 sent)
A strategy-priced mint sent less than the quote. Excess above the quote is refunded to the payer.
WalletCapExceeded(uint256 cap, uint256 attempted)
The call would push mintedBy[to] past walletCap.
WithdrawFailed()
The transfer in withdraw reverted, for example a recipient that rejects ETH.
The balance is left intact.
WrongPayment(uint256 required, uint256 sent)
A fixed-price mint did not send exactly price * quantity.
ZeroAccount()
withdraw or rescueStrayETH was passed the zero address.
ZeroQuantity()
mint was called with quantity == 0.