ERC721 tokens & Crypto-Collectibles

aena verma
4 min readApr 5, 2021

Here is the link where you can learn to use ERC721 tokens in your smart contract -> https://cryptozombies.io/en/course

What are tokens??🤔

A token on Ethereum is basically just a smart contract that follows some common rules — namely, it implements a standard set of functions that all other token contracts share, such as transferFrom(address _from, address _to, uint256 _tokenId) and balanceOf(address _owner).

So basically a token is just a contract that keeps track of who owns how much of that token, and some functions so those users can transfer their tokens to other addresses.

What are ERC20 tokens??🙄

If you’ve been in the Ethereum space for any amount of time, you’ve probably heard people talking about tokens — specifically ERC20 tokens.

An ERC-20 Token acts just like the ETH, meaning that 1 Token is and will always be equal to all the other Tokens. It provides functionalities like transferring tokens from one account to another, to get the current token balance of an account and also the total supply of the token available on the network. Besides these it also has some other functionalities like to approve that an amount of token from an account can be spent by a third party account. So the question is why should we need erc721 tokens?

Why do the ERC721 tokens matter?

ERC20 tokens are really cool for tokens that act like currencies. But we can use these tokens everywhere . Since all ERC20 tokens share the same set of functions with the same names, they can all be interacted with in the same ways.

This means if you build an application that is capable of interacting with one ERC20 token, it’s also capable of interacting with any ERC20 token. That way more tokens can easily be added to your app in the future without needing to be custom coded. You could simply plug in the new token contract address, and boom, your app has another token it can use.

But suppose we are building a character game 😎, firstly, characters aren’t divisible like currencies — I can send you 0.237 ETH, but transferring you 0.237 of a character doesn’t really make sense. Secondly, all characters are not created equal. Your Level 2 character “ Hritish ” is totally not equal to my Level 732 character“ Aena💯💯😎💯💯”. (Not even close, Hritish).

ERC721 tokens are not interchangeable since each one is assumed to be unique, and are not divisible. You can only trade them in whole units, and each one has a unique ID. So these are a perfect fit for making our character tradeable.

Note that using a standard like ERC721 has the benefit that we don’t have to implement the auction or escrow logic within our contract that determines how players can trade / sell our character. If we conform to the spec, someone else could build an exchange platform for crypto-tradable ERC721 assets, and our ERC721 character would be usable on that platform. So there are clear benefits to using a token standard instead of rolling your own trading logic.

ERC721 Standard

contract ERC721 {event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);function balanceOf(address _owner) external view returns (uint256);function ownerOf(uint256 _tokenId) external view returns (address);function transferFrom(address _from, address _to, uint256 _tokenId) external payable;function approve(address _approved, uint256 _tokenId) external payable;}
  1. The first way is the token’s owner calls transferFrom with his address as the _from parameter, the address he wants to transfer to as the _to parameter, and the _tokenId of the token, he wants to transfer.
  2. The second way is the token’s owner first calls approve with the address, he wants to transfer to, and the _tokenID . The contract then stores who are approved to take a token, usually in a mapping (uint256 => address). Then, when the owner or the approved address calls transferFrom, the contract checks if that msg.sender is the owner or is approved by the owner to take the token, and if so it transfers the token to him.

What are Crypto-Collectibles?😽

Remember character-in-game while discussing erc721 tokens- that character is mainly Crypto-Collectibles. It is a cryptographically unique, non-fungible digital asset. Unlike cryptocurrencies, which require all tokens to be identical, each crypto-collectible token is unique or limited in quantity. Typically, crypto-collectibles are visualized as real-life objects such as pets or avatars.

Where can I learn more? 🙋‍

The best way to play with crypto-collectibles is to actually buy one (or better, create one!). For that, RareBits or CryptoKitties is a good place to start.

Thank you for Reading!

--

--