Homework: ERC20

[1.] It makes it a lot easier for everyone to be able to create a new smart contract currency and also allow for easy communication between different entities, e.g. wallets.

[2.] What functions are in the ERC20 Token Standard Interface and what do they do?
(a) function totalSupply() public view returns (uint256);
==> It returns the number of all tokens allocated by this contract

(b) function balanceOf(address tokenOwner) public view returns (uint);
==> It returns the current token balance of an account, identified by its owner’s address.

(c ) function allowance(address tokenOwner, address delegate)
==> It returns the current approved number of tokens by an owner to a specific delegate, as set in the approve function.

(d) function transfer(address receiver, uint numTokens) public returns (bool);
==> It moves numTokens amount of tokens from the owner’s balance to that of another user, or receiver

(e) function approve(address delegate, uint tokens) public returns (bool);
==> It allows an owner of the contract to approve a delegate account, e.g. the marketplace itself — to withdraw tokens from his account and to transfer them to other accounts.

(f) function transferFrom(address owner, address buyer, uint numTokens) public returns (bool);
==> This is the peer of the approve function, which we discussed above. It allows a delegate approved for withdrawal to transfer owner funds to a third-party account.

1 Like
  • What are the benefits of setting a token standard like ERC20?
    Having the same token standards makes it easier using wallets, doing exchanges etc.

  • What functions are in the ERC20 Token Standard Interface and what do they do?
    totalSupply(): gives maximum number of tokens that exist
    balanceOf(address): gives a public addresses’ balance of ERC20 tokens
    transfer(): allows transfer of their ERC20 tokens to another public address
    doSomething(): operates instructions.
    allowance(): Provides the amount of allowed tokens to be transferred from a given address by another.

1 Like
  1. A standard removes friction because new tokens get added more easily to wallets/exchanges.
  2. ERC20 includes functions for checking the balance of an account or the total supply of the token.
1 Like

@filip I have a question: how can I see the code for a given ERC20 token?
For example if I know the Ethereum address of the contract for BAT is 0x0D8775F648430679A709E98d2b0Cb6250d2887EF
how can I get the code that lives at this address? (I don’t want to trust the Basic Attention Token webpage to tell me what the code is).

1 Like

1.) ERC20 standards are beneficial because they allow new tokens to be easily incorporated. Basically, they share the same “language” and dont need new wallets for new tokens.

2.) Some of the funtions in the ERC20 Token Standard Interface are:

totalSupply() - total number of tokens in circulation
balanceOf(address account) - number of tokens held by a specific address
transfer() - initiates a transfer of tokens from one address to another

1 Like
  1. Wallets can support future tokens that have ERC20 standards. Also, allows the entire space to scale more efficiently.
  2. balanceOf(address account) shows the token balance of a public address
    totalSupply() shows the total amount of tokens that exist.
    transfer() enables a person to transfer their ERC20 token to another public address.
1 Like
  1. allows wallets and exchanges to add erc 20 tokens
  2. there is a lot for sure. balaceOf gets the balance of an account
1 Like
  • What are the benefits of setting a token standard like ERC20?
    —it makes them a fungible token, all tokens are made with the same standard.
  • What functions are in the ERC20 Token Standard Interface and what do they do?
    —its a diagram that shows address histories and uses balances to represent physical objects, monetary value, and or the holder’s reputation.

1.What are the benefits of setting a token standard like ERC20?
Uniformity of tech & protocol standard.
It lowers the complexity of understanding each token implementation.
It provides greater liquidity to ERC-20 tokens.
There will be less risk of breaking contracts.

  1. What functions are in the ERC20 Token Standard Interface and what do they do?
    The following functions are in the ERC20 Token Standard interface and are there so that the tokens can be shared or exchanged for other tokens or transferred to a crypto wallet.
    Mandatory Functions
  • totalSupply, balanceOf, transfer, transferFrom, approve, allowance.

Optional Functions:

  • Token Name, Symbol, Decimal (up to 18 decimals).
1 Like
  1. the benefits are that they are fungible, there is no difference between ERC20 token, they have the same value. And it is more easy to understand and programm when a token standard already exists.
  2. function totalsupply - standard option for all ERC20
    function balanceof - it gives the adress account a balance
    funciton transfer - it gives the adress account an transfer option
1 Like
  • What are the benefits of setting a token standard like ERC20?

Setting standards allows for greater efficiency and effectivness of a network. Also new projects can follow standard guidlines which will allow ease of interoperability with existing networks.
Wallets and exchanges can be programmed to interact with the standard protocols.

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

totalSupply() - returns with the total supply of that token
balanceOf() - returns with the token amount of that address
transfer() - transfer amount of token from this address to another
approve() - allows the reciept of tokens from another address
transferFrom() - It takes three inputs; sender address, reciever address, amount to transfer, and outputs the resolution ie. was transfer completed or not.
allowance() - shows the valid number of transferable tokens

1 Like

I don’t understand your question. I thought that my answer stated those functions of the ERC-20 interface.

1 Like
  1. What are the benefits of setting a token standard like ERC20?
    Setting a standard allow means developers are all required to use the same terminology in their code. The benefits of this are new tokens can take advantage of existing infrastructure such as exchanges and wallets, allowing new tokens to be sent to wallets or exchanges as soon as it has been created. The standard also reduces the risks of contracts not functioning as intended.

  2. What functions are in the ERC20 Token Standard Interface and what do they do?
    There are six mandatory functions and three optional functions in the ERC20 standard:
    Mandatory

  • totalSupply() - Sets the maximum supply of the token

  • balanceOf() - Queries the number of tokens in a chosen address.

  • transfer() - Transfer tokens from one address to another

  • transferFrom() - Allows you to automate taking transfer from other addresses, like a direct debit.

  • approve - approve that the correct number of tokens can be sent from the contract’s address, it also double checks that the tokens in the transactions line up with the total supply.

  • allowance - checks the sender has the required amount of tokens in their account.

    Optional

  • Token Name - Set the token name

  • Symbol - Set the ticker symbol for your token (e.g Ethereum is Eth)

  • Decimal (up to 18) - Set how many decimal places each token can be divided into. A divisibility of 3 will give the lowest possible value of 0.001.

1 Like
  • What are the benefits of setting a token standard like ERC20?
    This creates an environment where all programming uses the same function names. This allows for a wallet to communicate with all of the tokens built on the ETH network.

  • What functions are in the ERC20 Token Standard Interface and what do they do?
    Well we were made familiar with 2. totalsupply() and balanceOf(account balance)
    totalsupply() is just that. Every token has this written into the code for setting what the total supply of a particular token will be.
    BalanceOf(account balance) is a function wallets use to give the supply of tokens available for an address.

1 Like

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

  • balanceOf(): provides the number of tokens held by a given address.
  • transfer(): transfers a number of tokens directly from the message sender to another address.
  • transferFrom(): transfers a number of tokens directly from an account to another address. Used with approve() function.
  • approve(): approval to transfer up to a certain number of tokens, known as an allowance.
  • allowance(): provides the number of tokens allowed to be transferred from a given address by another given address.

@dpopp1 check this one too!

Hope this gives you a clear view of the subject, keep learning! :slight_smile:

If you have any doubt, please let us know so we can help you!

Carlos Z.

1 Like

Excellent answer sir! really well documented! keep it like that please! :muscle:

Carlos Z.

Hello sir, you have to read the code itself, you can do it on etherscan on the tab “contract”, some contract like BAT have the code to be read it by the public, others will have to decompile de Bytecode.

BAT Contract Source Code (Solidity)

Hope this gives you a clear view of the subject, keep learning! :slight_smile:

If you have any doubt, please let us know so we can help you!

Carlos Z.

1 Like

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

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

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

Carlos Z.

Excellent answer sir! really well documented! keep it like that please! :muscle:

Carlos Z.

1 Like

Ah - you were looking for a programming answer. :grimacing: Not there yet, never programmed, I am deciding on a commitment to the JavaScript programming course…

Thanks

1 Like