Homework: ERC20

  1. The benefits of setting a token standard like ERC20 are that tokens are easy to create, implement. They are fungible and identical, they are supported by wallets and exchanges from the word go. Exchanges and wallet providers only have to implement ERC20 code once after that they can list all ERC20 base tokens also they can add new token quickly.
  2. ERC20 has 9 functions which can be divided into two categories: 1) optional which gives identity to a token. These functions are name - the token name, symbol - unique symbol of the token e.g. TYK and decimal - divisibility of the token most common 8 & 18. 2) mandatory which define a tokens structure. These functions are total supply - maximum number of tokens to spend in SC, balanceOf - SC wallet with total number of tokens, approve - approval to send tokens to another wallet, transfer - the act of transferring tokens to another wallet, transferFrom - helps holders to spend their tokens automatically and allowance - the minimum allowed to spend.
1 Like
  1. Helps the industry to develop more rapidly. For example wallets and exchanges will be able to more easily add tokens as there’s a standard and costly bespoke solutionswont be necessary.

  2. There are a number of functions including total supply, which gives the number of tokens that exist. Balance of, gives the balance of a particular address, and transfer, which allows people to send transactions between addresses.

1 Like
  1. Interoperability.
  2. balanceOf() gets an address’s balance.
    totalSupply is to get total Supply
    transfer transfers
1 Like
  1. Having a common standard allows wallets and exchanges to be programmed to support any token using that standard, such as the ERC 20. This is more efficient than each token having its own code, which would be more costly and time-consuming to build around.

  2. totalSupply() specifies the maximum number of tokens that exist.
    balanceOf(address account) specifies the balance of an ERC20 account
    transfer() allows users to transfer an ERC20 token to another ERC20 wallet

1 Like
  1. What are the benefits of setting a token standard like ERC20?
    It makes the creation of smart contracts much easier and ensures that all programmers use the same structure making it compatible!

  2. What functions are in the ERC20 Token Standard Interface and what do they do?
    There are quite some functions described, such as totalsupply, which gives you the total number of tokens; balanceOf gives the balance of a specific account and transfer let’s you transfer from one account to another.

1 Like

1.Benefits of setting a token standard like ERC20 is that it makes all tokens have the same standard codes, making it easy for the exchanges to adopt them.

  1. Functions in the ERC20 token standard interface are , total supply, adding, multiply, divide, transfer, balance. They allow the executions of transactions in a standard way for the ERC20 tokens.

-The benefits of setting a token standard like ERC20 is that it increases efficiency and allows tokens to operate on platforms and wallets seamlessly.

-The functions that are in the ERC20 are:

  • totalSupply() which gives a number as an output. This number is the total supply of the token
  • balanceOf() which takes the address of an owner as the input and gives the balance of the users as output
  • allowance() function takes in the address of the tokenOwner and the spender and gives as output, the number of tokens allowed to be transferred from a given address by another given address.
  • transfer() function simply takes in the address of the receiver and the funds which are to be sent to the account
  • approve() function. You can approve someone to spend from your account.
  • transferFrom() function. It takes in three inputs — the address of the sender, the address of the receiver, as well as the number of tokens to be transferred. And gives an output of the success or failure of the transfer.
1 Like
  1. What are the benefits of setting a token standard like ERC20?
    Ans - So that the wallets and exchanges doesnt have to deal with diff tokens in a different and unique way .
  2. What functions are in the ERC20 Token Standard Interface and what do they do?
    Ans - balanceof ( to know the balance of tokens ) , totalsupply ( max number of tokens exits ) , transfer , approve etc
1 Like

Excellent answers sir, well documented! Please keep them like that :muscle:

Carlos Z.

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

Yes sir, but could you please describe what those functions do?

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

  1. Fungibility. Also ERC-20 tokens can be traded on multiple exchanges since they conform to a single standard that exchanges can agree on.

  2. (from https://eips.ethereum.org/EIPS/eip-20)
    function name() <— returns the token name
    function symbol() <— returns the token symbol
    decimals() <— returns the number of decimals used by the token
    totalSupply() Returns the total token supply.
    balanceOf(address_owner) Returns the account balance of another account with address _owner.
    transfer(address _to, uint256 _value) Transfers _value amount of tokens to address _to
    balanceOf
    Returns the account balance of another account with address _owner
    function balanceOf(address _owner) public view returns (uint256 balance)

    transfer
    Transfers _value amount of tokens to address _to, and MUST fire the Transfer event. The function SHOULD throw if the message caller’s account balance does not have enough tokens to spend.

Note Transfers of 0 values MUST be treated as normal transfers and fire the Transfer event.

function transfer(address _to, uint256 _value) public returns (bool success)

transferFrom

Transfers _value amount of tokens from address _from to address _to , and MUST fire the Transfer event.

The transferFrom method is used for a withdraw workflow, allowing contracts to transfer tokens on your behalf. This can be used for example to allow a contract to transfer tokens on your behalf and/or to charge fees in sub-currencies. The function SHOULD throw unless the _from account has deliberately authorized the sender of the message via some mechanism.

Note Transfers of 0 values MUST be treated as normal transfers and fire the Transfer event.

function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)

approve

Allows _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 .

NOTE : To prevent attack vectors like the one described here and discussed here, clients SHOULD make sure to create user interfaces in such a way that they set the allowance first to 0 before setting it to another value for the same spender. THOUGH The contract itself shouldn’t enforce it, to allow backwards compatibility with contracts deployed before

function approve(address _spender, uint256 _value) public returns (bool success)

allowance

Returns the amount which _spender is still allowed to withdraw from _owner .

function allowance(address _owner, address _spender) public view returns (uint256 remaining)

Events

Transfer

MUST trigger when tokens are transferred, including zero value transfers.

A token contract which creates new tokens SHOULD trigger a Transfer event with the _from address set to 0x0 when tokens are created.

event Transfer(address indexed _from, address indexed _to, uint256 _value)

Approval

MUST trigger on any successful call to approve(address _spender, uint256 _value) .

event Approval(address indexed _owner, address indexed _spender, uint256 _value)
1 Like
  1. The benefit of a token standard like ERC20 is that all tokens can interact with wallets in the same way. So one wallet can work with any token based on the ERC20 standard.

totalSupply() - returns total amount of tokens that exist
balanceOf(address) - returns token balance of address passed
transfer(address, uint256) - transfers specified amount to another address
transferFrom(address, address, uint256) - transfers specified amount from one address to another.
approve(address, uint256) - sets an allowance for an address to spend a certain amount of the token on behalf of designated address
allowance(address, address) - returns the allowance of a specified address to spend on behalf of another address

1 Like
  1. What are the benefits of setting a token standard like ERC20?
    A: Having the ERC20 standard promotes a seamless interface between token(s), wallets, and exchanges. Additionally, it provides a foundational base of functions for developers to work from when creating tokens.

  2. What functions are in the ERC20 Token Standard Interface and what do they do?
    A: 1. transfer()…sending tokens from one address to another
    2. balanceOf()…finding the number of tokens held by a particular address
    3. transferFrom()…allows the taking of tokens from a wallet within the parameters of the smart contract
    4. approve()…works in conjunction with transferFrom() to give an address approval to transfer an allowance of tokens to another address.
    5. allowance()…gives the number of tokens allowed to be transferred from one address to an another.

1 Like
  1. What are the benefits of setting a token standard like ERC20?
  2. What functions are in the ERC20 Token Standard Interface and what do they do?

Answers:-

  1. The ERC20 token convention standard ensures these different tokens smart contract to be programmed within the standard to be efficient with no friction so it works well within the network.

  2. transferOf() shows a public address and the balance of ERC20 token.
    totalsupply () shows maximum token that exists.

1 Like
  1. Benefits of setting standards is so that all exchanges and wallets can understand and manage the tokens.
  2. Typical functions include TotalSupply and BalanceOf which return the total supply and the balance in the wallet respectively.
1 Like

@ggunhold
Excellent answers, well documented! Please keep them like that :muscle:

Abel S.

1 Like

@rhotoshi
Excellent answers, well documented! Please keep them like that :muscle:

Abel S.

1 Like
  • Having a standard is efficient, all wallets know how to talk to tokens making it easy to interoperate with each other. This helps propel the platform forward.
  • Functions communicate an action. For examplebalanceOf: Returns calculates how many tokens exist in an account.
  1. Less friction because everyone can follow the same rules and each smart contract can communicate with the main chain.

  • totalSupply : Returns the total circulating amount of tokens.
  • balanceOf : Returns how many tokens exist in an account.
  • transfer : Transfer an amount of tokens from token owner’s account to another account.
  • approve : A token owner can approve for spender to transferFrom tokens from the token owner’s account.
  • allowance : Returns the amount of tokens approved by the owner that can transferred to the spender’s account.
  • transferFrom : Allows a spender account to transfer an amount of tokens on behalf of the token owner to another account.
1 Like
  1. The benefits of a token standard are that all exchanges, wallets,… can easily integrate your token.

  2. In the ERC20 Token Standard Interface are functions like:

  • balanceOf(account) -> gets the balance of an account address
  • totalSupply() -> gets the total Supply of tokens
  • transfer(…) -> transfer tokens from one account to anothe
1 Like