Reading this article requires a basic understanding of the concepts of Ethereum, smart contracts, tokens, and so on. What is ERC20
1 2 3 4 5 6 7 8 9 10 11 12 13Name
Returns the name of the ERC20 token, such as "My test token".
Symbol
Returns the abbreviation for tokens, for example: MTT, which is also the name that we generally see on the token exchange.
Decimals
Returns the number of tokens used after the decimal point. For example, if set to 3, that is, support 0.001 means.
Totalsupply
Returns the total amount of token supply
Balanceof
Return an account balance for an address (account)
Transfer
Transfer the number of _value tokens from the caller address of the token contract to the address _to, and the transfer event must be triggered.
Transferfrom
The transfer event must be triggered from the address _from to send the token to address _to of _value.
The Transferfrom method is used to allow a contract to proxy someone to transfer tokens. The condition is that the from account must be approve. This is illustrated later.
Approve
Allow _spender to retrieve your account multiple times, up to _value amount. If you call this function again, it will overwrite the current margin with _value.
Allowance
Returns the amount that _spender is still allowed to extract from _owner.
The following three methods are not good to understand, here also need to add a note,
Approve is authorizing a third party (such as a service contract) to transfer tokens from the sender's account and then perform a specific transfer operation through the Transferfrom () function.
Account A has 1000 eth and wants to allow the B account to call his 100 eth at random, as follows:
A account calls the Approve function approve (b,100) in the following form
b account would like to use the 10 eth in these 100 ETH to C account, call Transferfrom (A, C, 10)
Call allowance (A, B) to view the B account and also be able to invoke the a account number of tokens
In addition, I recommend this article, the concept of this part of the explanation is relatively clear.
Https://mp.weixin.qq.com/s/foM1QWvsqGTdHxHTmjczsw