OptimismMintableERC721
Table of Contents
Overview
The OptimismMintableERC721 contract represents an ERC721 token on L2 that corresponds to a native ERC721 token on another chain (typically L1). It enables cross-chain NFT transfers through the ERC721 bridge by allowing the bridge to mint tokens when NFTs are deposited and burn tokens when NFTs are withdrawn.
Definitions
Remote Token
The address of the corresponding ERC721 token contract on the remote chain (typically L1) that this L2 token represents.
Remote Chain
The chain where the Remote Token is natively deployed, identified by its chain ID.
Assumptions
a01-001: Bridge contract is trusted
The bridge contract specified at deployment is trusted to only mint tokens corresponding to valid deposits from the Remote Chain and only burn tokens for valid withdrawal requests.
Mitigations
- Bridge address is immutable and set at deployment
- Bridge contract is part of the audited OP Stack protocol
Invariants
N/A - This contract has no non-obvious cross-function invariants. All critical properties are enforced through single-function access control and standard ERC721 behavior.
Function Specification
constructor
Initializes the OptimismMintableERC721 contract with bridge configuration and token metadata.
Parameters:
_bridge: Address of the ERC721 bridge contract on this network_remoteChainId: Chain ID where the Remote Token is deployed_remoteToken: Address of the corresponding token on the Remote Chain_name: ERC721 token name_symbol: ERC721 token symbol
Behavior:
- MUST revert if
_bridgeis the zero address - MUST revert if
_remoteChainIdis zero - MUST revert if
_remoteTokenis the zero address - MUST set
BRIDGEto_bridge - MUST set
REMOTE_CHAIN_IDto_remoteChainId - MUST set
REMOTE_TOKENto_remoteToken - MUST set
baseTokenURIto an EIP-681 formatted URI:ethereum:{_remoteToken}@{_remoteChainId}/tokenURI?uint256= - MUST initialize the ERC721 contract with
_nameand_symbol
remoteChainId
Returns the chain ID where the Remote Token is deployed.
Behavior:
- MUST return the value of
REMOTE_CHAIN_ID
remoteToken
Returns the address of the token on the Remote Chain.
Behavior:
- MUST return the value of
REMOTE_TOKEN
bridge
Returns the address of the ERC721 bridge on this network.
Behavior:
- MUST return the value of
BRIDGE
safeMint
Mints a token to a recipient address, checking that contract recipients implement the ERC721 receiver interface.
Parameters:
_to: Address to mint the token to_tokenId: Token ID to mint
Behavior:
- MUST revert if caller is not the bridge contract
- MUST revert if
_tois the zero address - MUST revert if
_tokenIdalready exists - MUST revert if
_tois a contract that does not implement IERC721Receiver - MUST mint
_tokenIdto_to - MUST emit
Mintevent with_toand_tokenId - MUST emit standard ERC721
Transferevent from zero address to_towith_tokenId
burn
Burns a token from an owner address.
Parameters:
_from: Address to burn the token from (informational, not used for validation)_tokenId: Token ID to burn
Behavior:
- MUST revert if caller is not the bridge contract
- MUST revert if
_tokenIddoes not exist - MUST burn
_tokenIdfrom its current owner - MUST emit
Burnevent with_fromand_tokenId - MUST emit standard ERC721
Transferevent from current owner to zero address with_tokenId
supportsInterface
Checks if the contract implements a given interface.
Parameters:
_interfaceId: The interface identifier to check
Behavior:
- MUST return true if
_interfaceIdmatches the IOptimismMintableERC721 interface ID - MUST return true if
_interfaceIdmatches any interface supported by ERC721Enumerable - MUST return false otherwise
_baseURI
Returns the base URI for computing token URIs.
Behavior:
- MUST return the value of
baseTokenURI