Write a minter
This guide's authorization and sale examples use v1. Current v2 still
exposes the token's mintTo(to, quantity), but uses one owner-set minter slot
instead of a minter set: setMinter(address), with 0 disabling minting.
V2 has no admins, lockMinter, pooled mode, or supplied-seed mint path.
The v2 value-facing ABI is mint(uint256) and
mintWithReferral(address,uint256,address,bytes), plus priceOf(address,uint256).
Its FixedPriceSale uses exact payment,
a fixed 5% referral share when an eligible nonzero referrer is supplied, and an
optional external gate such as AllowlistGate.
Custom pricing belongs in a custom minter. See
Surface v2 and the
token API.
A minter is any contract the collection owner authorizes to mint tokens. Every mint goes through one: the token holds no sale logic, so the minter owns price, window, payment, referral, and gating. The canonical FixedPriceMinter covers the common priced drop and the factory wires it automatically; you write your own when a work needs economics the canonical minter does not do (dynamic settlement, ERC20 backing, id draws) or when the collection is pooled, which has no canonical minter.
Authorization
The owner grants (or revokes) a minter explicitly, per address, on the token:
function setMinter(address minter, bool allowed) external; // owner or admin (owner-only on pooled)
function isMinter(address minter) external view returns (bool);setMinter authorizes a minter contract; revoking it withdraws that
authorization (a revoked minter can no longer call mintTo/mintToId, but
tokens it already minted are unaffected). lockMinter freezes the set
permanently.
The token's mint entrypoints
function mintTo(address to, uint256 quantity) external returns (uint256 firstTokenId); // Sequential
function mintToId(address to, uint256 tokenId) external; // PooledBoth are non-payable and revert NotMinter if msg.sender is not authorized.
Which one exists depends on the collection's idMode, fixed at deploy:
- Sequential: call
mintTo. The core assigns ids from its mint-order counter, mintsquantityconsecutive ids, returns the first, and emits oneMintedevent. The sequential form has nomintToId; its absence from the ABI is the guarantee, not a runtime check - Pooled: call
mintToId, supplying the id yourself (tokenId == sourceIdis the intended shape: the minter owns whatever pool or source mapping decides which id mints next; id0is legal). The pooled form has nomintTo
Both v1 entrypoints enforce the supply cap (ExceedsCap) and write a seed per
token. V2 also enforces the mints-ever cap and stores every seed itself.
These mint paths use _mint, so
they do not invoke onERC721Received, and enforce no token-side mint window.
Your minter owns the schedule,
and the artist's control over it is setMinter(minter, false).
Value handling is entirely yours
mintTo and mintToId take no msg.value and do no payment accounting. If
your minter is a paid mint, it is responsible for:
- collecting and validating payment (ETH, an ERC20, a swap route, whatever the form needs), and refunding or escrowing as needed
- honoring the referral share by convention, not by contract guarantee. The
canonical minter pays
referralShareBps(initialized to its 10% cap) out of the price to the referrer; nothing on the token enforces it, so a custom minter sets its own referral policy - paying out (or escrowing) proceeds itself, since the token holds no value and runs no pull-payment ledger
The value-facing shape (IMinter)
The v1 canonical minter presents this value-facing ABI. A custom v1 minter can adopt it for compatible frontends and indexers:
function mint(address to, uint256 quantity, address referrer, bytes calldata data) external payable;
function priceOf(address to, uint256 quantity) external view returns (uint256);to is the recipient and the address any gate evaluates; msg.sender is the
payer, and refunds accrue to the payer. data carries caller-supplied gate
input (a Merkle proof). The canonical minter implements exactly this; a custom
minter that adopts it plugs into the same mint surfaces. Per-minter config
(price, window, gates, payout) is each minter's own surface, not part of
IMinter.
Config authority: borrow it from the collection
The canonical minter has no Ownable of its own. Its setters check the
collection's owner()/isAdmin, so one owner and admin set governs both
contracts and an ownership transfer on the collection invalidates delegated
admin access to the minter's config too. Borrowing authority this way is the recommended pattern
for a custom minter.
Burn semantics differ by id mode
burn(tokenId) on the token is mode-gated:
- Sequential: standard owner-or-approved burn. Burned ids are never reused
- Pooled: only an authorized minter may burn (
NotAuthorizedotherwise). A pooled collection's tokens carry backing, pool membership, or other minter-owned state that a holder-initiated burn would strand. A pooled minter typically wraps its ownredeem()aroundburn, releasing whatever it owes the holder before or as part of the call
A burned pooled id can be minted again via mintToId as a brand new instance:
fresh seed, fresh escrow if the minter tracks any. The prior instance's history
stays readable in emitted events and offchain indexing.
Minimal minter skeleton
An illustrative payment flow; use the canonical minter for production sales.
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.24;
interface ISurfaceMint {
function mintTo(address to, uint256 quantity) external returns (uint256 firstTokenId);
}
interface ISurfaceAuth {
function owner() external view returns (address);
function isAdmin(address account) external view returns (bool);
}
/// @notice Minimal fixed-price sequential minter: takes exact payment, mints
/// through the collection's minter entrypoint, forwards the referrer
/// share by convention, and pays the artist the rest. One instance
/// bound to one collection.
contract SimpleMinter {
uint16 constant REFERRAL_SHARE_BPS = 1_000; // 10%
uint16 constant BPS = 10_000;
address public immutable collection;
uint256 public price;
event PriceSet(uint256 price);
constructor(address collection_, uint256 price_) {
collection = collection_;
price = price_;
}
modifier onlySurfaceAdmin() {
require(
msg.sender == ISurfaceAuth(collection).owner() || ISurfaceAuth(collection).isAdmin(msg.sender),
"not collection owner or admin"
);
_;
}
function setPrice(uint256 price_) external onlySurfaceAdmin {
price = price_;
emit PriceSet(price_);
}
function mint(address to, uint256 quantity, address referrer) external payable returns (uint256 firstTokenId) {
uint256 total = price * quantity;
require(msg.value == total, "wrong payment");
firstTokenId = ISurfaceMint(collection).mintTo(to, quantity);
uint256 referralCut = referrer != address(0) ? (total * REFERRAL_SHARE_BPS) / BPS : 0;
if (referralCut > 0) {
(bool okR,) = referrer.call{value: referralCut}("");
require(okR, "referral payout failed");
}
uint256 artistCut = total - referralCut;
if (artistCut > 0) {
(bool okA,) = ISurfaceAuth(collection).owner().call{value: artistCut}("");
require(okA, "artist payout failed");
}
}
}This skeleton pushes payments during mint: a reverting recipient blocks the mint, and an owner resolved live as zero after renunciation can receive a payment at the zero address. It is not the canonical payout behavior; use a stored nonzero payout recipient and pull accounting for a production minter.
The canonical FixedPriceMinter does the same job with the safer pull-payment
pattern (proceeds accrue and recipients withdraw, so a reverting recipient
cannot block minting), plus a price strategy, a window, a sale ceiling, and
optional allowlist and per-wallet-cap gates. Prefer cloning it over hand-rolling
value handling; write your own only for economics it does not cover. A pooled
minter follows the same shape but calls mintToId(to, sourceId) with an id it
owns the logic for, and typically pairs redeem()/burn with releasing
per-token backing.
After deploying a minter
cast send <COLLECTION_ADDRESS> "setMinter(address,bool)" <MINTER_ADDRESS> true \
--rpc-url https://mainnet.gateway.tenderly.co --account <KEYSTORE_ACCOUNT>See Id modes for the sequential/pooled contract in full, Mint for minting through the canonical minter, and FixedPriceMinter for the reference implementation.