Standard NFT

The ERC721 smart contract standard is the basic standard for NFTs on EVM compatible chains.

The ERC721 is a smart contract standard which is specialised in single-copy 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 of your NFT collection

_symbol: The symbol of your NFT collection

_owner: The owner of the NFT collection. Can be transferred and is initially set to the deployer wallet.

_currentTokenID: The Index of NFTs minted in this collection. Initially set to 1.


Function
Input Parameters
Description
Output

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, only callable by the owner.

None

_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