SurfaceV2

Implementation 0x9E90a7dbE576f23d909B81d90ff939b5041930e4 · view on evm.now · Ethereum mainnet

The v2 token, deployed per artist as an EIP-1167 clone of the implementation above through the token CloneFactory, usually by the Launcher. A collection has no canonical address of its own; substitute your collection address for <COLLECTION_ADDRESS> in the examples below. This is a separate deployment from Surface; the two coexist and neither depends on the other.

The v2 token primitive: an ERC721 collection deployed per artist as an EIP-1167 clone through the token CloneFactory, usually by the Launcher. Token ids equal mint order (1, 2, 3, ...) and are never reused. The collection stores one mint-time seed per token; no function is payable. Forced ETH has no withdrawal path on this token.

One minter slot mints. The owner sets the renderer, the minter, the supply cap, the EIP-2981 royalty and the name. There are no lock bits: renouncing ownership is the only permanence mechanism, and after it no setter can succeed. Sales and gates borrow authority by reading owner(), so a renounce freezes them too while payouts keep flowing.

Concepts

One minter

minter is a single address. Only it can call mintTo. The FixedPriceSale the launcher wires is the usual minter; a bespoke minter (custom economics) or the owner's own wallet (an airdrop: setMinter(owner), mintTo, setMinter(sale)) works the same way. Two concurrent minters need a small router contract that is the minter and fans out to its own callers.

Renounce is the lock

Every setter is onlyOwner. renounceOwnership sets the owner to zero, after which the renderer, minter, supply cap, royalty and name are fixed for good. transferOwnership is single-step and rejects the zero address. Once the owner is zero, any sale or gate that borrows the collection's authority is frozen as well.

Seed

Each token's seed is keccak256(abi.encode(block.prevrandao, collection, tokenId)), stored at mint. It excludes the recipient so a minter cannot grind wallets for a favorable seed, and stays readable after a burn. See the injection convention.

Write functions

mintTo

solidity
function mintTo(address to, uint256 quantity) external returns (uint256 firstTokenId)

Access: minter-only (msg.sender == minter, else NotMinter)

Mints quantity tokens to to with ids firstTokenId .. firstTokenId + quantity - 1, where firstTokenId is the lifetime mint count plus one, and returns firstTokenId. Reverts ZeroQuantity on zero and ExceedsCap when a set supply cap would be passed. Uses _mint, never _safeMint: the mint path makes no external call, so a receiver check is the minter's job. Emits one Minted plus one Transfer per token.

burn

solidity
function burn(uint256 tokenId) external

Access: permissionless (holder or approved, else ERC721InsufficientApproval)

Burns tokenId. The collection owner has no burn authority over a token it does not hold. Burns never free cap room and the seed stays readable. Emits Burned.

setMinter

solidity
function setMinter(address minter_) external

Access: owner-only (OwnableUnauthorizedAccount)

Sets the one minter. Zero is allowed and means nobody can mint. Emits MinterSet.

setRenderer

solidity
function setRenderer(address renderer_) external

Access: owner-only (OwnableUnauthorizedAccount)

Points tokenURI and contractURI at a new renderer. Reverts RendererRequired on zero and RendererNotContract on an address without code. Emits RendererSet, BatchMetadataUpdate(0, type(uint256).max) and ContractURIUpdated.

setSupplyCap

solidity
function setSupplyCap(uint256 supplyCap_) external

Access: owner-only (OwnableUnauthorizedAccount)

Sets the lifetime mint ceiling. 0 is open. A nonzero cap below the lifetime mint count reverts BadSupplyCap. Emits SupplyCapSet.

setRoyalty

solidity
function setRoyalty(uint16 bps, address receiver) external

Access: owner-only (OwnableUnauthorizedAccount)

Sets the EIP-2981 rate and receiver. Reverts RoyaltyReceiverRequired on a zero receiver and RoyaltyTooHigh above 5000 bps. Emits RoyaltySet.

setName

solidity
function setName(string name_, string symbol_) external

Access: owner-only (OwnableUnauthorizedAccount)

Changes name() and symbol(). The name lives only in the collection; renderers read it from here. Emits NameSet, BatchMetadataUpdate(0, type(uint256).max) and ContractURIUpdated.

notifyMetadataUpdate

solidity
function notifyMetadataUpdate(uint256 fromTokenId, uint256 toTokenId) external

Access: owner-only or the renderer (NotAuthorized)

Emits BatchMetadataUpdate(fromTokenId, toTokenId) for changes the collection cannot observe (a live work's output, a reveal). The renderer can still call it after a renounce. No state change.

initialize

solidity
function initialize(string name_, string symbol_, address owner_, address renderer_, uint256 supplyCap_, uint16 royaltyBps_, address royaltyReceiver_, address minter_) external

Access: deployer one-shot (initializer, else InvalidInitialization)

Sets name, symbol, owner, renderer, supply cap, royalty and the required initial minter. Reverts OwnableInvalidOwner on a zero owner, RendererRequired or RendererNotContract on a bad renderer, RoyaltyReceiverRequired, RoyaltyTooHigh, and MinterRequired on a zero minter. The minter is not checked for code: the launcher passes a sale's predicted address before that sale exists. Emits RendererSet, RoyaltySet, SupplyCapSet and MinterSet. The implementation itself cannot be initialized.

renounceOwnership

solidity
function renounceOwnership() external

Access: owner-only (OwnableUnauthorizedAccount)

Sets the owner to zero. Every setter is refused from then on; this is the collection's only lock. Emits OwnershipTransferred.

transferOwnership

solidity
function transferOwnership(address newOwner) external

Access: owner-only (OwnableUnauthorizedAccount)

Single-step transfer to a new owner. Rejects the zero address (OwnableInvalidOwner). Emits OwnershipTransferred.

approve

solidity
function approve(address to, uint256 tokenId) external

Access: permissionless (holder or operator, standard ERC721)

Standard ERC721 single-token approval.

setApprovalForAll

solidity
function setApprovalForAll(address operator, bool approved) external

Access: permissionless (standard ERC721)

Standard ERC721 operator approval.

transferFrom

solidity
function transferFrom(address from, address to, uint256 tokenId) external

Access: owner-or-approved-only (standard ERC721 transfer authority, else ERC721InsufficientApproval)

Standard ERC721 transfer. A transfer to the collection's own address reverts SelfCustodyRejected.

safeTransferFrom(address, address, uint256)

solidity
function safeTransferFrom(address from, address to, uint256 tokenId) external

Access: owner-or-approved-only (standard ERC721 transfer authority, else ERC721InsufficientApproval)

Standard ERC721 safe transfer, with the same self-custody rule as transferFrom.

safeTransferFrom(address, address, uint256, bytes)

solidity
function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) external

Access: owner-or-approved-only (standard ERC721 transfer authority, else ERC721InsufficientApproval)

Standard ERC721 safe transfer with data, with the same self-custody rule as transferFrom.

Read functions

balanceOf

solidity
function balanceOf(address owner) external view returns (uint256)

Standard ERC721 balance.

config

solidity
function config() external view returns (address renderer_, address minter_, uint256 supplyCap_, uint16 royaltyBps_, address royaltyReceiver_, uint256 minted)

(renderer, minter, supplyCap, royaltyBps, royaltyReceiver, minted) in one read, where minted is the lifetime mint count. This flat tuple differs from the V1 config ABI. Renderers can derive provenance from sequential ids: first is id 1; with a nonzero cap, the final possible mint has tokenId == supplyCap.

contractURI

solidity
function contractURI() external view returns (string)

Delegates to IRenderer(renderer).contractURI(collection). The collection's cover and description live in the renderer.

getApproved

solidity
function getApproved(uint256 tokenId) external view returns (address)

Standard ERC721 approved address for a token.

isApprovedForAll

solidity
function isApprovedForAll(address owner, address operator) external view returns (bool)

Standard ERC721 operator check.

minter

solidity
function minter() external view returns (address)

The one address allowed to call mintTo. Zero means nobody can mint.

name

solidity
function name() external view returns (string)

The collection name, settable by the owner with setName.

owner

solidity
function owner() external view returns (address)

The current owner, or zero once renounced.

ownerOf

solidity
function ownerOf(uint256 tokenId) external view returns (address)

Standard ERC721 holder of a token.

renderer

solidity
function renderer() external view returns (address)

The renderer tokenURI and contractURI delegate to.

royaltyBps

solidity
function royaltyBps() external view returns (uint16)

The EIP-2981 rate in basis points.

royaltyInfo

solidity
function royaltyInfo(uint256, uint256 salePrice) external view returns (address, uint256)

EIP-2981: the stored receiver and salePrice * royaltyBps / 10000, the same for every token. The amount uses full-precision Math.mulDiv, so a large salePrice does not overflow the intermediate multiplication.

royaltyReceiver

solidity
function royaltyReceiver() external view returns (address)

The EIP-2981 receiver. Never zero.

supplyCap

solidity
function supplyCap() external view returns (uint256)

The lifetime mint ceiling; 0 is open.

supportsInterface

solidity
function supportsInterface(bytes4 interfaceId) external view returns (bool)

True for ERC-165, ERC-721, ERC-721 Metadata, ERC-2981 and ERC-4906.

symbol

solidity
function symbol() external view returns (string)

The collection symbol, settable by the owner with setName.

tokenSeed

solidity
function tokenSeed(uint256 tokenId) external view returns (bytes32)

The mint-time seed of a token. Reverts NeverMinted for an id outside 1 to the lifetime mint count; still readable after a burn.

tokenURI

solidity
function tokenURI(uint256 tokenId) external view returns (string)

Delegates to IRenderer(renderer).tokenURI(collection, tokenId). Reverts ERC721NonexistentToken for a token that does not exist.

totalSupply

solidity
function totalSupply() external view returns (uint256)

Live tokens: lifetime mints minus burns.

version

solidity
function version() external view returns (uint256)

2, the implementation lineage marker.

Events

Approval

solidity
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)

Standard ERC721 approval event.

ApprovalForAll

solidity
event ApprovalForAll(address indexed owner, address indexed operator, bool approved)

Standard ERC721 operator approval event.

BatchMetadataUpdate

solidity
event BatchMetadataUpdate(uint256 fromTokenId, uint256 toTokenId)

ERC-4906 refresh signal for a token id range; (0, type(uint256).max) means every token.

Burned

solidity
event Burned(uint256 indexed tokenId)

A token was burned.

ContractURIUpdated

solidity
event ContractURIUpdated()

ERC-7572 signal that contractURI output changed.

Initialized

solidity
event Initialized(uint64 version)

Standard OpenZeppelin Initializable event, emitted once by initialize.

Minted

solidity
event Minted(address indexed minter, address indexed to, uint256 firstTokenId, uint256 quantity)

One per mintTo call: the calling minter, the recipient, the first id and the quantity. Ids run contiguously from firstTokenId.

MinterSet

solidity
event MinterSet(address indexed minter)

The minter changed, including at initialize.

NameSet

solidity
event NameSet(string name, string symbol)

The name and symbol changed.

OwnershipTransferred

solidity
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)

Standard OpenZeppelin Ownable event, emitted on initialize, transfer and renounce.

RendererSet

solidity
event RendererSet(address indexed renderer)

The renderer changed, including at initialize.

RoyaltySet

solidity
event RoyaltySet(uint16 bps, address indexed receiver)

The royalty changed, including at initialize.

SupplyCapSet

solidity
event SupplyCapSet(uint256 supplyCap)

The supply cap changed, including at initialize.

Transfer

solidity
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)

Standard ERC721 transfer, mint and burn event.

Errors

BadSupplyCap(uint256 minted, uint256 cap)

A nonzero supply cap below the lifetime mint count.

ERC721IncorrectOwner(address sender, uint256 tokenId, address owner)

Standard ERC721 error: the from address does not hold the token.

ERC721InsufficientApproval(address operator, uint256 tokenId)

Standard ERC721 error: the caller may not move or burn the token.

ERC721InvalidApprover(address approver)

Standard ERC721 error: an invalid approver.

ERC721InvalidOperator(address operator)

Standard ERC721 error: an invalid operator.

ERC721InvalidOwner(address owner)

Standard ERC721 error: an invalid owner, such as zero in balanceOf.

ERC721InvalidReceiver(address receiver)

Standard ERC721 error: a zero recipient, or a safe transfer to a contract that does not accept tokens.

ERC721InvalidSender(address sender)

Standard ERC721 error: an invalid sender.

ERC721NonexistentToken(uint256 tokenId)

Standard ERC721 error: the token does not exist.

ExceedsCap(uint256 cap, uint256 attempted)

The mint would pass the supply cap.

InvalidInitialization()

Standard OpenZeppelin Initializable error: initialize on an initialized clone or on the implementation.

MinterRequired()

initialize was given a zero minter.

NeverMinted(uint256 tokenId)

tokenSeed was asked for an id that was never minted.

NotAuthorized()

notifyMetadataUpdate from an address that is neither the renderer nor the owner.

NotInitializing()

Standard OpenZeppelin Initializable error, unreachable in normal use.

NotMinter()

mintTo from an address that is not the minter.

OwnableInvalidOwner(address owner)

Standard OpenZeppelin Ownable error: a zero owner at initialize or in transferOwnership.

OwnableUnauthorizedAccount(address account)

Standard OpenZeppelin Ownable error: an owner-only function called by someone else, including after a renounce.

RendererNotContract(address renderer)

The renderer address has no code.

RendererRequired()

The renderer address is zero.

RoyaltyReceiverRequired()

The royalty receiver is zero.

RoyaltyTooHigh(uint16 bps)

The royalty rate is above 5000 bps.

SelfCustodyRejected()

A mint or transfer to the collection's own address.

ZeroQuantity()

mintTo with a quantity of zero.