Skip to main content

ERC721 Base

The Immutable ERC721 Base is an abstract contract that inherits from the ERC721 non-fungible token standard. This contract can be used to extend custom ERC721 contracts from game studios.


Key functionalityRecommended usage
  • Metadata setting and interrogation
  • Restricted role-based functionality
  • Royalty setting and retrieval
  • Royalty enforcement
  • Inheriting and extending to deploy your bespoke ERC721 collection on Immutable zkEVM
caution

This contract is abstract, meaning that it can't be deployed. It is intended to be inherited and extended to suit your needs.

The contract is not an Immutable recommended preset contract.

If you require a contract that is ready to be deployed and offers minting functionality, refer to the ImmutableERC721 minting preset here. The ImmutableERC721 preset is Immutable's recommended preset contract for game development.

Installation and usage

Installation

The preset contract is contained within the contracts repository which can be easily added to your project via:

npm install @imtbl/contracts

We recommend using existing frameworks such as Hardhat or Foundry in order to set up your own smart contract development environment from scratch.

Usage

pragma solidity 0.8.19;

import '@imtbl/contracts/contracts/token/erc721/abstract/ImmutableERC721Base.sol';

contract MyERC721 is ImmutableERC721Base {
constructor(
address owner,
string memory name,
string memory symbol,
string memory baseURI,
string memory contractURI,
address operatorAllowlist,
address royaltyReceiver,
uint96 feeNumerator
)
ImmutableERC721Base(
owner,
name,
symbol,
baseURI,
contractURI,
operatorAllowlist,
royaltyReceiver,
feeNumerator
)
{}
}
Constructor arguments
ArgumentPurpose
ownerThe address to grant the DEFAULT_ADMIN_ROLE to, for administrative permissions
nameThe name of the collection
symbolThe symbol of the collection
baseURIThe base URI for the collection, used for retrieval of off-chain token metadata
contractURIThe contract URI for the collection, used for retrieval of off-chain collection metadata
operatorAllowlistThe address of the operator allowlist
royaltyReceiverThe address of the royalty receiver, a single recipient for the entire collection
feeNumeratorThe royalty fee numerator, specified in basis points. For example, setting the numerator to 200 will result in a 2% royalty fee

Functionality and design

The base contract provides common functionality to all inherited contracts, including the permissioned minting preset and your extension.

It also includes metadata, access control, royalty specification and retrieval, royalty enforcement and all inherited contract functionality, which can be seen below.

Interface

FunctionDescription
baseURI()Returns the base URI
contractURI()Returns the contract URI
owner()Returns the current owner of the contract
setBaseURI(baseURI_)Set the base URI, restriced to admins
setContractURI(_contractURI)Set the contract URI, restricted to admins
transferOwnership(address newOwner)Transfer contract ownership, updating contract owner, restricted to current owner
supportsInterface(interfaceId)Returns whether contract supports supplied interface ID

Inheritance

Ethereum standard contracts

ContractFunctionality
ERC721 (code, EIP)Transferring, minting, approvals, metadata, balance and approval functionality
ERC721Enumerable (code, EIP)Adds enumerability of all the token ids in the contract as well as all token ids owned by each account and total supply retrieval
ERC721Burnable (code, EIP)Adds burning functionality to token ids in the contract
AccessControl (code, EIP)Role setting (granting and revoking), role retrieval, role creation