Mint
This guide uses the v1 factory and minter. For current v2 contracts, use Surface v2, Launcher, and FixedPriceSale. V2 has a single minter slot, exact fixed-price payment, and a separate optional gate. Its creation and mint signatures differ from v1; use the matching ABI.
The token holds no sale logic. Every mint goes through an authorized minter,
and the common case is the FixedPriceMinter
clone the factory wires to a sequential collection at creation. You mint by
calling the minter, not the collection; the minter takes payment and calls
the collection's non-payable mintTo to issue the tokens.
Find the collection's current primaryMinter() first. The SurfaceCreated
event's primaryMinter field records its original binding, which may change
after deploy. Confirm the selected minter is still authorized with
isMinter(address). Collections deployed with a custom minter
(createSurfaceCustom, or any pooled collection) expose whatever mint ABI
that minter defines; the rest of this guide is the canonical minter.
function mint(address to, uint256 quantity, address referrer, bytes calldata data) external payable;
function priceOf(address to, uint256 quantity) external view returns (uint256);tois the recipient and the address any gate evaluates (an allowlist gates the collector, not the payer);msg.senderis the payer, so to mint for another address pass it astoreferrerreceives the referral share (referralShareBps, initialized to its 10% cap) out of the price when nonzero.address(0)directs the full price to the payoutdatacarries caller-supplied input a gate consumes, an ABI-encodedbytes32[]Merkle proof for the allowlist. Gates that read only chain state (the per-wallet cap) need nodata; pass0x
Price resolution
If the minter has no price strategy set (priceStrategy() == address(0)), the
price is price() * quantity and payment must match exactly: any other
msg.value reverts WrongPayment.
If a price strategy is set, the minter calls priceOf(collection, to, quantity)
on it once and requires msg.value >= required; underpayment reverts
Underpayment. Overpayment does not revert. It accrues to the payer as a pull
refund, claimable via withdraw(msg.sender), since a strategy's quote can move
between when a collector reads it and when their transaction lands (for example
a basefee-denominated price).
Read the resolved price ahead of a mint with the minter's priceOf:
cast call <MINTER_ADDRESS> "priceOf(address,uint256)(uint256)" \
0xYourAddress 1 \
--rpc-url https://mainnet.gateway.tenderly.coSale window
mintStart / mintEnd (unix seconds, both optional) live on the minter and
gate mint:
- Before
mintStart: revertsMintNotStarted - At or after
mintEnd(when set): revertsMintEnded
The token carries no mint window and no lifecycle status. Anything wanting the
sale phase reads the minter's mintStart/mintEnd.
Gates
Two optional gates on the canonical minter, AND-composed in the same call, both
evaluating the recipient to:
- Merkle allowlist (
allowlistRootnonzero): pass an ABI-encodedbytes32[]proof indata. The leaf is the OpenZeppelin standard-merkle-tree single-address leaf,keccak256(bytes.concat(keccak256(abi.encode(to)))). A missing or wrong proof revertsNotAllowlisted - Per-wallet cap (
walletCapnonzero):mintedBy[to]plus the requested quantity must not exceed the cap, or the call revertsWalletCapExceeded. The counter increments after a successful mint
Both are live config: setting the root and later clearing it is how a
presale-then-public sale runs on one minter. maxMints is the minter's own
sale ceiling across all buyers (MaxMintsExceeded), separate from the token's
supplyCap.
Supply cap
The token enforces the supply cap on mintTo: ExceedsCap reverts when a mint
would push past supplyCap (0 means uncapped). Sequential collections bound
mints ever. The cap binds every minter, so no grant can exceed it, and
lockSupply freezes it permanently.
cast example
cast send <MINTER_ADDRESS> "mint(address,uint256,address,bytes)" \
0xYourAddress 1 0x0000000000000000000000000000000000000000 0x \
--value 0.02ether \
--rpc-url https://mainnet.gateway.tenderly.co \
--account <KEYSTORE_ACCOUNT>With a referrer, pass their address in the third argument.
viem example
import {createWalletClient, createPublicClient, http} from 'viem';
import {mainnet} from 'viem/chains';
import {fixedPriceMinterAbi} from '@pin/abi';
const MINTER = '<MINTER_ADDRESS>';
const publicClient = createPublicClient({
chain: mainnet,
transport: http('https://mainnet.gateway.tenderly.co'),
});
const walletClient = createWalletClient({
chain: mainnet,
transport: http('https://mainnet.gateway.tenderly.co'),
});
const price = await publicClient.readContract({
address: MINTER,
abi: fixedPriceMinterAbi,
functionName: 'priceOf',
args: [walletClient.account.address, 1n],
});
const hash = await walletClient.writeContract({
address: MINTER,
abi: fixedPriceMinterAbi,
functionName: 'mint',
args: [walletClient.account.address, 1n, referrerAddress, '0x'],
value: price,
});
await publicClient.waitForTransactionReceipt({hash});Reverts to handle
| Error | Where | Cause |
|---|---|---|
ZeroQuantity |
minter | quantity == 0 |
MintNotStarted |
minter | before mintStart |
MintEnded |
minter | at or after mintEnd |
MaxMintsExceeded |
minter | mint would exceed the minter's maxMints |
NotAllowlisted |
minter | allowlist set and the proof does not verify for to |
WalletCapExceeded |
minter | mint would exceed walletCap for to |
WrongPayment |
minter | fixed-price mint, msg.value != price * quantity |
Underpayment |
minter | strategy-priced mint, msg.value < quote |
ExceedsCap |
token | mint would exceed the collection's supplyCap |
After a successful mint, claim any accrued balance (artist proceeds, referral
share, or your own overpayment refund) with withdraw(account) on the minter,
a permissionless trigger that always pays the owed address, never the caller:
cast send <MINTER_ADDRESS> "withdraw(address)" 0xPayeeAddress \
--rpc-url https://mainnet.gateway.tenderly.co --account <KEYSTORE_ACCOUNT>See Write a minter for pooled collections and any collection whose economics (backing, dynamic settlement, id draws) need a custom minter, and FixedPriceMinter for the full generated reference.