Learn ERC20 in Solidity | Transfer Function

Solidity Programming Language
3 min readFeb 26, 2022

--

ERC20

Aim : To learn ERC20 and make your own token

Code:

Compile it !

Choose the ERC20 file from Contract Section and deploy with your datas.

0x5B38Da6a701c568545dCfcB03FcB875f56beddC4 is owner

……………………………………………………………………..

This owner account has 1000 token.

balanceOf” : This indicates tokens amount which any address has. We put owner address and this functions gives us tokens amount which owner address has

We are 3 persons.

Owner

Bob

Alice

SENT TOKENS with TRANSFER FUNCTION

Owner would like to sent 100 tokens to the Alice. Owner can sent this amount with transfer function.

This is ERC20 transfer function.

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol

This function calls the _transfer function and _transfer function checks some controls.

owner’s address is zero address ?

alice’s address is zero address ?

owner’s token amount is greater than the amount of sending tokens.

Everthing is ok .

Owner can sent 100 tokens to the Alice.

Thank you owner

Now Alice wants to sent 50 tokens to the Bob

Firstly, account should be 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2

Alice uses transfer function and sents 50 tokens to the Bob.

Thank you Alice.

Bob has 50 tokens

Dr. Engin YILMAZ

Ankara

2022

--

--

Solidity Programming Language

Solidity basics for beginners: Learn the fundamentals of smart contract development and build your first DApp! #Solidity #Foundry #Ethereum #Opcodes #DApps