본문으로 건너뛰기

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
주의

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 _receiver,
uint96 _feeNumerator
)
ImmutableERC721Base(
owner,
name,
symbol,
baseURI,
contractURI,
operatorAllowlist,
_receiver,
_feeNumerator
)
{}
}

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