Coding For Beginners Blockchain Development A Step-By-step Guide To Create Your Own Blockchains, Cryptocurrencies and NFTs... (Davis, Elliot) (Z-Library)
Coding For Beginners Blockchain Development A Step-By-step Guide To Create Your Own Blockchains, Cryptocurrencies and NFTs... (Davis, Elliot) (Z-Library)
Development
By
Elliot Davis
© Copyright 2021 by Elliot Davis - All rights reserved.
This document is geared towards providing exact and reliable information in
regard to the topic and issue covered. The publication is sold with the idea
that the publisher is not required to render accounting, officially permitted, or
otherwise, qualified services. If advice is necessary, legal or professional, a
practiced individual in the profession should be ordered.
From a Declaration of Principles which was accepted and approved equally
by a Committee of the American Bar Association and a Committee of
Publishers and Associations.
In no way is it legal to reproduce, duplicate, or transmit any part of this
document in either electronic means or in printed format. Recording of this
publication is strictly prohibited and any storage of this document is not
allowed unless with written permission from the publisher. All rights
reserved.
The information provided herein is stated to be truthful and consistent, in that
any liability, in terms of inattention or otherwise, by any usage or abuse of
any policies, processes, or directions contained within is the solitary and utter
responsibility of the recipient reader. Under no circumstances will any legal
responsibility or blame be held against the publisher for any reparation,
damages, or monetary loss due to the information herein, either directly or
indirectly.
Respective authors own all copyrights not held by the publisher.
The information herein is offered for informational purposes solely and is
universal as so. The presentation of the information is without contract or any
type of guarantee assurance.
The trademarks that are used are without any consent, and the publication of
the trademark is without permission or backing by the trademark owner. All
trademarks and brands within this book are for clarifying purposes only and
are owned by the owners themselves, not affiliated with this document.
BEFORE YOU START READING,
DOWNLOAD YOUR FREE DIGITAL
ASSETS!
CHAPTER 6: TOKENS
6.1 Understanding The Concept of Tokens
6.2 The ERC20 Token
6.3 Launching Our Own ERC20 Token
6.4 The ERC721 Non-Fungible Tokens (NFT) Standard
6.5 Some More Insight into NFTs
6.6 Uses of Token Standards
CONCLUSION
Introduction
The first chapter of this book will discuss the basic fundamentals of coding
and cryptocurrency. To understand the concept of blockchains and
cryptocurrency, it is very important to understand how computer
programming works.
Now, coding is not a very complex field of work and can be understood if
one gives proper time and dedication to the subject. To understand in-depth
coding concepts, we need to learn a bit about what a program is. But first,
let’s go through a brief overview of Bitcoin & Blockchains
1.1 History of Bitcoin
Many people regarded coding as an odd hobby reserved for geeks tinkering
with gadgets in their basements. However, coding has transformed from a
hobby to a critical employment skill over the last few years. Employers have
indicated an interest in paying a premium for personnel with coding and
programming skills. With that in mind, let us examine our first advantage:
Earning Profitability: One of the finest and most evident benefits of
learning to code is the earning potential for coding and programming experts.
The Bureau of Labor Statistics (BLS) collects and analyses pay and other
employment data for a broad range of occupations.
Consider the 2019 median annual wage statistics from the Bureau of Labor
Statistics for the following coding and programming-related occupations
(bearing in mind the average annual wage of $45,000):
Once recorded, the blocks are designed to be immutable; the data contained
within a block cannot be modified retroactively. A public blockchain
database is managed independently via a peer-to-peer system and a
distributed timestamping server. Blockchains are an open, decentralized
technology that enables the efficient and permanent recording of two-part
transactions.
When learning about cryptocurrency, one of the first terms you may
encounter is "blockchain." Understanding the Blockchain is critical for
understanding Bitcoin, cryptocurrency, and the promise of digital software in
general. Thus, what is a blockchain, and why is it so critical?
This chapter discusses the problem that the Blockchain is intended to solve
and why solving it is vital. This level deepens the understanding of the
Blockchain's application area, the environment in which it offers the most
value, and the relationship between trust, honesty, and ownership
management. By the end of this section, you will have a better grasp of how
the Blockchain works and a more nuanced definition of the term
"Blockchain."
The parable
Numerous languages have a graphic expression for when someone seeks to
organize an unruly mob. In English, this situation is sometimes referred to as
attempting to herd cats. It shows the difficulties inherent in herding a bunch
of stubborn and refractory animals that refuse to recognize or consider a
central authority. Is it common for you to desire to join a coalition of
individuals who refuse to accept or acknowledge a central authority? This is
the situation with a completely distributed peer-to-peer network composed of
independent and self-contained nodes with little central control or
coordination. This action exemplifies how the Blockchain addresses a
significant issue in strictly distributed peer-to-peer networks.
Knowing the number of nodes and their trustworthiness increases the odds of
obtaining credibility in a distributed peer-to-peer system. This is comparable
to maintaining a private club with strong moral standards and a rigorous
onboarding procedure for new members. When the quantity and
trustworthiness of nodes are unknown, the worst conditions for ensuring
honesty in a distributed peer-to-peer system occur. This is true when an open-
source, strictly distributed peer-to-peer system is running on the Internet.
• Errors in technology
• Peers who are malicious
Technical Inaccuracies:
Bitcoin was the first decentralized digital currency and the first program
created on a blockchain platform. Bitcoin is by far the most popular and well-
known cryptocurrency today, as well as the world's largest and most active
open Blockchain. As Bitcoin gained public acceptance, several media outlets
began to use "Bitcoin" and "blockchain" interchangeably. Even today,
numerous articles struggle to explain the relationship between Bitcoin, other
cryptocurrencies, and blockchain technology in a straightforward manner.
To ensure clarity, let us begin with the essentials. Bitcoin is, at its core, a
currency. It was created to facilitate digital, secure, peer-to-peer financial
transactions and has largely accomplished this purpose. Bitcoin operates
based on a blockchain. On the other hand, blockchain technology has uses
that reach well beyond Bitcoin and the field of digital currency in general.
Bitcoin's blockchain model works extremely well, yet there are several areas
for development. (For instance, Bitcoin transactions can take a long time to
process, posing a barrier of entry for many companies interested in taking
Bitcoin payments.) Nobody enjoys waiting an hour in a store while a Bitcoin
transaction is verified.
While Bitcoin was the first technology to deploy the Blockchain, early
adopters such as Vitalik Buterin rapidly saw the Blockchain's promise in a
broad range of other contexts. Because Bitcoin was created expressly to be a
currency, entrepreneurs began to consider whether the Bitcoin blockchain
structure was the best paradigm for developing applications other than peer-
to-peer digital money transactions. Ethereum was created out of the need to
provide a more flexible environment for universally leveraging the potential
of blockchain technology across a diverse range of various applications.
Thus, each new block is a compilation of data about the most recent
transactions. Each block is cryptographically secure and is linked to the
previous block via a specific type of timestamp. Here, very complex
arithmetic is performed to ensure that each new block corresponds to the
whole history of all prior transactions on the entire Blockchain.
Each new timestamp must match the timestamp of the preceding block,
which was linked to the one before that, forming a continuous chain in which
each block is verifiably related to the one before it, all the way back to the
very first block, dubbed the "genesis block." The whole history of every
Bitcoin transaction is stored on the Blockchain, which is publicly accessible
to anybody. The ability to conduct secure transactions with this level of
transparency has attracted many individuals to Bitcoin and blockchain
technology.
To put it simply, the Bitcoin blockchain is a record of every validated Bitcoin
transaction that has ever occurred. Blocks are used to aggregate together
transactions that occur over a specified period. Multiple, identical versions of
the Blockchain are constantly stored and updated by a global network of
participating computers. This is commonly referred to as a "distributed
ledger." Fundamentally, a distributed ledger is merely a massive
decentralized database or a record of data, events, or transactions.
Decentralization is a fundamental principle underlying both Bitcoin and
Ethereum's blockchain architectures and numerous other blockchain-based
initiatives and cryptocurrencies.
Although not all distributed ledgers are blockchains, all blockchains use some
form of a distributed ledger. Typically, this means that identical copies are
stored and updated concurrently on many separate devices located throughout
the world. In the case of Bitcoin, anyone wishing to hack or "cheat" the
Blockchain would have to modify the data of not just one block but the entire
historical record across the majority of the network's decentralized machines.
Due to the amount of computational power necessary to accomplish this, it is
almost impossible to do so under current conditions, ensuring that the system
is safe by design.
Ethereum Blockchain
While not identical conceptually, the Ethereum blockchain is structured
similarly. When it comes to Ethereum, the basic distinction is in the type of
data stored in blocks and how that data is processed.
Today, Bitcoin remains the largest open public Blockchain and serves as the
de facto blueprint for many other blockchain-based applications. The Bitcoin
blockchain, on the other hand, is merely one implementation of blockchain
technology. As more sectors investigate the potential of Blockchain, new
models emerge regularly, frequently tailored to a particular purpose.
So, what is a distributed system exactly? Let us comprehend it first and then
cross it off the list to avoid interfering with the ongoing discussion. Please
keep in mind that every system, whether centralized or decentralized, can be
distributed. A centralized distributed system is composed of a master node
responsible for decomposing tasks or data and dispersing the burden among
the nodes. On the other side, a distributed system that is decentralized does
not have a "master" node, but the computing is distributed.
Centralized Systems:
As the name implies, a unified system is one in which all administrative
functions are coordinated through a single management point. While such
systems are straightforward to establish, administer, enforce, and rule, they
have various inherent flaws, including the following:
• They are less robust because they include a single point of failure.
• They are more prone to attack and thus less secure.
• Concentrating power can result in immoral behavior.
• Scalability is frequently a problem.
Decentralized Systems:
As the name implies, a decentralized structure lacks centralized power and
grants equal authority to each node. Building, managing, controlling, and
enforcing confidence in such systems is not easy. They do not, however, have
the drawbacks associated with typical centralized structures. Several
advantages of decentralized systems include the following:
• They do not have a single point of failure, making them more reliable
and less prone to failure.
• It is more stable due to the lack of a concentrated point of attack.
• Symmetrical authority structure that limits the scope of immoral
activity and is often democratic
2.4 Smart Contracts
Despite their basic differences, many people regard Bitcoin and Ethereum as
"competitors" vying for control of the blockchain space. This perspective is
not entirely accurate even for individuals who are only concerned with Ether
as money and have no interest in technology. Bitcoin and Ethereum are two
independent, coexisting technologies with distinct objectives and purposes.
Bitcoin is intended to function as a medium of exchange; it is not a means to
an end. Ethereum makes use of Ether to facilitate the execution of smart
contracts; the Ether currency serves as a means to an end. In this way, the two
projects are complementary, as they have distinct visions, objectives, and
uses.
To better understand smart contracts and how the Ethereum platform works,
it is helpful to review certain software development fundamentals. If you
have executed any programming language, you will have an advantage in
understanding how smart contracts execute code. If not, have no fear. Again,
you do not need to write code to grasp how Ethereum works, although it is
beneficial to familiarize yourself with some fundamental programming ideas.
Chapter 3: IDE and Frameworks
An IDE helps developers quickly create new apps since many tools are not
required to be integrated manually during the setup phase. Additionally,
developers save time by not spending hours on learning how to utilize many
different tools when they are all represented on the same workbench. This is
particularly advantageous for onboarding new engineers, who may rely on an
IDE to quickly become familiar with a team's standard tools and procedures.
Indeed, most features in integrated development environments (IDEs) are
designed to save time, such as intelligent code completion and automatic
code generation, which eliminates the need to write out whole character
sequences.
Other popular IDE features are intended to assist developers in organizing
their work and resolving issues. IDEs parse code as it is written, allows for
real-time detection of problems caused by human mistakes. Since a single
graphical user interface presents utilities, developers may perform operations
without moving between apps.
Syntax highlighting is also a feature included in most integrated development
environments (IDEs), which employs visual signals to distinguish between
different types of grammar in the text editor. Additionally, several IDEs
feature class, object explorers and representations of the class hierarchy for
certain languages.
It is possible to develop apps without using an IDE or for each developer to
create their IDE manually. The advantage of this method for certain
developers is the extreme customizability and control it provides. However,
in a corporate setting, the time savings, environment consistency, and
automation capabilities of current IDEs typically surpass any other benefits.
Before the advent of integrated development environments, programmers
created their scripts in text editors. This entailed composing and saving a
program in a text editor before running it through the compiler, noting any
error warnings, and then returning to the text editor to update their code.
It was not until 1983 that Borland Ltd. bought a Pascal compiler and released
it as TurboPascal, the first language to provide an integrated editor and
compiler
While TurboPascal popularized the concept of an integrated development
environment, many feel Microsoft's Visual Basic (VB), released in 1991 to be
the first true IDE. Visual Basic was a widely-used programming language
throughout the 1980s. It was written in the earlier BASIC language. With the
advent of Visual Basic, programming could be conceived of in graphical
terms, resulting in significant productivity gains.
Today, most enterprise development teams choose a pre-configured
integrated development environment (IDE) optimized for their unique use
case; hence, the decision is not whether to implement an IDE but which IDE
to choose.
3.2 The Advantages of IDEs
There are several technical and business applications for IDEs, implying
numerous proprietary and open-source IDE solutions. Typically, the essential
aspects that distinguish IDEs are as follows:
The range of supported languages: Some IDEs are language-specific and
better suited to a particular programming style. For example, IntelliJ is
largely recognized as a Java integrated development environment (IDE).
Other IDEs, such as the Eclipse IDE, support various languages in one
package, including Java, XML, and Python.
Supported operating system(s): A developer's operating system will narrow
down which IDEs are feasible (unless the IDE is cloud-based) and if the
application created is meant for an end-user running a certain operating
system (such as Android or iOS), this constraint may be amplified.
While most IDEs have the three critical capabilities of a text editor, build
automation, and debugger, many also incorporate refactoring, code search,
and continuous integration and deployment (CI/CD) tools.
Impact on system performance: If a developer wishes to run other memory-
intensive apps concurrently, the memory footprint of an IDE may be critical
to consider.
Extensions and plugins: Some IDEs enable developers to tailor processes to
their specific requirements and preferences.
Integrated development environments for mobile devices
Almost every sector has been impacted by the growing popularity of
smartphone and tablet applications, which has prompted many businesses to
build mobile applications in addition to traditional web applications. Platform
selection is a critical component in mobile application development. For
example, if a new application will be used on iOS, Android, and a web page,
it may be prudent to begin with an IDE that supports several operating
systems.
Blockchain Testnet
Blockchain Testnet is the last addition to the list of the top blockchain tools
accessible right now. It is a fundamental tool for blockchain developers and is
useful for pre-production testing of decentralized applications. Each
blockchain solution has its own Blockchain Testnet, optimized for best
performance with the respective blockchain solution.
When it comes to Blockchain development, the value of the Blockchain
Testnet cannot be overstated. A Blockchain Testnet enables you to evaluate
decentralized applications (dApps) before launching them live. Each
blockchain solution has its Testnet, and it is strongly advised that you utilize
the Testnet associated with that solution for the best results. There are three
different types of Blockchain Testnets: public, private, and GanacheCLI.
Testnets are incredibly beneficial since they enable you to test your
decentralized applications thoroughly for faults and problems without
investing a lot of money or resources. For instance, Ethereum utilizes gas as a
fuel source for several functions. Spending money on petrol each time you
need to perform a test drive can quickly add up to a significant financial
burden. Testing becomes possible as a result of Testnets. Users may choose
from three distinct types of Blockchain Testnets: public, private, and Ganache
CLI. Testnet is a useful resource for identifying flaws and vulnerabilities in
decentralized applications without requiring large financial inputs. Gorli
Testnet is now one of the most popular among developers.
Follow this link to visit their website and learn more:
https://www.blockchain.com/explorer?view=btc-testnet
Ganache
As a Truffle Suite Blockchain tool, Ganache enables Blockchain developers
to establish their own private Ethereum blockchain for testing decentralized
applications, analyzing state, and executing commands while maintaining
complete control over the chain's operation.
Ganache is a Truffle Suite Blockchain tool that enables you to construct your
own private Ethereum blockchain for testing decentralized applications,
executing commands, and inspecting state while maintaining complete
control over the chain's operation.
The most significant feature of Ganache is that it enables users to do any
operations that are possible on the main chain without paying for them.
Ganache is a widely popular Blockchain tool among developers due to its
features, including an integrated block explorer and powerful mining
controls. Blockchain engineers use Ganache to test their smart contracts
throughout the development process.
Follow this link to visit their website and learn more:
https://trufflesuite.com/ganache/
Embark
As a developer platform for Ethereum decentralized applications, Embark
enables developers to create and deploy decentralized applications quickly.
Additionally, it enables users to design and deploy serverless HTML5
applications that take an application of decentralized technology.
Additionally, one can use Embark to develop smart contracts and make them
accessible in the JS code. If the contract is amended, Embark and the
associated Dapp will adjust it independently.
In the case of numerous contracts, migration, redeployment, and
modifications are all readily handled. To interface with Embark, one may
utilize a regular web development language and any build workflow. Embark
enables developers to write contracts using Javascript on a test-driven basis
and manage their contracts across many blockchains.
Follow this link to visit their website and learn more:
https://framework.embarklabs.io/
Truffle
Truffle is a significant rival among the top blockchain tools. It is an Ethereum
blockchain framework designed to simplify the development of Ethereum-
based applications by providing a development environment. Additionally,
Truffle contains a vast library of custom deployments that enable the creation
of new smart contracts and the resolution of blockchain development
difficulties.
Additionally, Truffle is well-suited for developing complicated Ethereum
decentralized applications. Automated contract testing is another major
feature of Truffle as a blockchain tool. Truffle can automate contract testing
using Mocha and Chai. Additionally, Truffle can assist in facilitating the
development of smart contracts and their linkage, compilation, and
deployment. Notably, Truffle also has a customizable build pipeline that
enables the execution of bespoke build methods.
Follow this link to visit their website and learn more:
https://trufflesuite.com/
Metamask
At the moment, the majority of blockchain technology usage is focused on
cryptocurrencies. Thus, wallets are also considered the greatest blockchain
tools, while Metamask offers some additional features. It acts as a bridge
between a web browser and the Ethereum blockchain.
Additionally, Metamask provides a software platform for providing Ether and
other ERC-20-compliant assets. Simultaneously, it enables interaction with
Ethereum's decentralized applications. The browser-based capability may
contribute to Metamask's simplicity of usage. It is critical to understand that
users may connect Coinbase and Shapeshift to Metamask to sell and acquire
ERC20 tokens and ETH.
Additionally, users may utilize Metamask to store keys for ETH and ERC20
tokens. Metamask is compatible with various Ethereum test networks,
making it an ideal wallet for blockchain engineers. After installing the app in
the browser, users will have access to an integrated Ethereum wallet.
Follow this link to visit their website and learn more:
https://metamask.io/
Parity
Parity is an Ethereum client. This is another powerful platform among
blockchain engineers since it is a mission-critical management tool.
Additionally, parity makes use of the Rust programming language. Another
fantastic aspect of this technology is that it gives an infrastructure that is both
fast and dependable.
In any case, creating your blockchain network for personal or commercial
use, or even simply for research purposes, is simple. To put it another way,
all of these are fully customizable.
Follow this link to visit their website and learn more:
https://www.parity.io/technologies/ethereum/
3.5 Blockchain Development Frameworks
This step of learning is the book's cornerstone since it teaches how the
blockchain operates inside. This stage's learning activities will take you
through all of the blockchain's principles and underlying technology. By the
end of this level, you will have a firm grasp of all of the blockchain's
fundamental principles, how they operate independently, and how they work
together to form the massive apparatus known as the blockchain.
4.1 Planning the Blockchain
We have already discussed what a blockchain is, its use, and how it operates.
However, the blockchain was not invented, so that we might waste time
debating its technical concepts. Rather than that, the blockchain was invented
for real-world applications. As a result, this stage delves deeper into the
application of the blockchain. Additionally, it specifies generic blockchain
application patterns and connects them to the blockchain's features.
Additionally, this stage sketches some blockchain applications and discusses
the details that should be addressed while examining a particular blockchain
application.
The Allegory
Why are shelves, cabinets, drawers, and boxes used? These storage methods
are frequently utilized since they allow for the storing and organization of
items regardless of their intended function. A box can be used to hold a
variety of items, including documents, technical spare parts, office supplies,
photographs, money, DVDs, clothing, and wine bottles. The versatility of
boxes, drawers, cabinets, and shelves is limited only by the diversity of goods
stored in them. However, I will first discuss the blockchain's capabilities as a
specific box for digital objects.
The Blockchain's Characteristics
The blockchain is a decentralized peer-to-peer data storage system that
possesses the following properties:
• Immutable
• Append-only
• Ordered
• Time-stamped
• Transparent and open
• Secure (identification, authentication, and authorization)
These qualities of the blockchain are agnostic to the data that is stored on it.
Thus, the blockchain may be thought of as a specific type of box for keeping
digital goods from a basic point. This paves the way for a plethora of
blockchain-based applications.
The term "wallet" has various meanings in Ethereum. At its most basic level,
a wallet is a piece of software that acts as the principal user interface for
Ethereum.
The wallet maintains track of a user's keys and addresses and initiates and
also signs transactions. Additionally, certain Ethereum wallets are capable of
communicating with contracts, like ERC20 tokens. From a programmer's
perspective, the phrase "wallet" relates to the system that stores and manages
users' keys.
Each wallet has a key management component. That is the extent of most
wallets. Other wallets are classified as browsers, gateways to Ethereum-based
decentralized apps, or DApps. There are no apparent boundaries between the
many categories often referred to as "wallets."
5.1 Crypto wallets
A crypto wallet is a type of digital wallet used to accept, transmit, and store
digital currencies such as Bitcoin or Ethereum. The majority of currencies
have an official wallet or a third-party wallet approved for the storage of
digital money.
They would function identically to traditional leather wallets used to carry
cash and credit cards in an ideal world. The main distinction is that
cryptocurrency wallets are virtual. However, unlike a typical wallet, this
virtual wallet displays your current balance, your most recent spending, and
other information that a leather wallet cannot. As with digital apps,
cryptocurrency wallets are smarter in that they combine all of the advantages
of a physical wallet with additional flexibility and sophistication. With just
one wallet, users may store a variety of digital currencies without ever having
to worry about running out of capacity.
As a cryptocurrency investor, you should acquaint yourself with how wallets
function so that once you have your tokens, trading in the ICO market will be
seamless.
5.2 The Cryptocurrency Wallets' Operation
The number of wallets available continues to grow daily, and consumers now
have a plethora of alternatives. However, before you decide on which wallet
to use for your key coin offering investment, keep the following points in
mind:
Are you going to invest in many initial coin offerings (ICOs) or just
one?
Do you require access to your digital wallet from any location, or will
you use it at home?
Will you use your wallet for daily transactions, or are you more
interested in purchasing and retaining coins as an investment?
After asking yourself these questions and thoroughly assessing your needs,
you can easily pick which wallet would best serve your interests, allowing
you to pick the most suitable wallet.
Several of the finest crypto wallets for ICO tokens include the following:
MyEtherWallet
This is one of the most widely-used wallets in the crypto community. It may
purchase, trade successfully, and store ERC20 tokens received through initial
coin offerings (ICOs). It is one of the most widely accepted wallets since it
combines an internet wallet with an offline wallet.
Jaxx
This is another incredible wallet. It can store, trade, and control Bitcoin,
Litecoin, Ethereum, Augur, and a slew of other blockchain-based assets. It
allows you total control over your key, in addition to offering a slew of basic
yet useful functions.
Trezor
This hardware wallet provides an extremely secure method of safeguarding
your funds from hackers and malware. Its major distinguishing qualities are
cross-platform compatibility and an OLED display.
KeepKey
This is another hardware wallet for Ethereum, Bitcoin, Litecoin, and other
tokens. Additionally, it includes a USB port as one of its distinctive
characteristics.
The Exodus
This is a multi-digital asset wallet and the first desktop wallet to include an
integrated ShapeShift feature that enables easy and rapid conversion between
various cryptocurrency tokens and altcoins. Additionally, it permits the
storage of the private key in a configurable user interface application.
5.4 A Brief Overview of Wallet Technology
This section will discuss the various technologies used to develop user-
friendly, secure, and customizable Ethereum wallets. When developing
wallets, it is critical to strike a balance between convenience and privacy. The
most efficient Ethereum wallet stores all of its funds with a single private key
and address. Unfortunately, such a method presents a privacy nightmare since
all your operations may readily be tracked. While using a unique key for
every transaction increases security, it becomes incredibly complex to
administer. The optimal balance is tough to attain, which is why a well-
designed wallet is critical. Ethereum wallets do not hold ether or tokens,
contrary to popular belief. Indeed, the wallet contains simply the keys.
Ethereum's blockchain is used to store ether and other tokens. By verifying
transactions only with keys in their wallets, users gain control of the
network's tokens.
In some ways, an Ethereum wallet is similar to a digital keychain. However,
because the wallet keys are the only item necessary to send or receive ether or
tokens, this distinction is mostly unimportant in practice. The distinction is in
changing one's outlook from dealing with the centralized approach of
conventional banking (where only you and the financial institution can see
the money in your account, and you only need to reassure the bank that you
want to move funds to complete a transaction) to interacting with the
decentralized network of blockchain platforms (where anyone can see an
account's ether balance, even if they do not recognize who owns it, and
everybody needs to be reassured that they want to ) to dealing with the
decentralized network of blockchain platforms (where In reality, this implies
that there is a mechanism to check an account's balance without accessing the
wallet. Additionally, you may migrate your existing wallet us account
management to a new wallet.
Wallets are split into two categories based on the relationship between the
keys they store.
The first kind is a nondeterministic wallet, which generates each key
separately using a distinct random integer.
The keys are unrelated. This sort of wallet is often referred to as a
JBOK wallet, from "Just a Bunch of Keys."
The second form of wallet is the deterministic wallet, which derives all
keys from a single master key, referred to as the seed. Each key in this
form of wallet is connected to the previous one and maybe produced
again if the seed is accessible.
Numerous key derivation methods are employed in deterministic wallets.
As explained in "Deterministic Hierarchical Wallets," the most often utilized
derivation approach makes use of a treelike structure.
To make deterministic wallets a little more secure against data loss accidents,
such as getting your mobile device stolen or accidentally dropping it in the
bathroom, the seeds are regularly encoded as a series of terms (in English or
another language) that you can write down and use in the event of an
accident.
These are the wallet mnemonic code words. Naturally, if your mnemonic
code words are hacked, they can rebuild your wallet, giving them
accessibility to your ether and smart contracts. As a result, proceed with
caution while constructing your list of recovery words! Never save it
digitally, in a file, on a computer, or a mobile device. Make notes of it on
paper and save it in a safe and secure location.
5.5 Nondeterministic Wallets
Each wallet file contains a completely random private key in the first
Ethereum wallet (made for the Ethereum pre-sale). These "traditional"
wallets are being dropped out in preference of deterministic wallets because
of their numerous shortcomings. For example, it is best practice to avoid
reusing Ethereum addresses to optimize your privacy when using Ethereum.
To receive cash using a new address (needing a new private key) each time,
you may go even farther and use a unique address for each transaction, but
this might get costly if you regularly deal with tokens.
To adhere to this approach, a nondeterministic wallet list of keys must be
increased regularly, which implies that backups must be performed
frequently. If you ever lose your data (due to disk failure, a careless accident,
or having your phone stolen) without first backing up your wallet, you may
forfeit access to your assets and smart contracts.
Nondeterministic wallets of "type 0" are the most difficult to manage, as they
produce a new wallet file for each new address "just in time." In the Keystore
format, a key derivation function (KDF), sometimes called a password
stretching method, is employed to guard against dictionary, brute force and
rainbow table attacks. That being said, the pass does not encrypt the private
key directly. Rather than that, the pass is extended by repeatedly hashing it.
As specified by the Keystore JSON option crypto. Kd.params.n the hashing
function is repeated 262,144 times. A brute-force attacker would have to
perform 262,144 rounds of hashing to each attempted pass, considerably
slowing the attack and rendering it unfeasible for sufficiently sophisticated
and lengthy passes.
Numerous software libraries, such as the JavaScript library keythereum, can
read and write the Keystore format. Nondeterministic wallets should not be
used for anything more than rudimentary experiments. They are far too large
to transport and utilize in anything but the most basic of scenarios. Instead of
that, utilize an HD wallet with an industry-standard mnemonic.
5.6 Deterministic (Seeded) Wallets
The term "token" is derived from the Old English word "tcen," which
translates as "a sign or emblem." Transportation tokens, laundry tokens, and
arcade game tokens are privately issued coin-like things with negligible
intrinsic value.
6.1 Understanding The Concept of Tokens
Asset
A token may represent ownership of an intrinsic or extrinsic, tangible
or intangible asset, such as gold, real estate, a car, oil, energy, or
MMOG goods.
Access
A token can represent the right of access to a digital or physical asset,
such as a discussion forum, an exclusive website, a hotel room, or a
rental car.
Equity
A token may represent shareholder equity in a digital organization (for
example, a decentralized autonomous organization) or a legal entity
(for example, a corporation).
Voting
In a digital or judicial process, a token can reflect voting rights.
Collectible
A token might be digitally collectable (such as CryptoPunks) or
physically collectable (such as CryptoPunks) (such as a painting)
Identity
A token may represent a digital identity (such as an avatar) or a legal
identity (for example, a national ID).
Attestation
A token might represent an authority's verification or attestation of the
fact or a decentralized reputation system (for example, birth certificate,
a marriage record, or college degree).
Utility
Tokens can be used to pay or acquire access to services.
Frequently, many of these functions are merged into a single token.
It might be difficult to tell them apart at times because their physical
manifestations have always been tightly intertwined.
For example, a driver's license (attestation) doubles as an identity document
(identity) in the physical world, and the two are inextricably linked.
In the digital environment, formerly interwoven functions may be isolated
and developed separately (for example, anonymous attestation).
Tokens and Fungibility
The word "Intrinsic" is derived from the Latin word "intra," which means
"from inside." Certain tokens reflect digital assets intrinsic to blockchain
technology. Consensus rules regulate both these digital assets and the tokens
themselves. This has an important consequence: tokens representing intrinsic
assets are not exposed to additional counterparty risk. If you own the keys to
a CryptoKitty, no one else holds them for you—you directly own it.
Consensus rules from the blockchain apply, and your ownership (i.e., control)
of the private keys is equal to direct ownership of the asset. On the other
hand, many tokens represent extrinsic assets like real estate, voting shares in
corporations, trademarks, and gold bars. Ownership of these non-blockchain
assets is regulated by law, custom, and policy, which are different from the
consensus rules governing the token. In other words, token issuers and
owners may continue to use non-smart contracts.
As a result, because these extrinsic assets are maintained by custodians,
registered in external registries, and regulated by external laws and rules, they
introduce additional counterparty risk.
The capacity to transform extrinsic assets to intrinsic assets, eliminating
counterparty risk, is one of the most significant consequences of blockchain-
based tokens. An excellent example is transitioning from a corporation
(irrelevant) to equity or a voting token in a DAO or similar (intrinsic)
organization.
Tokens: Are They for Utility or Equity?
Today, almost all Ethereum projects begin with some form of token.
However, are tokens required for all of these projects? Are there any
disadvantages to employing a token, or is the motto "tokenize everything" a
possibility?
In principle, tokens might be the ultimate management or organizational tool.
In reality, the integration of blockchain platforms, such as Ethereum, into
established social systems has severely restricted their application thus far.
First, let us define the function of a token in a new project.
Tokens are often utilized in one of the two ways in most projects: "utility
tokens" or "equity tokens." Frequently, these two jobs are confused. Utility
tokens are required to access a service, application, or resource. Utility tokens
represent resources such as shared storage or access to services such as social
media networks. Equity tokens denote ownership or control of an entity, such
as a startup. Equity tokens can be as basic as nonvoting shares for dividends
and earnings distribution or as complicated as voting in a decentralized
autonomous organization. The platform is administered via a sophisticated
governance mechanism based on token holders' votes.
That is correct!
Numerous businesses have a problem: while tokens are a wonderful
instrument for fundraising, issuing securities (equity) to the general public is
a regulated activity in most nations.
Numerous firms intend to circumvent these legal limits by disguising equity
tokens as utility tokens and conducting a public offering under the guise of a
pre-sale of "service access vouchers," or utility tokens as we refer to them.
It remains to be seen if these sham equity offers can evade regulatory
scrutiny.
As the ancient adage goes, "If it walks and quacks like a duck, it is a duck."
Regulators are unlikely to be diverted by these semantic twists; rather, they
are more likely to view such legal ambiguity as an attempt to deceive the
public.
Tokens for Utility Tokens: Who Needs Them?
The issue is that utility tokens pose major risks and impediments to startup
adoption. Perhaps "tokenize everything" will become a reality in the far
future. Still, the set of individuals who understand and desire to utilize a
token is a subset of the already limited cryptocurrency market.
Each invention entails a degree of risk and serves as a market filter for a
business. Innovation entails breaking from established practices and choosing
the less-travelled path. Already, this is a lonely stroll. It is a lonely route for a
startup to take when attempting to innovate in a new technology field, such as
storage sharing via peer-to-peer networks. Adding a utility token to the
invention and asking users to adopt tokens to utilize the service, the risk is
compounded, and the adoption barriers are raised.
It deviates from the already isolated road of peer-to-peer storage innovation
and heads into the wilderness.
Consider each advancement as a filter.
It limits adoption to those segments of the market that can be early adopters
of the invention. This impact is exacerbated by adding a second filter, thus
restricting the addressable market. You are asking your early adopters to
embrace not one but two unique technologies: the novel
application/platform/service you invented and the token economy.
Each innovation carries risk, increasing the likelihood of the startup failing.
When you add a utility token to an existing high-risk firm, you add all of the
risks associated with the underlying platform (Ethereum), the larger economy
(exchanges, liquidity), the regulatory environment (equity and commodities
regulators), and technology (smart contracts, token standards). That is a huge
risk for a company.
Advocates of "tokenize everything" would almost certainly claim that they
will inherit the token economy's market fervor, early adopters, technology,
innovation, and liquidity by embracing tokens.
Additionally, this is right. The question is whether the benefits and
exhilaration of adventure exceed the risks and uncertainty. Nonetheless, the
crypto sphere is home to some of the most inventive business models.
Suppose regulators do not move swiftly enough to embrace new rules and
promote new business models. In that case, entrepreneurs and their associated
talent will seek to operate in more crypto-friendly countries.
Finally, when we explored tokens at the chapter's outset, we discussed the
common definition of "token" as "something of negligible value."
The fundamental reason for the low value of most tokens is that they are
limited to a single use: one bus company, one laundry, one arcade, one hotel,
or one corporate shop. Due to low liquidity, restricted application, and high
conversion fees, the value of tokens is reduced to "token" value.
When you include a utility token into your platform but restrict its use to your
single platform with a tiny market, you are re-creating the conditions that
rendered real tokens useless. This may be the optimal way for tokenization
integration in your project.
If, on the other hand, a user needs to change anything into your utility token
to utilize your platform and then convert the remaining back into something
more generally valuable, you have produced a corporate scrip.
While the switching costs of a digital token are orders of magnitude less than
those of a physical token with no market, they are not zero.
Utility tokens that may be utilized in various businesses will be quite
intriguing and, in all likelihood, pretty lucrative. However, if you founded
your business intending to bootstrap a whole industry-standard to flourish,
you may have already done so.
Without a token, a token cannot work. Adopt it because the token eliminates
a significant market barrier or resolves an access issue. Avoid using a utility
token since it is the only method to acquire funds swiftly, and you must
pretend that the offering is not a public securities offering.
6.2 The ERC20 Token
Before Ethereum, there were blockchain tokens. In some senses, Bitcoin, the
first blockchain money, is a token in and of itself. Numerous token platforms
were also established on Bitcoin and other cryptocurrencies before Ethereum.
However, adopting the first token standard on Ethereum resulted in a
proliferation of tokens.
Tokens are one of the most apparent and practical uses of a universal
programmable blockchain like Ethereum, according to Buterin. Indeed, it was
typical to see Vitalik and others wearing T-shirts with the Ethereum logo and
a sample smart contract on the back during Ethereum's first year. This T-shirt
came in various styles, but the most popular included a token
implementation. Before we go into the mechanics of producing tokens on
Ethereum, it is critical to understand how tokens function on the platform.
Tokens are distinct from ether in that the Ethereum protocol does not know of
them. While transmitting ether is a built-in feature of the Ethereum network,
sending or even possessing tokens is not. Ethereum accounts' ether balances
are managed at the protocol level, whilst their token balances are managed at
the smart contract level. To create a new token on Ethereum, you must first
create a new smart contract. Once implemented, the smart contract takes care
of everything, including ownership, transfers, and access permissions. You
may create your smart contract in any way you choose, but it is usually
prudent to adhere to an existing standard. Following that, we shall examine
such norms.
ERC20 Token Standard
The initial standard was proposed in November 2015 by Fabian Vogelsteller
as an Ethereum Request for Comments (ERC). It was immediately allocated
GitHub issue number 20, giving it the moniker "ERC20 token." Currently,
the great majority of tokens adhere to the ERC20 standard.
The ERC20 request for comments evolved into Ethereum Improvement
Proposal 20 (EIP-20). However, it is still commonly known by its original
designation, ERC20.
ERC20 is a standard for fungible tokens, which means that various units of
an ERC20 token are interchangeable and lack any unique attributes. The
ERC20 standard specifies a standardized interface for token-implemented
contracts that enables any compatible token to be accessed and used in the
same way.
The interface comprises several required functions and properties and certain
optional functions and attributes that developers may add.
ERC20-required functions and events
A token contract that is ERC20 complaint must provide the following
functions and events:
totalSupply
Returns the total number of units of this token that are presently in
existence.
ERC20 tokens can have a fixed or variable supply.
balanceOf
Returns the address's token balance when given an address.
transfer
Given an address and an amount, transfers that amount of tokens to that
address from the balance of the address that initiated the transfer.
transferfrom
It transfers tokens from one account to another given a sender, receiver,
and amount.
approve
When used in combination with approval, given a destination address
and an amount, it enables that address to execute numerous transfers up
to that amount from the account that issued the approval.
allowance
Returns the spender's remaining amount and is authorized to withdraw
from the owner given an owner address and a spender address.
Transfer
An event triggered on successful transfer (call to transfer or
transferFrom) (even for zero-value transfers).
Approval
An approval event is registered when a call to approve is successful.
For our scenario, we will use the OpenZeppelin framework, which has many
critical security tests and is extensible:
The optional variables title, symbols, and decimals are defined in this section.
Additionally, we establish an initialsupply variable with a value of 2.1 billion
tokens and subdivide it into two decimal places for a total of 2.1 billion units.
In the contract's activation (constructor) function, we adjust the totalSupply to
match the initialsupply and assign the full initialsupply to the sum of the
account (msg.sender) used to build the METOKEN contract.
We are now using truffle to build the METOKEN code.
Following that, let us verify our METoken balance and transfer some
METoken to some other address using the accounts generated by ganache. To
begin, let us obtain the account addresses:
The accounts list now includes all of the ganache's accounts, with account[0]
being the account that deployed the METoken contract. It should have a
METoken balance since our METoken constructor distributes the whole
token supply to the address that generated it. Let us verify:
Finally, use the contract's transfer function to send 1000.00 METoken from
account[0] to account[1].
As you can see, account[0] now has 20,999,000 MET, whereas account[1]
only has 1,000 MET.
Let us begin by compiling and migrating the contracts directly from the
Truffle console:
Great. Now, let us transfer a little amount of MET to the Faucet contract:
Accepted, 1,000 MET have been transferred to the Faucet contract. How do
we now get those tokens?
Remember, Faucet.
Sol is a rather straightforward contract. It has a single function, withdraws,
used to withdraw ether. It lacks a withdrawal option for MET or any other
ERC20 token. If we use it to withdraw, it will attempt to transmit ether but
fail due to the Faucet's lack of ether balance.
The METoken contract knows that Faucet has a balance, but it cannot
transfer that amount until it gets a transfer call from the contract's address.
We need to invoke the transfer method in METoken from the Faucet contract
somehow.
If you are unsure what to do next, refrain. There is no way to resolve this
issue. The MET sent to Faucet is permanently stuck. Only the Faucet contract
can transfer it, and the Faucet contract lacks the code necessary to invoke an
ERC20 token contract's transfer function.
Perhaps you foresaw this issue. Almost certainly, you did not. Indeed, neither
did hundreds of Ethereum users who transferred different tokens mistakenly
to contracts that lacked ERC20 functionality. According to some estimations,
tokens worth over USD 2.5 billion (at the time of writing) have been "stuck"
in this manner and are now permanently gone.
One possibility for ERC20 tokens to lose their tokens mistakenly during a
transfer is when they try to move to exchange or another service. They copy
an Ethereum address from an exchange's website, mistakenly believing that
they may transfer tokens to it directly. On the other hand, numerous
exchanges advertise receiving addresses that are genuine contracts! These
contracts are designed to accept only ether, not ERC20 tokens, and often
sweep all monies received to "cold storage" or another controlled wallet.
Despite several cautions to "do not transfer tokens to this address," many
tokens are lost in this manner.
We have modified the simple Faucet example quite a bit. METFaucet will
need two more variables due to its usage of the transferFrom function in
METoken. One will include the address of the METoken contract that has
been deployed. The other will have the owner of the MET's address, who will
allow faucet withdrawals. METFaucet will invoke METoken.transferFrom
and order it to transfer MET from the owner to the address associated with
the faucet withdrawal request.
These two variables are declared here:
Since our faucet must be initialized with the necessary METoken and
METOwner addresses, we must define a custom constructor:
After completing the METFaucet.sol code, we will need to alter the migration
script to deploy it. This migration script will be a little more involved since
METFaucet is dependent on the METoken address. We will utilize a
JavaScript promise to deploy the two contracts sequentially. Create the
following file: 2 deploy contracts.js
All of the token standards examined so far are fungible, implying that token
units are interchangeable. The ERC20 token standard tracks just the final
balance of each account and does not track (explicitly) the origin of every
token. ERC721 is a standard for non-fungible tokens, commonly referred to
as deeds.
According to the Oxford Dictionary, a deed is a legally binding document
that has been signed and delivered, typically relating to property ownership
or legal rights. The term "deed" is used to represent "property ownership,"
even though they are not yet considered "legal papers" in any state.
Legal ownership based on digital signatures on a blockchain network is likely
to be recognized legally at some time in the future. Tokens that are not
fungible are used to track ownership of one-of-a-kind items. The thing
possessed can be a digital item, such as an in-game item or digital collectable,
or a physical item, such as a house, a car, or an artwork, the ownership of
which is tracked by a token. Deeds can also represent loans (debt), liens,
easements, and other objects with a negative value.
The ERC721 standard imposes no constraints or expectations on the nature of
the item whose ownership is tracked by a deed. It simply requires to be
uniquely recognized, which is achieved via a 256-bit identification in this
standard.
The information and discussion of the standard are maintained in two
locations on GitHub:
Initial proposition
Continued discussion
To see the essential distinction between ERC20 and ERC721, examine the
ERC721 internal data structure:
ERC721 keeps track of each deed ID and who owns it, in contrast to ERC20,
which keeps track of each owner's balances, with the owner serving as the
main key for the mapping.
All of the non-fungible token's attributes come from this basic distinction.
ERC721's contract interface standard is as follows:
Select the WalletConnect option on the next page if you are using the
Rainbow or Metamask wallets. If you are using Coinbase Wallet, click on
WalletLink. Numerous other wallets are also supported by these connection
options. Therefore, it is worthwhile to investigate each to see whether your
favorite wallet is compatible.
Your connection method is determined by the wallet you are using.
Whichever wallet you are using; the following step is nearly same. Following
your selection of a connecting method, a QR code will show on the screen.
Scan this code with your wallet app. Once the code has been read, indicate
that you want to link your wallet to Rarible.
To get started with Rarible, scan the QR code in your wallet app and press
connect.
This is a secure connection, and Rarible will always need confirmation of
purchases via your wallet app before proceeding. Your Rarible account is
quickly created after linking a wallet. You now own all of the necessary
components for creating, minting, and selling your first NFT.
Where can I sell NFTs?
New NFT markets are springing up on a regular basis as the technology's
popularity grows. In this part, we will go through a few of the most popular
online marketplaces and analyze how each one differs from the others, so you
can make a better educated choice on where to offer your first NFT.
Zora
Rarible is one of the most user-friendly platforms for creators and collectors
interested in NFTs. This was the first site I used when I originally began, and
the platform makes submitting content and creating an NFT as easy as
sharing a YouTube video. In a market dominated by invite-only platforms,
Rarible is one of the few NFT platforms that enable new creators to begin
selling their work as soon as they join up. This openness results in a jumble
of content on the site, and the service's monitoring of copyrighted and
objectionable uploads should be better. Work on the site sells for a broad
range of prices, from a few dollars to tens of thousands of dollars.
SuperRare
The NFT marketplace for digital artists is SuperRare's claim to fame. Memes,
text postings, and basic sound effects are not for sale here. SuperRare's
portfolio is carefully managed, and the company has taken a deliberate
approach to onboarding new creators. As a consequence, viewing SuperRare
is like entering an exclusive digital gallery. The site has a wonderful
collection of NFTs that represent hundreds of hours of work by artists. Prices
may be rather high, and new creators are only approved after submitting an
application.
Nifty Gateway
Ownership authority
The ability to endow single addresses or groups of addresses with
additional capabilities (i.e., multisignature schemes), such as
blacklisting, whitelisting, minting, and recovery.
Burning
The capacity to destroy ("burn") tokens on purpose, either by moving
them to an unspendable address or erasing a balance and lowering
supply.
Minting
The ability to increase the overall quantity of tokens at a specified pace
or using the creator's "fiat."
Crowdfunding
The ability to sell tokens by auction, market sale, or reverse auction,
among other methods.
Recovery through backdoors
Functions to reverse transfers, recover funds, or deactivate the token
that can be activated by a certain address or group of addresses.
Whitelisting
The ability to restrict activities to certain addresses (for example, token
transfers). Most frequently, it is used to provide tokens to "accredited
investors" after being verified following local regulations. Typically,
there is a mechanism for maintaining the whitelist.
Blacklisting
The ability to restrict token transfers by specifying particular addresses
to be excluded. Typically, a method is provided for updating the
blacklist.
These numerous functions are implemented in reference libraries, such
as the OpenZeppelin library. Several of them are case–sensitive and
appear in only a few tokens. There are currently no widely agreed
standards for these functions' interfaces. As previously stated, the
option to extend a token standard's capabilities constitutes a trade-off
between innovation and risk, as well as interoperability and security.
Tokens and Initial Coin Offerings
Tokens have become an increasingly important component of the Ethereum
ecosystem. They are almost certain to become a necessary component of all
smart contract platforms, including Ethereum. However, the relevance and
potential influence of these standards should not be seen as an endorsement
of present token offers.
As with early-stage technology, the initial wave of goods and firms will
almost always fail, and some will fail miserably.
Numerous tokens accessible on Ethereum are glaringly evident frauds,
pyramid schemes, and money grabs. The difficulty is to discern between the
technology's long-term vision and influence, which are almost certain to be
massive, and the short-term bubble of token ICOs, which is plagued with
deception. Token standards and the platform will very certainly survive the
current token bubble and then alter the course of human history.
In Ethereum, tokens are a strong notion that may serve as the foundation for
many significant decentralized applications.
Conclusion