By: Jesse Abramowitz, Blockchain Developer
There have been a lot of talks surrounding fungible and non-fungible tokens recently. Although this may appear to be confusing and overwhelming at times, never fear! This article will discuss specific functions in the contract code.
This article is the first installment in a two-part series meant to explore the differences between Non-fungible and fungible tokens. Part II will examine how they can be used. This series is meant for people who have a beginner or intermediate understanding of blockchains, specifically Ethereum.
For the sake of this article, we are going to pick specific Ethereum standards and look at what makes them fungible and non-fungible. For our fungible tokens we will look at ERC20 and for our non-fungible ERC721.
We’re even providing awesome incentive for our readers! If you stick around to the end there is a chance to win some BUNZ tokens!
To be considered an ERC20 token you must have six functions and two event listeners.
As shown above there are functions for:
What we end up with is a unit of value Y with total supply X. Each token Y of X is indistinguishable from any other token Y such that ∑Y = X.
In an ERC721 token, there are similar functions like totalSupply and balanceOf which queries the user in questions balance but with added functions.
Specifically important to conversations surrounding fungibility is the ownerOf function. This query is to find out who owns a specific token. This is because the tokens each have a specific owner!
Again we end up getting a unit of value Y with total supply X. Each token Y of X is now different from the next because they have a specific owner but again ∑Y = X. It ends up looking like this:
If we think about this in a non-virtual way, a fungible token would be like a $20 bill. A $20 has the same value for everyone. If I were to take a $20 from my wallet and trade it for a $20 in your wallet neither of us would have lost anything we would be net neutral…
In value, that is.
Your opinion of me may have changed (as now I may appear as some kind of weirdo) but that has nothing to do with the $20 bill.
In contrast, a non-fungible token would be like a football card. To each individual, the value of that football card will likely differ. For example, To an Eagles fan, a rookie card of Carson Wentz is more valuable than that of Eli Manning. However, to a Giants fan the same would not be true. Although both agree there is a value to each, the exact determination of the value is flexible.
Fungible tokens are awesome and, for the most part, tokenization of all the things has a positive and bright future. On a technical level, it’s important to note that fungible tokens don’t provide an added value to products. They tend to help with a variety of business cases.
Non-fungible tokens can also do some amazing things on a technical level which can change the way the world operates.
In my next article I will go into some more interesting pieces of code in an ERC721 token that can allow that to happen and what “that” is.
Want to launch your own ERC721 token? You can use this code.
You can also interact with a token up on the Ropsten Test Network here.
There are no modifiers on the mintable function so you can mint your own token. (I personally own token 658)
For those that are up for the challenge: The first person to find out my wallet address with that information will receive 500 BUNZ tokens courtesy of BlockX Labs.
EDIT: The challenge prize has been won and is no longer available however, feel free to play just for fun!
Have any questions about fungible vs non-fungible tokens? Or just want to open a dialogue? Feel free to reach out [email protected]