ERC721 NFTs Decoded: Understanding approvals and ownership (2024)

ERC721 is one of the most common representations of NFTs on EVM blockchains so we will be diving deeper into how they work in this post.

Understanding the ERC721 Standard

ERC721 is a notable standard in the Ethereum ecosystem, created to facilitate the representation of non-fungible tokens (NFTs) on the Ethereum blockchain. Introduced in 2017, the ERC721 standard has gained significant popularity due to its ability to represent unique, indivisible assets, providing a foundation for the booming digital art and collectables market.

Unlike ERC20 tokens, which are fungible and interchangeable, each ERC721 token is unique and can represent ownership over an individual, distinct asset, digital or physical.

Primary use cases of ERC721 tokens include:

Digital Collectibles: The most common use case is in the realm of digital collectables. CryptoKitties, a game where you can collect, breed, and sell virtual cats, was the first major project to use ERC721 tokens.

Digital Art: Artists can mint their artworks as ERC721 tokens, proving their authenticity and allowing them to be bought, sold, or traded on various NFT marketplaces like OpenSea

--- [ shameless shilling - check out my very own NFT collection, Teal Panic-A-Cat which I used to test out some of the features I have been building at Zeal ] ---

Virtual Real Estate: Projects like Decentraland use ERC721 tokens to represent ownership over parcels of virtual land.

Fine Wine Trading: Strauss & Cohas partnered withFanfire to create wine collections backed by NFT baskets, a novel concept for creating baskets for ERC721 tokens.

Token Approvals and Ownership Tracking in ERC721

In ERC721, the concept of ownership is well-defined and standardised. Each token has an owner, which can be transferred via the transferFrom function that emits the transfer event.

Token Approvals: Similar to ERC20, ERC721 also includes an approval mechanism. However, in the case of ERC721, approvals are set per token. This means a token owner can approve another user or a smart contract to manage one of their tokens. This is done via the approve function.

Ownership Tracking: ERC721 tokens use a mapping structure to track the owner of each token. Each token has a unique identifier and the contract stores which address owns each identifier.

Operator Approvals: In addition to per-token approvals, ERC721 also introduces the concept of operator approvals. This allows a token owner to approve another address (an "operator") to manage all their tokens.

The specifics of tracking ownership and approvals in ERC721 contracts can be complex due to the unique nature of each token. In the following sections, we will delve deeper into these topics, providing code examples and discussing their implementations.

Ownership Tracking

ERC721 tokens, also known as Non-Fungible Tokens (NFTs), represent unique items or assets on the blockchain. In the ERC721 standard, each token is unique and can be owned by an individual address. The contract keeps track of the owner of each token through a mapping, much like in ERC20, but this time the mapping is from the unique token ID to the owner's address:

mapping (uint256 => address) private _tokenOwner;function ownerOf(uint256 tokenId) public view virtual returns (address) { address owner = _ownerOf(tokenId); if (owner == address(0)) { revert ERC721NonexistentToken(tokenId); } return owner;} 

Approvals Tracking

ERC721 contracts also keep track of token approvals within their internal state. This allows a token owner to approve another address to transfer a specific token on their behalf. The contract maintains a mapping of token approvals:

mapping (uint256 => address) private _tokenApprovals;function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId);} 

Recommended by LinkedIn

How to Deploy NFT: From Scratch to Creating Your Own… ChainUp 3 months ago
Navigating the Current NFT Marketplace Landscape: A… Libin M 1 year ago
Complete Guide to Utility NFTs for Business Owners and… Consortium 21 - Metaverse | NFT | Web 3.0 | MarTech | O2O2M Marketing 1 year ago

Challenges and Solutions

One challenge with the ERC721 standard is that each token is unique, which can make it more difficult to work with than ERC20 tokens. For example, to transfer multiple ERC721 tokens, you would have to call the transfer function individually for each token, which can be gas-intensive.

An extension to the ERC721 standard, known as ERC721Enumerable, introduces an additional mapping to keep track of all tokens owned by each address, making it easier to work with multiple tokens owned by the same address.

The approval system in ERC721 is more complex compared to ERC20 due to its granular permission settings. Within ERC721, each token requires its own individual approval, or you could use the setApprovalForAll function which authorises a specific address to manage every token the owner presently holds and will acquire in the future. This differentiation contributes to higher gas costs and the added challenge of managing approvals, as tokens are individually approved and entire collections are managed separately.

To illustrate, imagine that you have both individual and 'ForAll' approvals. If one type of approval is revoked, it doesn't impact the other. Thus, should you invoke 'revokeForAll', any individual approvals previously set will remain active. This can be an essential detail when managing ERC721 tokens, as it provides flexibility but can also introduce complexities.

It's worth noting that, like in ERC20, approvals and ownership changes are tracked by listening for Approval, ApprovalForAll, and Transfer events emitted by the contract and updating an off-chain database accordingly.

This poses a challenge for some use cases like building a web3 wallet where users need an accurate representation of all approvals granted for all assets they hold on the blockchain. I've discussed the same issues for ERC20 here:

We have solved this particular problem at Zeal , giving our wallet users a comprehensive view of their ERC20, ERC721 and ERC1155 approvals and balances on the entire blockchain. We currently support Polygon and Binance Smart Chain with many more EVMs to be added in the near future. If you are curious to play with the API, just drop me a message!

In the next post, I'll tackle ERC1155 tokens, and share specifics of how you can use log topics and data to identify approvals.

Some supplemental reading:

If you are a blockchain boffin and spot anything missing or incorrect, feel free to drop a comment.

ERC721 NFTs Decoded: Understanding approvals and ownership (2024)

FAQs

How to prove ownership of NFT? ›

If you ever need to provide NFT proof of ownership, you can do so in a number of ways. Smart contract metadata. First things first, head to the Details section of the NFT smart contract. This should include info on tokenID, contract address, blockchain hosting, metadata status and encoding standard.

What is the approve function in ERC-721? ›

The approve function allows the owner of an ERC721 NFT to approve another address to transfer the token on their behalf. The address approved to transfer the token. The identifier of the token being approved for transfer.

What is the difference between ERC-721 and 721A? ›

ERC-721A is a significantly improved version of ERC-721 but has most features similar to the latter. ERC-721A is more gas-efficient than ERC-721 token. Unlike its predecessor, ERC-721A does not have to be pre-minted but can be minted on-demand all at once, which is more cost-effective too.

How to view ERC-721 NFT? ›

For ERC-721 NFTs, use the tokenURI function, which is part of the ERC-721 standard. This function retrieves a token's metadata so you can view it. For ERC-1155, use the uri method. Note the tokenURI and uri methods are optional for contracts.

How can NFT be used to verify the authenticity of an asset and verify its ownership? ›

After an NFT is digitally sourced or created and recorded to a blockchain, an owner's claim to the NFT can be verified by associating the asset to an address on a blockchain. For example, if an NFT was bought and sold using Bitcoin, one could verify the transaction and ownership on Bitcoin's blockchain.

What is the ERC-721 royalty standard? ›

ERC721-C is a new token standard designed for enforceable on-chain royalties. Unlike ERC-721 and ERC1155, ERC721-C makes royalties programmable and allows creators to prevent zero-fee exchanges from listing their works. Creators can use ERC721-C (and ERC1155-C) to set on-chain royalty rules.

Which ERC is most important? ›

ERC-20 is the most widely used token standard and is used to create fungible tokens, while ERC-721 is used to create non-fungible tokens (NFTs).

How can an ERC1155 token be made into a non-fungible token? ›

Answer: An ERC1155 token can be made into a non-fungible token by ensuring that it's token id has a maximum supply of one, which represents a unique asset. Also, a uri can be specified for the token id, which should contain the metadata for the token, such as, image url, attributes, and other properties.

Which is better ERC-721 or ERC1155? ›

ERC-721 is popular for creating NFTs, enabling the representation of unique digital assets such as artwork, collectibles, and in-game items. ERC-1155 provides flexibility by supporting multiple token types in a single contract, making it suitable for complex token ecosystems like gaming platforms.

Can ERC-721 be fractionalized? ›

By definition, an ERC721 cannot be replicated as each token is completely unique. In order to fractionalize an NFT, a smart contract can be designed to generate a series of ERC20 tokens which are then linked to the specific ERC721 token.

Is ERC-721 a smart contract? ›

These functions play an important role in the formation of unique tokens, each with its distinct metadata, ensuring their individuality. ERC-721 smart contracts function as digital ledger keepers, diligently recording token ownership details.

What is an example of ERC-721 NFT? ›

The ERC-721 token smart contract demonstrates how to create and transfer non-fungible tokens. Non-fungible tokens represent ownership over digital or physical assets. Example assets are artworks, houses, tickets, etc. Non-fungible tokens are distinguishable and we can track the ownership of each one separately.

Does MetaMask support ERC-721? ›

You can add both ERC-721 and ERC-1155 NFTs to MetaMask on any network. At the moment, sending NFTs is only supported for ERC-721 tokens. If you receive a message telling you that you are not the owner of the NFT, please be sure that you are trying to add the token to the right MetaMask account.

Do NFTs contain ownership details? ›

The authenticity of ownership of the NFT is encrypted in a blockchain, a searchable digital ledger of all NFT transactions made, so ownership cannot be forged or fabricated. Ownership of a digital work of art can thus be transferred and validated, opening up new doors for digital artists to market their output.

Who owns the rights to an NFT? ›

Someone who purchases an NFT only owns the asset recorded on the blockchain. The NFT purchaser does not own the creative content. The content creator continues to own the copyright, even if that NFT is resold a million times over.

How to authenticate an NFT? ›

There are several other methods to check the authenticity of an NFT, but they are more technical and complicated. They include using an NFT verification service, verifying NFT ownership through a digital certificate, and using the ID of the NFT to check if you can sell the NFT.

Top Articles
Best Penny Crypto To Invest In 2024
How to See Your Android Notification History? – AirDroid
This website is unavailable in your location. – WSB-TV Channel 2 - Atlanta
Swimgs Yuzzle Wuzzle Yups Wits Sadie Plant Tune 3 Tabs Winnie The Pooh Halloween Bob The Builder Christmas Autumns Cow Dog Pig Tim Cook’s Birthday Buff Work It Out Wombats Pineview Playtime Chronicles Day Of The Dead The Alpha Baa Baa Twinkle
Chicago Neighborhoods: Lincoln Square & Ravenswood - Chicago Moms
FFXIV Immortal Flames Hunting Log Guide
St Petersburg Craigslist Pets
Cumberland Maryland Craigslist
Noaa Swell Forecast
Craigslist Cars And Trucks Buffalo Ny
Umn Pay Calendar
Kentucky Downs Entries Today
Nyuonsite
Blue Beetle Showtimes Near Regal Swamp Fox
Fredericksburg Free Lance Star Obituaries
Illinois Gun Shows 2022
Eine Band wie ein Baum
Hewn New Bedford
Robeson County Mugshots 2022
Poe Str Stacking
Beaufort 72 Hour
'Insidious: The Red Door': Release Date, Cast, Trailer, and What to Expect
Riverstock Apartments Photos
Tom Thumb Direct2Hr
Ewg Eucerin
Mawal Gameroom Download
91 Octane Gas Prices Near Me
Mercedes W204 Belt Diagram
Prévisions météo Paris à 15 jours - 1er site météo pour l'île-de-France
Craigslist Texas Killeen
Wasmo Link Telegram
2024 Coachella Predictions
Mega Millions Lottery - Winning Numbers & Results
Orange Pill 44 291
Walter King Tut Johnson Sentenced
Craigslist In Myrtle Beach
Domino's Delivery Pizza
Merge Dragons Totem Grid
Muziq Najm
Convenient Care Palmer Ma
Wayne State Academica Login
Gravel Racing
Lacy Soto Mechanic
Who Is Responsible for Writing Obituaries After Death? | Pottstown Funeral Home & Crematory
Florida Lottery Claim Appointment
BCLJ July 19 2019 HTML Shawn Day Andrea Day Butler Pa Divorce
Babykeilani
Scythe Banned Combos
Tom Kha Gai Soup Near Me
Caesars Rewards Loyalty Program Review [Previously Total Rewards]
Suzanne Olsen Swift River
Latest Posts
Article information

Author: Rev. Leonie Wyman

Last Updated:

Views: 5582

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Rev. Leonie Wyman

Birthday: 1993-07-01

Address: Suite 763 6272 Lang Bypass, New Xochitlport, VT 72704-3308

Phone: +22014484519944

Job: Banking Officer

Hobby: Sailing, Gaming, Basketball, Calligraphy, Mycology, Astronomy, Juggling

Introduction: My name is Rev. Leonie Wyman, I am a colorful, tasty, splendid, fair, witty, gorgeous, splendid person who loves writing and wants to share my knowledge and understanding with you.