BaseERC721
The BaseERC721 contract extends the basic ERC721 contract with various extensions for controlling a max mint supply and setting royalities.
Implementation¶
The BaseERC721 contract requires the following variables to be passed into the constructor:
| Name | Type | Description |
|---|---|---|
_name | string memory | Name of the collection. |
_symbol | string memory | Symbol for the token. |
_baseURI | string memory | The URI for the token metadata. |
_baseURIExtension | string memory | The extension to be appended to the tokenID when formin the URI. |
_maxSupply | uint256 | The maximum amount of tokens that can be minted. Setting this to 0 will allow for an unlimited supply. |
_royaltyReceiver | address | The address that should receive royalties for secondary sales. |
_royaltyFeeNumerator | uint96 | The fee percentage to charge. The denominator is fixed to 10000, so setting to 750 would make the fee 7.5% (750/10000). |
Usage¶
setBaseURI
- Set the base URI and extension for the token metadata.
_baseURI: The URI that will get prepended to the token ID._baseURIExtension: The extension that will get appended to the token ID.
setDefaultRoyalty
- Set the default royalty to be received for secondary sales. The denominator used for the numerator to form the fraction is 10000.
_receiver: The address that should receive the royalties._feeNumerator: The fee percentage to charge. The denominator is fixed to 10000, so setting the_feeNumeratorto 750 would make the fee 7.5% (750/10000).
deleteDefaultRoyalty
- Delete the default royalty (i.e. reset back to 0% with no receiver).
setTokenRoyalty
function setTokenRoyalty(uint256 _tokenId, address _receiver, uint96 _feeNumerator) external onlyOwner
- Set royalties on a per token basis.
_tokenId: The token to set the royalties for._receiver: The address that should receive the royalties._feeNumerator: The fee percentage to charge. The denominator is fixed to 10000, so setting the_feeNumeratorto 750 would make the fee 7.5% (750/10000).
resetTokenRoyalty
- Reset the royalties for a specific token (i.e. reset back to 0% with no receiver).
_tokenId: The token ID to reset royalties for.
tokenURI
- Get the URI to the metadata for a specific token. Format is
[baseURI][tokenId][baseURIExtension]. _tokenId: The token ID to get the metadata URI for.- Returns the metadata URI for a specific token.
_baseMint
- Mint the supplied token Id to the given address, up to the
MAX_SUPPLY(which may be unlimited). _to: The address to mint tokens to._tokenId: Token ID to mint.