NFT with fixed Supply

The ERC721 smart contract standard is the basic standard for NFTs on EVM compatible chains. The fixed supply limits the total amount of NFTs that can exist from a collection.

The ERC721 is a smart contract standard which is specialised in Non Fungible Tokens (NFT) and out-of-the-box compatible with Opensea. In an ERC721, every NFT is unique which means you have to reference the content for each NFT.


Variables

_name: The name for your NFT collection.

_symbol: The ticker symbol of your NFT collection.

_owner: The current owner of your collection. Initially set to your deployer wallet.

_fixedSupply: The maximum amount of NFTs that can exist for this collection.

_currentTokenID: The current ID of the last minted NFT. This is initially set to 1.


FunctionInput ParametersDescriptionOutput

constructor

None

Initializes the contract by setting the NFT's name and symbol, and assigns the contract deployer as the initial owner.

None

name

None

Returns the name of the NFT.

string memory

symbol

None

Returns the symbol of the NFT.

string memory

balanceOf

address owner

Returns the number of NFT tokens owned by a specific address.

uint256

ownerOf

uint256 tokenId

Returns the owner address of the specified token ID.

address

tokenImage

uint256 tokenId

Retrieves the image URL linked to a specific token ID.

string memory

transferFrom

address from, address to, uint256 tokenId

Transfers a token from one address to another, if the sender is approved or the owner.

None

approve

address to, uint256 tokenId

Approves another address to transfer a specific token ID.

None

setApprovalForAll

address operator, bool approved

Sets or unsets approval for an operator to manage all of the sender's tokens.

None

isApprovedForAll

address owner, address operator

Checks if an operator is approved to manage all tokens of a given owner.

bool

getApproved

uint256 tokenId

Returns the approved address for a specific token ID.

address

mint

address to, string memory imageUrl

Mints a new token to a specified address with an associated image URL, respecting the fixed supply limit.

None

totalSupply

None

Returns the total fixed supply of tokens.

uint256

_exists

uint256 tokenId

Internal function to check if a token exists.

bool

_isApprovedOrOwner

address spender, uint256 tokenId

Internal function to check if an address is an approved spender or the owner of a specific token ID.

bool

_transfer

address from, address to, uint256 tokenId

Internal function to handle the token transfer mechanics.

None

_approve

address to, uint256 tokenId

Internal function to set the approval of a given address to manage a specific token ID.

None

Last updated