ERC721Base

ERC721Base

Git Source

Inherits: AccessControl, ERC721Burnable, ERC721Royalty, ERC721Metadata_URI, ERC721Enumerable

Author: cosimo.demedici.eth (https://github.com/ninfa-labs/ninfa-contracts)

Self-sovereign ERC-721 minter preset

{ERC721} token

State Variables

MINTER_ROLE

MINTER_ROLE is needed if the deployer wants to use or allow other accounts to mint on their self-sovereign collection. The value is the keccak256 hash of "MINTER_ROLE".

bytes32 internal constant MINTER_ROLE = 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6;

CURATOR_ROLE

CURATOR_ROLE is a constant used for role-based access control. The value is the keccak256 hash of "CURATOR_ROLE".

bytes32 internal constant CURATOR_ROLE = 0x850d585eb7f024ccee5e68e55f2c26cc72e1e6ee456acf62135757a5eb9d4a10;

_FACTORY

_FACTORY is a constant set at the deployment of the master contract. It replaces the initializer modifier, reducing the cost of calling initialize from the factory contract when a new clone is deployed.

Functions

constructor

Initializes the contract with the address of the factory contract.

Parameters

Name
Type
Description

factory_

address

The address of the factory contract.

mint

Mints a new token.

The _data parameter should be in the following format/order: abi.encodePacked(bytes32 _tokenURI, address [] memory _royaltyRecipients, uint96[] memory _royaltyBps.

Parameters

Name
Type
Description

_to

address

is not only the recipient, but also the address that will be used for access control when calling the setRoyaltyInfo function. Therefore, _to MUST be an address controlled by the artist/minter to prevent unauthorized changes to the royalty info. When minted for the first time, the royalty recipient MUST be set to msg.sender, i.e., the minter/artist. The royalty recipient cannot and SHOULD NOT be set to an address different than the minter's, such as a payment splitter, or else the setRoyaltyRecipient function will revert when called.

_data

bytes

_mint

Calls parent functions from the most derived to the most base contract: ERC721Metadata_URI, ERC721Royalty, ERC721.

required solidity override to ensure that the contract is initialized.

This is an internal function that is meant to be overridden by derived contracts.

_burn

Burns a token and deletes its royalty info from storage.

Overrides the _burn function of the base contract and all extensions.

initialize

Initializes the contract by setting roles and default values.

Grants DEFAULT_ADMIN_ROLE, CURATOR_ROLE, and MINTER_ROLE to the account that deploys the contract. MINTER_ROLE is needed if the deployer wants to use or allow other accounts to mint. CURATOR_ROLE is needed for artist managing roles such as galleries or curators.

Parameters

Name
Type
Description

_data

bytes

Parameters MUST be encoded in the following order: abi.encode(deployer, defaultRoyaltyBps, symbol, name). The name string is passed to the overridden initialize function as data bytes.

setDefaultRoyalty

Sets the default royalty for the contract.

Can only be called by an account with the DEFAULT_ADMIN_ROLE.

Parameters

Name
Type
Description

_receiver

address

The account that will receive the royalty payments.

_feeNumerator

uint96

The percentage of the sales price that will be paid as a royalty.

setTokenRoyalty

Sets the royalty for a specific token.

Can only be called by an account with the DEFAULT_ADMIN_ROLE.

Parameters

Name
Type
Description

_tokenId

uint256

The ID of the token for which to set the royalty.

_receiver

address

The account that will receive the royalty payments.

_feeNumerator

uint96

The percentage of the sales price that will be paid as a royalty.

setBaseURI

Sets the base URI for the contract.

Can only be called by an account with the DEFAULT_ADMIN_ROLE.

Parameters

Name
Type
Description

baseURI_

string

The new base URI.

exists

Checks if a token exists.

Parameters

Name
Type
Description

_id

uint256

The ID of the token to check.

Returns

Name
Type
Description

<none>

bool

true if the token exists, false if it does not.

supportsInterface

Checks if the contract supports an interface.

Parameters

Name
Type
Description

interfaceId

bytes4

The interface ID to check for.

Returns

Name
Type
Description

<none>

bool

true if the contract supports the interface, false if it does not.

Last updated