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

Loading player…

Implementing an ERC 721 Token

BaseMon, Oct 9, 2023, 12:00 AM

Create your own ERC-721 token using Remix and Solidity. Understand the implementation and the step-by-step process to mint and redeem NFTs. Start building your own unique tokens with ease and confidence! 🚀💎 📚 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

all right let's copy this URL and let's start doing our own ERC 721 token the first thing we do if you remember in remix we can import urls and what is happening is we are bringing all the family of contracts for the ERC 721 to the remix environment okay and then by using inheritance we simply say is ERC 721 okay now let's check the implementation and as you notice this Constructor also requires a name and a symbol so let's just copy and let's delete this part symbol I'm renaming a bit I'm renaming the variables but then we need to initialize the ERC 721 and we're gonna pass the name and the symbol that we are receiving okay now what we're gonna do is we are gonna simply create a variable that is going to be called counter okay and then we are gonna initialize counter to one okay and this counter is going to be the token ID that we are gonna use okay and then we're gonna create a function called let's see mine we create a function where everyone can simply come without any permission and they can simply redeem are nft in our contract okay and then what we're gonna do is we are going to call the function save mint okay um there is also a mint however if you notice in the comments the comments recommend to use save mean okay so we are just going to follow the instructions and we say save mint and let's see what save means receives and it receives an address and the token ID so the address is gonna be the message sender and the token ID is going to be the counter okay then the first one that we mean will have an idea of one and then we just say counter plus plus and that should be all okay okay now Let's test and here we are going to assign a name let's call it my nfts okay and as a symbol can be m y all right and we simply are gonna deploy and here we have our token instance notice how this token has all the functions that are defined in the ERC 721 token standard okay so I can try to see the name the symbol the counter and let's try to get the owner of let's say token ID one so since there is no owner yet for this particular token ID it is throwing an error okay so what are we gonna do is let's redeem the nft okay so let's click redeem and it was successful now let's try to query again the owner of the token id1 and as you can see we are getting a value because we already minted the first nft with the counter value as 1. okay since we are increasing here the counter then we can basically redeem again alright so let's try okay and now let's get the owner of the id2 and there we are we have the same owner

Automatic transcript — names and jargon may be misspelled.