Homework: ERC20

  1. All participants in the ecosystem will be able to speak the same language.

The specific wording of the function is followed by a clarification of what it does, in square brackets.

  • totalSupply() public view returns (uint256 totalSupply) [Get the total token supply]
  • balanceOf(address _owner) public view returns (uint256 balance) [Get the account balance of another account with address _owner ]
  • transfer(address _to, uint256 _value) public returns (bool success) [Send _value amount of tokens to address _to ]
  • transferFrom(address _from, address _to, uint256 _value) public returns (bool success) [Send _value amount of tokens from address _from to address _to ]
  • approve(address _spender, uint256 _value) public returns (bool success) [Allow _spender to withdraw from your account, multiple times, up to the _value amount. If this function is called again it overwrites the current allowance with _value ]
  • allowance(address _owner, address _spender) public view returns (uint256 remaining) [Returns the amount which _spender is still allowed to withdraw from _owner ]

Events format:

  • Transfer(address indexed _from, address indexed _to, uint256 _value) . [Triggered when tokens are transferred.]
  • Approval(address indexed _owner, address indexed _spender, uint256 _value) [Triggered whenever approve(address _spender, uint256 _value) is called.]

(SOURCE: https://en.wikipedia.org/wiki/ERC-20)

3 Likes
  1. What are the benefits of setting a token standard like ERC20?
    ERC20 Standardisation creates commonality of design and interaction which in turn leads to efficiency and predictability and greater adoption within the industry.

  2. What functions are in the ERC20 Token Standard Interface and what do they do? The key standardised functions in an ERC20 token are: Contract Address, Total Supply of tokens, the name, symbol & number of decimal places. In addition the standard protocol allows for transfer of tokens by way of transfer(), approve() & transferfrom().

2 Likes
  1. Token standards allow applications and exchanges to be completable with all tokens using a particular standard.

balanceOf - “This function allows a smart contract to store and return the balance of the provided address”
totalSupply - “this function allows an instance of the contract to calculate and return the total amount of the token that exists in circulation.”
transfer - “This function lets the owner of the contract send a given amount of the token to another address just like a conventional cryptocurrency transaction.”
transferFrom - “This function allows a smart contract to automate the transfer process and send a given amount of the token on behalf of the owner.”
approve - " When calling this function, the owner of the contract authorizes, or approves , the given address to withdraw instances of the token from the owner’s address."
(Source: https://medium.com/blockchannel/the-anatomy-of-erc20-c9e5c5ff1d02)
allowance - " Returns the amount which _spender is still allowed to withdraw from _owner"
(Source: https://en.wikipedia.org/wiki/ERC-20#Technical_standard )

2 Likes
  1. Token standards allow all wallets and exchanges which are set up to support a token standard to accept all tokens which respect the token standard
  2. totalSupply function returns total supply of token
    balanceOf function returns token balance of wallet address
    transfer function transfers tokens from token owner account to account
    allowance function returns the amount of tokens approved by the owner that can be
    transferred to the spender’s account
    approve function allows the token owner to approve for spender to transferFrom tokens
    from the token owner’s account
    transferFrom transfers tokens from account to account
1 Like

1- One update on Etherium is reflected to all tockens, tockens and understand each others
2- allow users to find out the balances of accounts as well as to transfer them from one account to another under varying conditions

1 Like
  1. It will be supported by all the wallets and exchanges, because they function in the same way.
  2. totalSupply() gives you how many tokens in circulation
    balance0f(adrress) you get the balance of wallet you want to check
    allowance() function shows how many tokens can be send from given address by another given address
2 Likes
  1. The ease of compatibility and interoperatibility between diferent smart contratcs
  2. balanceOf() provides the number of tokens held by a given address.
    transfer() transfer tokes from the message sender to another address
    approve() gives another address aproval to transfer up to a certain number of tokens.
    transferFrom() tranfer token from a given address that previous had given approval for that
3 Likes
  1. Many applications can be built that can communicate easily with each other. One wallet can accommodate different applications. Efficiency can be attained in a frictionless environment because all contracts are stuctured in one standard way.

  2. totalsupply function shows the amount of tokens in circulation
    balanceof shows the balance of a particular address
    transfer shows what has been transferred and where

1 Like
  1. Big benefit for all crypto space is standard ERC20 tokens witch use the same programming language
    and functions, because it easy to communicate between.
    2 TotalSupply() gives maximum number of tokens that exist
    balanceOf() gives a public addresses balance of ERC 20 tokens
    transfer () allows someone to transfer their ERC20 tokens to another public address
1 Like

1. What are the benefits of setting a token standard like ERC20?

dApps can easily communicate with the ETH ecosystem and everything that interacts with it.

2. What functions are in the ERC20 Token Standard Interface and what do they do?

[Not functions, but these are helpful to know. Functions below]
Name: name of the token
Symbol: akin to stock ticker symbol
Decimals: how divisible a token can be. Defines how balances are displayed.
Totalsupply: the sum of all balances

Functions
balanceOf(): # of tokens @ an address
transfer(): move tokens from one address to another
approve(): approval to transfer tokens
allowance(): # allowed to be transferred to another address

1 Like
  1. What are the benefits of setting a token standard like ERC20?
    -> Different applications can be built on one standard, which ensure that all parts / constituents of the network are able to communicate and interact.
  2. What functions are in the ERC20 Token Standard Interface and what do they do?
    -> totalSupply() - Get the total token supply
    -> `balanceOf() - Get the account balance of another account
    -> transfer() - transfers a number of tokens directly from the message sender to another address
    -> approve() - approval to transfer up to a certain number of tokens
    -> transferFrom() - Send value amount of tokens from address to another address
    -> allowance() - provides the number of tokens allowed to be transferred from a given address by another given address
1 Like
  1. One of the benefits of setting a token standard include interoperability between wallets and applications for all tokens that abide by the standard. The advantage of the interoperability include less confusion and more speed in developing programs that deal with these tokens.
  2. a) balanceOf() is a function that gets the balance of the number of tokens on an address.
    b) transfer() is a function to transfer tokens from one address to another.
    c) totalSupply() is a function that notes the total supply of the tokens.
1 Like
  1. Thal all wallets and exchanges will support the token
  2. The balanceOf() function provides the number of tokens held by a given address
    The transfer() function transfers a number of tokens directly from the message sender to another address, not used in paying for functions within the smart contract.
    To pay for these functions we have to use approve() to allow SC use tokens defined as “allowance” and when any function is called SC is using transferFrom() to take tokens from allowance as a payment.
    The allowance() is providing info about how many tokens are in the allowance.
1 Like
  1. What are the benefits of setting a token standard like ERC20?
    ERC20 is one of the most important standards for Ethereum: It defines how we call all program tokens. It’s good that all developers program in the same way. It means that all exchanges and wallets will support these tokes from day 1, it’s beneficial for the entire space.

  2. What functions are in the ERC20 Token Standard Interface and what do they do?
    balanceOf() - gives the number of tokens held by someone.
    transfer() - moves funds from one address to another
    aprove() and transferFrom() are 2 functions that work together in case that the tokens to be transfered are being used as payment in a smart contract
    The items in the token contract are:
    name - is the name of the token contract is the long name by which the token contract should be known
    symbol - is the symbol by which the token contract should be known
    decimals - because Ethereum does no support support decimals. If the token contract represent an indivisible entity then decimals should be 0.
    totalsupply - is the sum of all balances

1 Like

Can interact with other contracts, wallets and exchanges and its becomes easier for programmers to work if everything has a standard to follow.

totalSupply - total token supply.
balanceOf - account balance of another account.
transfer- transfers a number of tokens directly from the message sender to another.
approve - allows spenders to withdraw from your account multiple times.
transferFrom - transfers value amount of tokens from address to address.
allowance - returns the amount which spender is still allowed to withdraw from.

1 Like

1-What are the benefits of setting a token standard like ERC20?

Having a standard (ERC20) all tokens speak the same language this helps programmers to understand and provide improvements, as well as exchange and wallets can support the token from day 1.

2-What functions are in the standard interface of the ERC20 token and what do they do?

For ERC20 tokens we have many functions among which we can mention:

  • Transfer () this function is used when sending tokens from one address to another.
  • Allowance () this function gives us the number of tokens allowed to be transferred from one address to another address.
1 Like
  1. each wallet can support erc20 tokens from the beginning of supply. there are defined several standard functionalities, which would be supportet from each token and each wallet
  2. balaceOf() returns balance of a specific axxount
    totalSupply() returns the number of tokens which exists
    transfer() transfers a number ob tokens from A to B
1 Like
  1. What are the benefits of setting a token standard like ERC20?
    -It creates efficiency. Standards allows communication within the network. Without standards wallets could not recognize different tokens.
  2. What functions are in the ERC20 Token Standard Interface and what do they do?
    totalSupply() which checks the total supply of the tokens. balanceOf() gives the balance of specific account.
1 Like
  1. Setting a token standard like ERC-20 enables different developers, working on different projects, to write smart contracts for tokens which have the same naming and syntax conventions, even though the different tokens and smart contracts themselves have been created for a wide variety of different purposes and to achieve different outcomes. This enables interoperability between different smart contracts and applications, which in turn leads to more efficiency within the ecosystem as a whole. For example, by programming a new token according to the ERC-20 standard, this will automatically make it compatible with wallets and other applications which already interact with smart contracts for other ERC-20 tokens. Therefore, existing wallets will be able to display account balances for the new token, and it will be much easier for exchanges to list it. In addition, once a developer has learnt to write smart contracts according to a particular token standard, the same task then becomes easier and quicker to perform, leading to an increase in the developer’s productivity in that particular area.

  2. Functions in the ERC-20 Token Standard Interface:

function name()
Returns the name of the token e.g. “Basic Attention Token”.

function symbol()
Returns the abbreviation used to represent the token e.g. “BAT”.

function decimals()
Returns the number of decimals the token uses.
e.g. ‘8’ means that when displaying the token amount to users, the decimal point is placed before the last 8 digits of the corresponding numerical value in Ethereum.
e.g. ‘0’ means that a token is indivisible.

function totalSupply()
Returns the total number of tokens in circulation. This is equal to the sum of all address balances for the token.

function balanceOf(address _owner)
Returns the total number of tokens held in a specified account address (_owner).

function transfer(address _recipient, _amount)
Transfers a specified number of tokens (_amount) from the sender’s account to another user’s account address (_recipient).

The following two functions enable a user to pay a smart contract for performing operations:

(i) function approve(address _contract, _amount)
This first allows a specified smart contract address (_contract) to withdraw tokens from the user’s account multiple times, up to a specified limit (_amount) i.e. the user is effectively setting a budget, and giving the smart contract an allowance, for future operating costs.

(ii) function transferFrom(address _user, address _contract, _amount)
Whenever the user asks the smart contract to perform a certain operation, the smart contract now has the necessary permission to transfer a set number of tokens equal to the cost of that particular operation (_amount) from the user’s account address (_user) to the smart contract address (_contract), provided that both the user has sufficient tokens in their account to cover the cost and the smart contract’s allowance limit will not be exceeded.

function allowance(address _owner, address _contract)
Returns the amount of tokens a specified smart contract address (_contract) is still allowed to withdraw from another specified account address (_owner) i.e. the funds a smart contract is still entitled to withdraw from another account.

4 Likes
  1. All tokens implementing the ERC20 standard conform to an interface which is understood by the various software which handle them, such as exchange platforms and wallets.

  2. The ERC20 token standard defines the following functions:

   // gets the total supply of the token
   function totalSupply() constant returns (uint theTotalSupply);

   // gets the balance of a particular address
   function balanceOf(address _owner) constant returns (uint balance);

   // adds a given number of tokens to a given address
   function transfer(address _to, uint _value) returns (bool success);

   // moves a given amount of tokens from one address to another
   function transferFrom(address _from, address _to, uint _value) returns (bool success);

   // authorizes a given address to remove an amount of tokens from the owner's address
   function approve(address _spender, uint _value) returns (bool success);

   // gets the number of tokens allowed to be transferred from one address by another address
   function allowance(address _owner, address _spender) constant returns (uint remaining);
3 Likes