New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

ERC 721 Standard Overview

BaseMon, Oct 9, 2023, 12:00 AM

Create an ERC-721 token compliant with the non-fungible token standard. Understand the importance of token IDs, implement ERC-721 functions, and explore metadata extensions like token URI for richer NFT information. Start creating unique and customizable NFTs now! 🎨🔖 📚 Head to Base Camp for full courses on smart contract development: https://docs.base.org/base-camp/docs/welcome ✅ Subscribe to our channel here: https://www.youtube.com/@BuildonBase ► Build on Base: https://base.org ► Follow us on Twitter: https://twitter.com/buildonbase ► Join our Discord: https://base.org/discord

Transcript

in this exercise we are going to do an ERC 721 token as I mentioned the ERC 721 standard is for non-fungible tokens which means that these tokens are unique so let's get started and now let's create a contract called my ERC 721 so how do we do an ERC 721 token that is compliant with the standard and before getting started with the coding section let's simply analyze the standard that is in the ethereum Improvement proposals website okay now this is standard defines an interface where as you can see the specification said every ERC compliant must implement the following interfaces okay and the interface is defined here okay now as you can see there are many similarities with the erc20 that we were working before like for instance there is also a transfer event an approval event but now we have an extra event so these events are similar one thing to notice is that these events contain a token ID okay we are gonna see the importance of this token ID in a bit okay the interface also defines a function to get the balance this function is basically to count all the nfts assigned to an owner we also have another function that is very useful to find the owner of an EFT and there is also a safe transfer front okay this one also contains a token ID alright we can read a bit more in the comments and as you see this function transfers the ownership of an EFT from one address to another okay we also have a transfer from an approve similar to the erc20 and then extra functions for instance this set approval for all basically is to enable or disable an approval for a third-party operator to manage all their sets that we have okay get approved and then a function to query if an address is authorized operator for another address okay then the token standard also defines some wallet interface okay what is saying is that a wallet must implement the wallet interface if it will accept transfer okay so basically if we want to create a contract or a wallet and we want to accept ERC 721 transfers we need to implement this interface okay the standard also defines a set of extensions okay in this case the metadata extension is optional however it is very important to see the functions that this ERC 721 metadata interface defines and these functions can be very useful for instance to get the name of a collection of nfts okay also a symbol or abbreviated name for the nfts in this contract okay and and a token URI okay which is a uniform resource identifier for a given asset okay um we are going to see for instance that this URI my point to a Json file and this Json file will need to confirm the metadata Json scheme of the ERC 721 example of at ERC 721 metadata Json schema is this one where basically notice we have a title and then we have some properties okay we have a name a description and an image okay now you might have noticed that websites like openc basically allow you to explore nfts and these nfts have an image okay so the way it works is that we can create a Json that describes all the metadata of our particular token and what is exactly representing then we can store this for instance in ipfs or simply in a server and then the nft what it's gonna do is it's only gonna store the URI where the file with all the metadata is gonna leave

Automatic transcript — names and jargon may be misspelled.