SlideShare a Scribd company logo
Tokens
Based on:
Mastering Ethereum: Building Smart Contracts and DApps
What Is a Token?
• The term is commonly used to refer to privately issued
special-purpose coin-like items of insignificant intrinsic
value (
‫حقيقيه‬ ‫قيمه‬ ‫بدون‬
) , such as transportation tokens,
laundry tokens, and arcade game tokens.
• Physical versions of tokens are often restricted to specific
businesses, organizations, or locations.
• There are not easily exchangeable and typically have only
one function.
Blockchain Token
• The restrictions of physical tokens are not exist any more
• Blockchain tokens serve multiple purposes and can be traded for each
other or for other currencies on global liquid markets
• Generally speaking, a token represents something specific in a given
ecosystem
• This could be could economic value, a dividend, a voting right… really anything.
• Token is not limited to one particular role; it can fulfill various different of roles
in its native ecosystem.
• Tokens are a great fundraising mechanism
How Tokens Are Used
• Tokens can be programmed to serve many different functions
• Currency
• A token can serve as a form of currency, with a value determined through private trade.
• Resource
• A token can represent a resource earned or produced in a sharing economy or resource-
sharing environment; for example, a storage or CPU token representing resources that can be
shared over a network
• Asset
• A token can represent ownership of an intrinsic or extrinsic, tangible or intangible asset; for
example, gold, real estate, a car, oil, energy, etc.
• Access
• A token can represent access rights and grant access to a digital or physical property, such as a
discussion forum, an exclusive website, a hotel room, or a rental car.
• Equity (
‫الملكيه‬ ‫حقوق‬
)
• A token can represent shareholder equity in a digital organization
• e.g. Decentralized Autonomous Organization (DAO), placing decision-making power into the
hands of an automated system and a crowdsourced process.
How Tokens Are Used
• Voting
• A token can represent voting rights in a digital or legal system.
• Collectible
• A token can represent a digital collectible (e.g., CryptoPunks) or physical collectible (e.g., a
painting).
• Identity
• A token can represent a digital identity (e.g., avatar) or legal identity (e.g. national ID).
• Attestation
• A token can represent a certification or attestation of fact by some authority or by a
decentralized reputation system (e.g., marriage record, birth certificate, college degree).
• Utility
• A token can be used to access or pay for a service.
Tokens and Fungibility(‫التبادل‬ ‫)قابليه‬
• Tokens are fungible when we can substitute any single unit of the token for
another without any difference in its value or function.
• If a token’s historical provenance can be tracked, then it is not entirely
fungible
• The ability to track provenance can lead to blacklisting and whitelisting, reducing or
eliminating fungibility.
• Non-fungible tokens are tokens that each represent a unique tangible or
intangible item and therefore are not interchangeable
• E.g . a token that represents ownership of a specific Van Gogh painting is not
equivalent to another token that represents a Picasso, even though they might be
part of the same “art ownership token” system
• Each non-fungible token is associated with a unique identifier, such as a
serial number.
Tokens and Intrinsicality
• Tokens that represent intrinsic assets do not carry additional counterparty risk
• If you hold the keys for a CryptoKitty, there is no other party holding that CryptoKitty for you—you own
it directly
• The blockchain consensus rules apply and your ownership (i.e., control) of the private keys is equivalent
to ownership of the asset, without any intermediary
• Conversely, many tokens are used to represent extrinsic things, such as real estate, and gold
bars
• The ownership of these items, which are not “within” the blockchain, is governed by law, and policy,
separate from the consensus rules that govern the token
• Token issuers and owners may still depend on real-world non-smart contracts
• These extrinsic assets carry additional counterparty risk because they are held by custodians, recorded in
external registries, or controlled by laws and policies outside the blockchain environment.
• Blockchain tokens may be used to convert extrinsic assets into intrinsic assets and thereby
remove counterparty risk
• E.g. A good example is moving from equity in a corporation (extrinsic) to an equity or voting token in a
DAO or similar (intrinsic) organization
Using Tokens: Utility or Equity
• Almost all projects in Ethereum today launch with some kind of token.
• Tokens are used one of two ways: either as “utility tokens” or as “equity tokens.”
• Utility tokens are those where the use of the token is required to gain
access to a service, application, or resource
• E.g. tokens that represent resources such as shared storage, or access to services
such as social media networks.
• Equity tokens are those that represent shares in the control or ownership
of something, such as a startup
• E.g nonvoting shares for distribution of dividends and profits, or voting shares in a
decentralized autonomous organization, where complex governance system based
on votes by the token holders.
Tokens on Ethereum
• Tokens are different from ether because the Ethereum protocol does not
know anything about them
• Sending ether is an intrinsic action of the Ethereum platform, but sending
or even owning tokens is not
• The ether balance of Ethereum accounts is handled at the protocol level,
whereas the token balance of Ethereum accounts is handled at the smart
contract level
• In order to create a new token on Ethereum, you must create a new smart
contract
• Smart contract handles everything, including ownership, transfers, and access rights
• You can write your smart contract to perform all the necessary actions any way you
want, but it is probably wisest to follow an existing standard.
An Initial Coin Offering (ICO)
• Is a crowdfunding mechanism used by companies and organizations
to raise money by selling tokens.
• The term is derived from Initial Public Offering (IPO), which is the
process by which a public company offers shares for sale to investors
on a stock exchange
• Unlike the highly regulated IPO markets, ICOs are open, global, and
messy
The ERC20 Token Standard
• Ethereum Request for Comments (ERC)
• The vast majority of tokens are currently based on the ERC20 standard
• ERC20 is a standard for fungible tokens
• ERC20 token are interchangeable and have no unique properties.
• It defines a common interface for contracts implementing a token, such
that any compatible token can be accessed and used in the same way.
• The interface consists of a number of functions that must be present in every
implementation of the standard
ERC20 required functions and events (1/2)
• totalSupply
• Returns the total units of this token that currently exist
• ERC20 tokens can have a fixed or a variable supply.
• balanceOf
• Given an address, returns the token balance of that address.
• transfer
• Given an address and amount, transfers that amount of tokens to that address,
from the balance of the address that executed the transfer.
• transferFrom
• Given a sender, recipient, and amount, transfers tokens from one account to
another
• Used in combination with approve.
ERC20 required functions and events (2/2)
• approve
• Given a recipient address and amount, authorizes that address to execute several
transfers up to that amount, from the account that issued the approval.
• allowance
• Given an owner address and a spender address, returns the remaining amount
that the spender is approved to withdraw from the owner.
• Transfer
• Event triggered upon a successful transfer (call to transfer or transferFrom) (even
for zero-value transfers).
• Approval
• Event logged upon a successful call to approve.
ERC20 optional functions
• name
• Returns the human-readable name (e.g., “US Dollars”) of the token.
• symbol
• Returns a human-readable symbol (e.g., “USD”) for the token.
• decimals
• Returns the number of decimals used to divide token amounts
• E.g, if decimals is 2, then the token amount is divided by 100 to get its user
representation.
The ERC20 interface defined in Solidity
contract ERC20 {
function totalSupply() constant returns (uint theTotalSupply);
function balanceOf(address _owner) constant returns (uint balance);
function transfer(address _to, uint _value) returns (bool success);
function transferFrom(address _from, address _to, uint _value) returns (bool success);
function approve(address _spender, uint _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint remaining);
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}
ERC20 data structures
• It uses two data structures that is implemented with a data mapping
• One to track balances
• This allows the token contract to keep track of who owns the tokens
• Each transfer is adeduction from one balance and an addition to another balance
mapping(address => uint256) balances;
• And the other to track allowances
• An owner of a token can delegate authority to a spender, allowing them to spend a
specific amount (allowance) from the owner’s balance
mapping (address => mapping (address => uint256)) public allowed;
ERC20 two different workflows
“transfer” and “approve & transferFrom”
• transfer
• Is used by wallets to send tokens to other wallets.
• If Alice wants to send 10 tokens to Bob, her wallet sends a transaction to the token
contract’s address, calling the transfer function with Bob’s address and 10 as the
arguments.
• The token contract adjusts Alice’s balance (–10) and Bob’s balance (+10) and issues a
Transfer event.
• approve followed , transferFrom
• Are used to delegate control to another address for distribution of tokens
• E.g, if a company is selling tokens for an ICO, they can approve a crowdsale contract
address to distribute a certain amount of tokens. The crowdsale contract can then
transferFrom the token contract owner’s balance to each buyer of the token
“approve & transferFrom” workflows
“approve & transferFrom” workflows
• If Alice wants to allow the AliceICO contract to sell 50% of all the AliceCoin
tokens to buyers like Bob and Charlie.
• First, Alice launches the AliceCoin ERC20 contract, issuing all the AliceCoin to her own
address.
• Then, Alice launches the AliceICO contract that can sell tokens for ether.
• Next, Alice initiates the approve & transferFrom workflow.(How?)
• She sends a transaction to the AliceCoin contract, calling approve with the address of the AliceICO contract and
50% of the totalSupply as arguments.
• This will trigger the Approval event. Now, the AliceICO contract can sell AliceCoin.
• When the AliceICO contract receives ether from Bob, it needs to send some AliceCoin to Bob in return.
• AliceICO contract calls the AliceCoin transfer From function, it sets Alice’s address as the sender and Bob’s
address as the recipient
• The AliceCoin contract transfers the balance from Alice’s address to Bob’s address and triggers a Transfer event.
• The AliceICO contract can call transferFrom an unlimited number of times, as long as it doesn’t exceed the
approval limit Alice set.
• The AliceICO contract can keep track of how many AliceCoin tokens it can sell by calling the allowance function.
4) Bob send ether and request tokens
(100 token for example)
5) AliceICO Call transfereFrom where,
address of AliceCoinERC20 as _from
address of Bob as _to
100 token as _value
contract AliceICO{
// This contract will be delegated by Alice to distribute tokens …..
function RequestTokens() public payable {}…..
}
2) Deploy AliceICO contract
contract AliceCoinERC20{
constructor(){
//Assigne all tokens to Alice }
…….
…….
function totalSupply() constant
returns (uint theTotalSupply);
function balanceOf(address _owner) constant
returns (uint balance);
function transfer(address _to, uint _value)
returns (bool success);
function approve(address _spender, uint _value) returns
(bool success);
function allowance(address _owner, address _spender) constant
returns (uint remaining);
function transferFrom(address _from, address _to, uint _value)
returns (bool success);
}
1) Deploy the contract and
Assign all tokens to Alice
https://github.com/ConsenSys/Tok
ens/blob/master/contracts/eip20/
EIP20.sol
ERC20 Implementation example

More Related Content

Similar to Tokens 10.pptx

Create your own token
Create your own tokenCreate your own token
Create your own token
shira william
 
Distributed exchanges
Distributed exchangesDistributed exchanges
Distributed exchanges
Didier Martin
 
Cryptocurrencies and ICOs
Cryptocurrencies and ICOsCryptocurrencies and ICOs
Cryptocurrencies and ICOs
Mikko Alasaarela
 
Features to required create erc 20
Features to required create erc 20 Features to required create erc 20
Features to required create erc 20
Alladin Nasir
 
Ethereum: Native Currency and Token
Ethereum: Native Currency and TokenEthereum: Native Currency and Token
Ethereum: Native Currency and Token
KC Tam
 
What Are Crypto Tokens & How Crypto Tokens Work?
What Are Crypto Tokens & How Crypto Tokens Work?What Are Crypto Tokens & How Crypto Tokens Work?
What Are Crypto Tokens & How Crypto Tokens Work?
Blockchain Council
 
Blockchain and Cryptocurrencies
Blockchain and CryptocurrenciesBlockchain and Cryptocurrencies
Blockchain and Cryptocurrencies
nimeshQ
 
Decentralised Exchanges - An Introduction
Decentralised Exchanges - An IntroductionDecentralised Exchanges - An Introduction
Decentralised Exchanges - An Introduction
Priyab Satoshi
 
blockchain technology note-unit-5-notes.pdf for sppu engineering students
blockchain technology note-unit-5-notes.pdf for sppu engineering studentsblockchain technology note-unit-5-notes.pdf for sppu engineering students
blockchain technology note-unit-5-notes.pdf for sppu engineering students
imranakhtar83
 
Ethereum
EthereumEthereum
Ethereum
V C
 
What Are Crypto Tokens
What Are Crypto TokensWhat Are Crypto Tokens
What Are Crypto Tokens
DIFXCrypto
 
Restribute ~ Wealth re-distirbution by blockchain hardfork ~
Restribute ~ Wealth re-distirbution by blockchain hardfork ~ Restribute ~ Wealth re-distirbution by blockchain hardfork ~
Restribute ~ Wealth re-distirbution by blockchain hardfork ~
Tomoaki Sato
 
Erc 721 tokens
Erc 721 tokensErc 721 tokens
Erc 721 tokens
Priyab Satoshi
 
blockchain bootcamp @WCNJ
blockchain bootcamp @WCNJblockchain bootcamp @WCNJ
blockchain bootcamp @WCNJ
Ash Yadav
 
Block chain - Smart contacts.pptx
Block chain - Smart contacts.pptxBlock chain - Smart contacts.pptx
Block chain - Smart contacts.pptx
shraddhaphirke1
 
Cryptocurrency.pptx
Cryptocurrency.pptxCryptocurrency.pptx
Cryptocurrency.pptx
Pullingo1
 
Token model design
Token model designToken model design
Token model design
Reyan Lamrani
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Codemotion
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Codemotion
 
What is Ethereum? – A Complete Guide to Ethereum for Beginners
What is Ethereum? – A Complete Guide to Ethereum for BeginnersWhat is Ethereum? – A Complete Guide to Ethereum for Beginners
What is Ethereum? – A Complete Guide to Ethereum for Beginners
CoinGape
 

Similar to Tokens 10.pptx (20)

Create your own token
Create your own tokenCreate your own token
Create your own token
 
Distributed exchanges
Distributed exchangesDistributed exchanges
Distributed exchanges
 
Cryptocurrencies and ICOs
Cryptocurrencies and ICOsCryptocurrencies and ICOs
Cryptocurrencies and ICOs
 
Features to required create erc 20
Features to required create erc 20 Features to required create erc 20
Features to required create erc 20
 
Ethereum: Native Currency and Token
Ethereum: Native Currency and TokenEthereum: Native Currency and Token
Ethereum: Native Currency and Token
 
What Are Crypto Tokens & How Crypto Tokens Work?
What Are Crypto Tokens & How Crypto Tokens Work?What Are Crypto Tokens & How Crypto Tokens Work?
What Are Crypto Tokens & How Crypto Tokens Work?
 
Blockchain and Cryptocurrencies
Blockchain and CryptocurrenciesBlockchain and Cryptocurrencies
Blockchain and Cryptocurrencies
 
Decentralised Exchanges - An Introduction
Decentralised Exchanges - An IntroductionDecentralised Exchanges - An Introduction
Decentralised Exchanges - An Introduction
 
blockchain technology note-unit-5-notes.pdf for sppu engineering students
blockchain technology note-unit-5-notes.pdf for sppu engineering studentsblockchain technology note-unit-5-notes.pdf for sppu engineering students
blockchain technology note-unit-5-notes.pdf for sppu engineering students
 
Ethereum
EthereumEthereum
Ethereum
 
What Are Crypto Tokens
What Are Crypto TokensWhat Are Crypto Tokens
What Are Crypto Tokens
 
Restribute ~ Wealth re-distirbution by blockchain hardfork ~
Restribute ~ Wealth re-distirbution by blockchain hardfork ~ Restribute ~ Wealth re-distirbution by blockchain hardfork ~
Restribute ~ Wealth re-distirbution by blockchain hardfork ~
 
Erc 721 tokens
Erc 721 tokensErc 721 tokens
Erc 721 tokens
 
blockchain bootcamp @WCNJ
blockchain bootcamp @WCNJblockchain bootcamp @WCNJ
blockchain bootcamp @WCNJ
 
Block chain - Smart contacts.pptx
Block chain - Smart contacts.pptxBlock chain - Smart contacts.pptx
Block chain - Smart contacts.pptx
 
Cryptocurrency.pptx
Cryptocurrency.pptxCryptocurrency.pptx
Cryptocurrency.pptx
 
Token model design
Token model designToken model design
Token model design
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
 
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
Jerome de Tychey - Building Web3.0 with Ethereum - Codemotion Berlin 2018
 
What is Ethereum? – A Complete Guide to Ethereum for Beginners
What is Ethereum? – A Complete Guide to Ethereum for BeginnersWhat is Ethereum? – A Complete Guide to Ethereum for Beginners
What is Ethereum? – A Complete Guide to Ethereum for Beginners
 

Recently uploaded

Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 

Recently uploaded (20)

Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 

Tokens 10.pptx

  • 1. Tokens Based on: Mastering Ethereum: Building Smart Contracts and DApps
  • 2. What Is a Token? • The term is commonly used to refer to privately issued special-purpose coin-like items of insignificant intrinsic value ( ‫حقيقيه‬ ‫قيمه‬ ‫بدون‬ ) , such as transportation tokens, laundry tokens, and arcade game tokens. • Physical versions of tokens are often restricted to specific businesses, organizations, or locations. • There are not easily exchangeable and typically have only one function.
  • 3. Blockchain Token • The restrictions of physical tokens are not exist any more • Blockchain tokens serve multiple purposes and can be traded for each other or for other currencies on global liquid markets • Generally speaking, a token represents something specific in a given ecosystem • This could be could economic value, a dividend, a voting right… really anything. • Token is not limited to one particular role; it can fulfill various different of roles in its native ecosystem. • Tokens are a great fundraising mechanism
  • 4. How Tokens Are Used • Tokens can be programmed to serve many different functions • Currency • A token can serve as a form of currency, with a value determined through private trade. • Resource • A token can represent a resource earned or produced in a sharing economy or resource- sharing environment; for example, a storage or CPU token representing resources that can be shared over a network • Asset • A token can represent ownership of an intrinsic or extrinsic, tangible or intangible asset; for example, gold, real estate, a car, oil, energy, etc. • Access • A token can represent access rights and grant access to a digital or physical property, such as a discussion forum, an exclusive website, a hotel room, or a rental car. • Equity ( ‫الملكيه‬ ‫حقوق‬ ) • A token can represent shareholder equity in a digital organization • e.g. Decentralized Autonomous Organization (DAO), placing decision-making power into the hands of an automated system and a crowdsourced process.
  • 5. How Tokens Are Used • Voting • A token can represent voting rights in a digital or legal system. • Collectible • A token can represent a digital collectible (e.g., CryptoPunks) or physical collectible (e.g., a painting). • Identity • A token can represent a digital identity (e.g., avatar) or legal identity (e.g. national ID). • Attestation • A token can represent a certification or attestation of fact by some authority or by a decentralized reputation system (e.g., marriage record, birth certificate, college degree). • Utility • A token can be used to access or pay for a service.
  • 6. Tokens and Fungibility(‫التبادل‬ ‫)قابليه‬ • Tokens are fungible when we can substitute any single unit of the token for another without any difference in its value or function. • If a token’s historical provenance can be tracked, then it is not entirely fungible • The ability to track provenance can lead to blacklisting and whitelisting, reducing or eliminating fungibility. • Non-fungible tokens are tokens that each represent a unique tangible or intangible item and therefore are not interchangeable • E.g . a token that represents ownership of a specific Van Gogh painting is not equivalent to another token that represents a Picasso, even though they might be part of the same “art ownership token” system • Each non-fungible token is associated with a unique identifier, such as a serial number.
  • 7. Tokens and Intrinsicality • Tokens that represent intrinsic assets do not carry additional counterparty risk • If you hold the keys for a CryptoKitty, there is no other party holding that CryptoKitty for you—you own it directly • The blockchain consensus rules apply and your ownership (i.e., control) of the private keys is equivalent to ownership of the asset, without any intermediary • Conversely, many tokens are used to represent extrinsic things, such as real estate, and gold bars • The ownership of these items, which are not “within” the blockchain, is governed by law, and policy, separate from the consensus rules that govern the token • Token issuers and owners may still depend on real-world non-smart contracts • These extrinsic assets carry additional counterparty risk because they are held by custodians, recorded in external registries, or controlled by laws and policies outside the blockchain environment. • Blockchain tokens may be used to convert extrinsic assets into intrinsic assets and thereby remove counterparty risk • E.g. A good example is moving from equity in a corporation (extrinsic) to an equity or voting token in a DAO or similar (intrinsic) organization
  • 8. Using Tokens: Utility or Equity • Almost all projects in Ethereum today launch with some kind of token. • Tokens are used one of two ways: either as “utility tokens” or as “equity tokens.” • Utility tokens are those where the use of the token is required to gain access to a service, application, or resource • E.g. tokens that represent resources such as shared storage, or access to services such as social media networks. • Equity tokens are those that represent shares in the control or ownership of something, such as a startup • E.g nonvoting shares for distribution of dividends and profits, or voting shares in a decentralized autonomous organization, where complex governance system based on votes by the token holders.
  • 9. Tokens on Ethereum • Tokens are different from ether because the Ethereum protocol does not know anything about them • Sending ether is an intrinsic action of the Ethereum platform, but sending or even owning tokens is not • The ether balance of Ethereum accounts is handled at the protocol level, whereas the token balance of Ethereum accounts is handled at the smart contract level • In order to create a new token on Ethereum, you must create a new smart contract • Smart contract handles everything, including ownership, transfers, and access rights • You can write your smart contract to perform all the necessary actions any way you want, but it is probably wisest to follow an existing standard.
  • 10. An Initial Coin Offering (ICO) • Is a crowdfunding mechanism used by companies and organizations to raise money by selling tokens. • The term is derived from Initial Public Offering (IPO), which is the process by which a public company offers shares for sale to investors on a stock exchange • Unlike the highly regulated IPO markets, ICOs are open, global, and messy
  • 11. The ERC20 Token Standard • Ethereum Request for Comments (ERC) • The vast majority of tokens are currently based on the ERC20 standard • ERC20 is a standard for fungible tokens • ERC20 token are interchangeable and have no unique properties. • It defines a common interface for contracts implementing a token, such that any compatible token can be accessed and used in the same way. • The interface consists of a number of functions that must be present in every implementation of the standard
  • 12. ERC20 required functions and events (1/2) • totalSupply • Returns the total units of this token that currently exist • ERC20 tokens can have a fixed or a variable supply. • balanceOf • Given an address, returns the token balance of that address. • transfer • Given an address and amount, transfers that amount of tokens to that address, from the balance of the address that executed the transfer. • transferFrom • Given a sender, recipient, and amount, transfers tokens from one account to another • Used in combination with approve.
  • 13. ERC20 required functions and events (2/2) • approve • Given a recipient address and amount, authorizes that address to execute several transfers up to that amount, from the account that issued the approval. • allowance • Given an owner address and a spender address, returns the remaining amount that the spender is approved to withdraw from the owner. • Transfer • Event triggered upon a successful transfer (call to transfer or transferFrom) (even for zero-value transfers). • Approval • Event logged upon a successful call to approve.
  • 14. ERC20 optional functions • name • Returns the human-readable name (e.g., “US Dollars”) of the token. • symbol • Returns a human-readable symbol (e.g., “USD”) for the token. • decimals • Returns the number of decimals used to divide token amounts • E.g, if decimals is 2, then the token amount is divided by 100 to get its user representation.
  • 15. The ERC20 interface defined in Solidity contract ERC20 { function totalSupply() constant returns (uint theTotalSupply); function balanceOf(address _owner) constant returns (uint balance); function transfer(address _to, uint _value) returns (bool success); function transferFrom(address _from, address _to, uint _value) returns (bool success); function approve(address _spender, uint _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint remaining); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); }
  • 16. ERC20 data structures • It uses two data structures that is implemented with a data mapping • One to track balances • This allows the token contract to keep track of who owns the tokens • Each transfer is adeduction from one balance and an addition to another balance mapping(address => uint256) balances; • And the other to track allowances • An owner of a token can delegate authority to a spender, allowing them to spend a specific amount (allowance) from the owner’s balance mapping (address => mapping (address => uint256)) public allowed;
  • 17. ERC20 two different workflows “transfer” and “approve & transferFrom” • transfer • Is used by wallets to send tokens to other wallets. • If Alice wants to send 10 tokens to Bob, her wallet sends a transaction to the token contract’s address, calling the transfer function with Bob’s address and 10 as the arguments. • The token contract adjusts Alice’s balance (–10) and Bob’s balance (+10) and issues a Transfer event. • approve followed , transferFrom • Are used to delegate control to another address for distribution of tokens • E.g, if a company is selling tokens for an ICO, they can approve a crowdsale contract address to distribute a certain amount of tokens. The crowdsale contract can then transferFrom the token contract owner’s balance to each buyer of the token
  • 19. “approve & transferFrom” workflows • If Alice wants to allow the AliceICO contract to sell 50% of all the AliceCoin tokens to buyers like Bob and Charlie. • First, Alice launches the AliceCoin ERC20 contract, issuing all the AliceCoin to her own address. • Then, Alice launches the AliceICO contract that can sell tokens for ether. • Next, Alice initiates the approve & transferFrom workflow.(How?) • She sends a transaction to the AliceCoin contract, calling approve with the address of the AliceICO contract and 50% of the totalSupply as arguments. • This will trigger the Approval event. Now, the AliceICO contract can sell AliceCoin. • When the AliceICO contract receives ether from Bob, it needs to send some AliceCoin to Bob in return. • AliceICO contract calls the AliceCoin transfer From function, it sets Alice’s address as the sender and Bob’s address as the recipient • The AliceCoin contract transfers the balance from Alice’s address to Bob’s address and triggers a Transfer event. • The AliceICO contract can call transferFrom an unlimited number of times, as long as it doesn’t exceed the approval limit Alice set. • The AliceICO contract can keep track of how many AliceCoin tokens it can sell by calling the allowance function.
  • 20. 4) Bob send ether and request tokens (100 token for example) 5) AliceICO Call transfereFrom where, address of AliceCoinERC20 as _from address of Bob as _to 100 token as _value contract AliceICO{ // This contract will be delegated by Alice to distribute tokens ….. function RequestTokens() public payable {}….. } 2) Deploy AliceICO contract contract AliceCoinERC20{ constructor(){ //Assigne all tokens to Alice } ……. ……. function totalSupply() constant returns (uint theTotalSupply); function balanceOf(address _owner) constant returns (uint balance); function transfer(address _to, uint _value) returns (bool success); function approve(address _spender, uint _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint remaining); function transferFrom(address _from, address _to, uint _value) returns (bool success); } 1) Deploy the contract and Assign all tokens to Alice

Editor's Notes

  1. https://coinmarketcap.com/tokens/views/all/