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 functionality | Recommended usage |
---|---|
|
|
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
Argument | Purpose |
---|---|
owner | The address to grant the DEFAULT_ADMIN_ROLE to, for administrative permissions |
name | The name of the collection |
symbol | The symbol of the collection |
baseURI | The base URI for the collection, used for retrieval of off-chain token metadata |
contractURI | The contract URI for the collection, used for retrieval of off-chain collection metadata |
operatorAllowlist | The address of the operator allowlist |
royaltyReceiver | The address of the royalty receiver, a single recipient for the entire collection |
feeNumerator | The 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
Function | Description |
---|---|
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
Contract | Functionality |
---|---|
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 |